作者 yangfu

Merge branch 'dev' into test

@@ -2,7 +2,6 @@ package article @@ -2,7 +2,6 @@ package article
2 2
3 import ( 3 import (
4 "context" 4 "context"
5 -  
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 5 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
@@ -26,14 +25,20 @@ func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) @@ -26,14 +25,20 @@ func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext)
26 } 25 }
27 26
28 func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) { 27 func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) {
29 - var conn = l.svcCtx.DefaultDBConn() 28 + var (
  29 + conn = l.svcCtx.DefaultDBConn()
  30 + categoryList []*domain.ArticleCategory
  31 + )
30 queryOption := domain.NewQueryOptions().WithFindOnly() 32 queryOption := domain.NewQueryOptions().WithFindOnly()
31 _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption) 33 _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption)
32 if err != nil { 34 if err != nil {
33 return nil, xerr.NewErrMsgErr("获取标签列表失败", err) 35 return nil, xerr.NewErrMsgErr("获取标签列表失败", err)
34 } 36 }
  37 + _, categoryList, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions().MustWithKV("enable", 1))
  38 + if err != nil {
  39 + return nil, xerr.NewErrMsgErr("获取标签分类列表失败", err)
  40 + }
35 // 合并输出数据 41 // 合并输出数据
36 - var group []string  
37 tagMap := map[string][]types.ArticleTagItem{} 42 tagMap := map[string][]types.ArticleTagItem{}
38 for _, val := range tagList { 43 for _, val := range tagList {
39 if m, ok := tagMap[val.Category]; ok { 44 if m, ok := tagMap[val.Category]; ok {
@@ -46,7 +51,6 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR @@ -46,7 +51,6 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
46 }) 51 })
47 tagMap[val.Category] = m 52 tagMap[val.Category] = m
48 } else { 53 } else {
49 - group = append(group, val.Category)  
50 tagMap[val.Category] = []types.ArticleTagItem{ 54 tagMap[val.Category] = []types.ArticleTagItem{
51 { 55 {
52 Id: val.Id, 56 Id: val.Id,
@@ -61,10 +65,10 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR @@ -61,10 +65,10 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
61 resp = &types.MiniAllArticleTagResponse{ 65 resp = &types.MiniAllArticleTagResponse{
62 TagGroup: make([]types.ArticleTagGroup, 0), 66 TagGroup: make([]types.ArticleTagGroup, 0),
63 } 67 }
64 - for i := range group { 68 + for _, category := range categoryList {
65 resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{ 69 resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{
66 - Category: group[i],  
67 - Tags: tagMap[group[i]], 70 + Category: category.Name,
  71 + Tags: tagMap[category.Name],
68 }) 72 })
69 } 73 }
70 return resp, nil 74 return resp, nil