This commit is contained in:
laodaming 2023-08-17 11:49:31 +08:00
parent 98c5eae6ee
commit d2c8fa9020
2 changed files with 8 additions and 11 deletions

View File

@ -43,7 +43,11 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag
err = db.Limit(limit).Find(&resp).Error
return resp, err
}
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string) (resp *FsProductTemplateTags, err error) {
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", tagName, 1).Take(&resp).Error
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string, fields ...string) (resp *FsProductTemplateTags, err error) {
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", tagName, 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Take(&resp).Error
return resp, err
}

View File

@ -8,7 +8,6 @@ import (
"fusenapi/utils/basic"
"fusenapi/utils/format"
"gorm.io/gorm"
"strconv"
"strings"
"context"
@ -62,13 +61,7 @@ func (l *GetTemplatevDetailLogic) GetTemplatevDetail(req *types.GetTemplatevDeta
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product template info")
}
//获取模板标签
templateTagModel := gmodel.NewFsProductTemplateTagsModel(l.svcCtx.MysqlConn)
tagId, err := strconv.ParseInt(*templatev2Info.Tag, 10, 64)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "parse int tag id err")
}
templateTagInfo, err := templateTagModel.FindOne(l.ctx, tagId, "id,title")
templateTagInfo, err := l.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(l.ctx, *templatev2Info.TemplateTag, "id,title")
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template tag info is not exists")
@ -125,7 +118,7 @@ func (l *GetTemplatevDetailLogic) GetTemplatevDetail(req *types.GetTemplatevDeta
}
templateInfoRsp["tag"] = map[string]interface{}{
"id": templateTagInfo.Id,
"title": *templateTagInfo.Title,
"title": *templateTagInfo.TemplateTag,
}
response := types.GetTemplatevDetailRsp{
ProductModelInfo: productModelInfoRsp,