This commit is contained in:
laodaming
2023-07-14 14:38:34 +08:00
parent 56a8b32d90
commit 86a2deacfb
3 changed files with 71 additions and 55 deletions

View File

@@ -31,9 +31,11 @@ func (t *FsTagsModel) GetAllByLevel(ctx context.Context, level int) (resp []FsTa
}
type GetAllTagByParamsReq struct {
Ids []int64
Status *int64
OrderBy string
Ids []int64
Status *int64
OrderBy string
LevelPrefixLeftLike string //右模糊
WithChild bool //是否包含子层级
}
func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByParamsReq) (resp []FsTags, err error) {
@@ -44,6 +46,14 @@ func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByPara
if req.Status != nil {
db = db.Where("`status` = ?", *req.Status)
}
if req.LevelPrefixLeftLike != "" {
//查询子集
if req.WithChild {
db = db.Where("`level_prefix` like ?", req.LevelPrefixLeftLike+`%`)
} else {
db = db.Where("`level_prefix` = ?", req.LevelPrefixLeftLike+`%`)
}
}
switch req.OrderBy {
case "":
db = db.Order("`id` DESC")