From cc7fcb213384ff186c9f0fd0d3aadbe213bf8441 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 11 Sep 2023 13:05:31 +0800 Subject: [PATCH] fix --- model/gmodel/fs_product_template_tags_logic.go | 8 ++++---- .../internal/logic/getproducttemplatetagslogic.go | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/model/gmodel/fs_product_template_tags_logic.go b/model/gmodel/fs_product_template_tags_logic.go index d0492bd2..b2529fcf 100755 --- a/model/gmodel/fs_product_template_tags_logic.go +++ b/model/gmodel/fs_product_template_tags_logic.go @@ -23,8 +23,8 @@ func (pt *FsProductTemplateTagsModel) FindOne(ctx context.Context, id int64, fie err = db.Take(&resp).Error return resp, err } -func (pt *FsProductTemplateTagsModel) GetList(ctx context.Context, page, limit int, isHide, status int64, orderBy string) (resp []FsProductTemplateTags, err error) { - db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`is_hide` = ? and `status` = ?", isHide, status) +func (pt *FsProductTemplateTagsModel) GetList(ctx context.Context, page, limit int, status int64, orderBy string) (resp []FsProductTemplateTags, err error) { + db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where(" `status` = ?", status) if orderBy != "" { db = db.Order(orderBy) } @@ -32,11 +32,11 @@ func (pt *FsProductTemplateTagsModel) GetList(ctx context.Context, page, limit i err = db.Offset(offset).Limit(limit).Find(&resp).Error return resp, err } -func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tagNames []string, limit int, isHide, status int64, orderBy string) (resp []FsProductTemplateTags, err error) { +func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tagNames []string, limit int, status int64, orderBy string) (resp []FsProductTemplateTags, err error) { if len(tagNames) == 0 { return nil, nil } - db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` in (?) and `is_hide` = ? and `status` = ?", tagNames, isHide, status) + db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` in (?) and `status` = ?", tagNames, status) if orderBy != "" { db = db.Order(orderBy) } diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index 184de958..8211d783 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -50,7 +50,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu //白板用户 if !userinfo.IsUser() && !userinfo.IsGuest() { // 返回固定模板标签列表 - productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetList(l.ctx, 1, req.Limit, 0, 1, "`id` DESC") + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, []string{"A1a"}, req.Limit, 1, "`id` DESC") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags") @@ -63,8 +63,8 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get ai recommend product template tag list") } - // 返回固定模板标签列表 - productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetList(l.ctx, 1, req.Limit, 0, 1, "`id` DESC") + // 返回固定模板A1a + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, []string{"A1a"}, req.Limit, 1, "`id` DESC") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags") @@ -72,8 +72,8 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu } else { //元数据是空的 if userMaterial.Metadata == nil { - // 返回固定模板标签列表 - productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetList(l.ctx, 1, req.Limit, 0, 1, "`id` DESC") + // 返回固定模板A1a + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, []string{"A1a"}, req.Limit, 1, "`id` DESC") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags") @@ -81,7 +81,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu } else { //解析元数据 var metaData map[string]interface{} - if err = json.Unmarshal([]byte(*userMaterial.Metadata), &metaData); err != nil { + if err = json.Unmarshal(*userMaterial.Metadata, &metaData); err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata") } @@ -91,7 +91,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu logx.Error(err) return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid") } - productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 0, 1, "id DESC") + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags")