作者 yangfu

标签分类修改

... ... @@ -2,7 +2,6 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
... ... @@ -26,14 +25,20 @@ func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
var (
conn = l.svcCtx.DefaultDBConn()
categoryList []*domain.ArticleCategory
)
queryOption := domain.NewQueryOptions().WithFindOnly()
_, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取标签列表失败", err)
}
_, categoryList, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions().MustWithKV("enable", 1))
if err != nil {
return nil, xerr.NewErrMsgErr("获取标签分类列表失败", err)
}
// 合并输出数据
var group []string
tagMap := map[string][]types.ArticleTagItem{}
for _, val := range tagList {
if m, ok := tagMap[val.Category]; ok {
... ... @@ -46,7 +51,6 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
})
tagMap[val.Category] = m
} else {
group = append(group, val.Category)
tagMap[val.Category] = []types.ArticleTagItem{
{
Id: val.Id,
... ... @@ -61,10 +65,10 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
resp = &types.MiniAllArticleTagResponse{
TagGroup: make([]types.ArticleTagGroup, 0),
}
for i := range group {
for _, category := range categoryList {
resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{
Category: group[i],
Tags: tagMap[group[i]],
Category: category.Name,
Tags: tagMap[category.Name],
})
}
return resp, nil
... ...