Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
7383d60bfe
|
@ -43,8 +43,8 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag
|
||||||
err = db.Limit(limit).Find(&resp).Error
|
err = db.Limit(limit).Find(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string, fields ...string) (resp *FsProductTemplateTags, err error) {
|
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, templateTagName string, fields ...string) (resp *FsProductTemplateTags, err error) {
|
||||||
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", tagName, 1)
|
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", templateTagName, 1)
|
||||||
if len(fields) != 0 {
|
if len(fields) != 0 {
|
||||||
db = db.Select(fields[0])
|
db = db.Select(fields[0])
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,19 @@ func (l *GetTemplateTagColorLogic) GetTemplateTagColor(req *types.GetTemplateTag
|
||||||
}
|
}
|
||||||
resourceId := s[len(s)-1]
|
resourceId := s[len(s)-1]
|
||||||
var (
|
var (
|
||||||
userMaterial *gmodel.FsUserMaterial
|
userMaterial *gmodel.FsUserMaterial
|
||||||
err error
|
templateTagInfo *gmodel.FsProductTemplateTags
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
|
//获取模板标签信息
|
||||||
|
templateTagInfo, err = l.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(l.ctx, req.TemplateTag)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the template tag is not exists")
|
||||||
|
}
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tag info")
|
||||||
|
}
|
||||||
//游客或者用户
|
//游客或者用户
|
||||||
if userinfo.IsUser() || userinfo.IsGuest() {
|
if userinfo.IsUser() || userinfo.IsGuest() {
|
||||||
userMaterial, err = l.svcCtx.AllModels.FsUserMaterial.FindOneByUserAndLogoUrl(l.ctx, userinfo.UserId, userinfo.GuestId, resourceId)
|
userMaterial, err = l.svcCtx.AllModels.FsUserMaterial.FindOneByUserAndLogoUrl(l.ctx, userinfo.UserId, userinfo.GuestId, resourceId)
|
||||||
|
@ -85,9 +95,17 @@ func (l *GetTemplateTagColorLogic) GetTemplateTagColor(req *types.GetTemplateTag
|
||||||
if req.SelectedColorIndex >= len(colors) {
|
if req.SelectedColorIndex >= len(colors) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "select color index is out of range !!")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "select color index is out of range !!")
|
||||||
}
|
}
|
||||||
|
var templateTagGroups interface{}
|
||||||
|
if templateTagInfo.Groups != nil && *templateTagInfo.Groups != "" {
|
||||||
|
if err = json.Unmarshal([]byte(*templateTagInfo.Groups), &templateTagGroups); err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse template tag`s groups info")
|
||||||
|
}
|
||||||
|
}
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTemplateTagColorRsp{
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTemplateTagColorRsp{
|
||||||
Colors: colors,
|
Colors: colors,
|
||||||
SelectedColorIndex: req.SelectedColorIndex,
|
SelectedColorIndex: req.SelectedColorIndex,
|
||||||
|
TemplateTagGroups: templateTagGroups,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,9 @@ type GetTemplateTagColorReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTemplateTagColorRsp struct {
|
type GetTemplateTagColorRsp struct {
|
||||||
Colors [][]string `json:"colors"`
|
Colors [][]string `json:"colors"`
|
||||||
SelectedColorIndex int `json:"selected_color_index"`
|
SelectedColorIndex int `json:"selected_color_index"`
|
||||||
|
TemplateTagGroups interface{} `json:"template_tag_groups"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
|
|
|
@ -39,6 +39,7 @@ type GetTemplateTagColorReq {
|
||||||
SelectedColorIndex int `form:"selected_color_index"`
|
SelectedColorIndex int `form:"selected_color_index"`
|
||||||
}
|
}
|
||||||
type GetTemplateTagColorRsp {
|
type GetTemplateTagColorRsp {
|
||||||
Colors [][]string `json:"colors"`
|
Colors [][]string `json:"colors"`
|
||||||
SelectedColorIndex int `json:"selected_color_index"`
|
SelectedColorIndex int `json:"selected_color_index"`
|
||||||
|
TemplateTagGroups interface{} `json:"template_tag_groups"`
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user