fix
This commit is contained in:
@@ -85,3 +85,35 @@ func (p *FsProductModel) GetRandomProductListInIds(ctx context.Context, ids []in
|
||||
err = db.Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
type GetProductListByParamsReq struct {
|
||||
Type []int64
|
||||
IsDel *int64
|
||||
IsShelf *int64
|
||||
Status *int64
|
||||
OrderBy string
|
||||
}
|
||||
|
||||
func (p *FsProductModel) GetProductListByParams(ctx context.Context, req GetProductListByParamsReq) (resp []FsProduct, err error) {
|
||||
db := p.db.WithContext(ctx).Model(&FsProduct{})
|
||||
if len(req.Type) > 0 {
|
||||
db = db.Where("`type` in (?)", req.Type)
|
||||
}
|
||||
if req.IsDel != nil {
|
||||
db = db.Where("`is_del` = ?", *req.IsDel)
|
||||
}
|
||||
if req.IsShelf != nil {
|
||||
db = db.Where("`is_shelf` = ?", *req.IsShelf)
|
||||
}
|
||||
if req.Status != nil {
|
||||
db = db.Where("`status` = ?", *req.Status)
|
||||
}
|
||||
switch req.OrderBy {
|
||||
case "":
|
||||
db = db.Order("`id` DESC")
|
||||
default:
|
||||
db = db.Order(req.OrderBy)
|
||||
}
|
||||
err = db.Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ type FsTags struct {
|
||||
Description *string `gorm:"default:'';" json:"description"` // 介绍 Seo
|
||||
RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` //
|
||||
RecommendProductSort *string `gorm:"default:'';" json:"recommend_product_sort"` //
|
||||
LevelPrefix *string `gorm:"default:'';" json:"level_prefix"` //归属等级前缀
|
||||
}
|
||||
type FsTagsModel struct{ db *gorm.DB }
|
||||
|
||||
|
||||
@@ -29,3 +29,27 @@ func (t *FsTagsModel) GetAllByLevel(ctx context.Context, level int) (resp []FsTa
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type GetAllTagByParamsReq struct {
|
||||
Ids []int64
|
||||
Status *int64
|
||||
OrderBy string
|
||||
}
|
||||
|
||||
func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByParamsReq) (resp []FsTags, err error) {
|
||||
db := t.db.WithContext(ctx).Model(&FsTags{})
|
||||
if len(req.Ids) > 0 {
|
||||
db = db.Where("`id` in (?)", req.Ids)
|
||||
}
|
||||
if req.Status != nil {
|
||||
db = db.Where("`status` = ?", *req.Status)
|
||||
}
|
||||
switch req.OrderBy {
|
||||
case "":
|
||||
db = db.Order("`id` DESC")
|
||||
default:
|
||||
db = db.Order(req.OrderBy)
|
||||
}
|
||||
err = db.Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user