This commit is contained in:
laodaming 2023-09-11 13:05:31 +08:00
parent 2553c6c821
commit cc7fcb2133
2 changed files with 11 additions and 11 deletions

View File

@ -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)
}

View File

@ -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")