From 0fd64a27bd939c922899e7b5a10edab3849c1a03 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 22 Aug 2023 12:16:02 +0800 Subject: [PATCH] fix --- model/gmodel/fs_tags_logic.go | 6 +++++- server/product/internal/logic/gettagproductlistlogic.go | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/model/gmodel/fs_tags_logic.go b/model/gmodel/fs_tags_logic.go index 35efa42c..b108a337 100755 --- a/model/gmodel/fs_tags_logic.go +++ b/model/gmodel/fs_tags_logic.go @@ -36,7 +36,8 @@ type GetAllTagByParamsReq struct { OrderBy string LevelPrefixLeftLike string //右模糊 WithChild bool //是否包含子层级 - Category int64 + Category int64 //分类 + Level int64 } func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByParamsReq) (resp []FsTags, err error) { @@ -50,6 +51,9 @@ func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByPara if req.Category != 0 { db = db.Where("`category` = ?", req.Category) } + if req.Level > 0 { + db = db.Where("`level` = ?", req.Level) + } if req.LevelPrefixLeftLike != "" { //查询子集 if req.WithChild { diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index c8642633..b69736d0 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -51,6 +51,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR OrderBy: "`sort` DESC", WithChild: true, //需要子集 Category: 1, //前台网站用的 + Level: 2, //等级是2的 } //传入分类id if req.Cid > 0 { @@ -63,8 +64,8 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag info") } - //前台用的分类是1 - if *tagData.Category != 1 { + //前台用的分类是1,且等级是2 + if *tagData.Category != 1 && *tagData.Level != 2 { return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "invalid tag") } tReq.LevelPrefixLeftLike = *tagData.LevelPrefix