diff --git a/model/gmodel/fs_tags_gen.go b/model/gmodel/fs_tags_gen.go index 13bc3800..5f27544b 100644 --- a/model/gmodel/fs_tags_gen.go +++ b/model/gmodel/fs_tags_gen.go @@ -18,6 +18,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"` // + Category *int64 `gorm:"default:1;" json:"category"` // 分类:1前台用的 2后台用的 } type FsTagsModel struct { db *gorm.DB diff --git a/model/gmodel/fs_tags_logic.go b/model/gmodel/fs_tags_logic.go index 75028f93..35efa42c 100755 --- a/model/gmodel/fs_tags_logic.go +++ b/model/gmodel/fs_tags_logic.go @@ -36,6 +36,7 @@ type GetAllTagByParamsReq struct { OrderBy string LevelPrefixLeftLike string //右模糊 WithChild bool //是否包含子层级 + Category int64 } func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByParamsReq) (resp []FsTags, err error) { @@ -46,6 +47,9 @@ func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByPara if req.Status != nil { db = db.Where("`status` = ?", *req.Status) } + if req.Category != 0 { + db = db.Where("`category` = ?", req.Category) + } if req.LevelPrefixLeftLike != "" { //查询子集 if req.WithChild { diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 7badfd95..42e240e1 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -50,6 +50,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR Status: &tStatus, OrderBy: "`sort` DESC", WithChild: true, //需要子集 + Category: 1, //前台网站用的 } //传入分类id if req.Cid > 0 { @@ -62,6 +63,9 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag info") } + if *tagData.Category != 1 { + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "invalid tag") + } tReq.LevelPrefixLeftLike = *tagData.LevelPrefix } tagList, err := l.svcCtx.AllModels.FsTags.GetAllTagByParams(l.ctx, tReq)