作者 tangxvhui

调整标签数据

@@ -49,6 +49,7 @@ type ( @@ -49,6 +49,7 @@ type (
49 Category string `json:"category"` // 标签分类 49 Category string `json:"category"` // 标签分类
50 Remark string `json:"remark,optional"` // 备注 50 Remark string `json:"remark,optional"` // 备注
51 Other string `json:"other,optional"` 51 Other string `json:"other,optional"`
  52 + SortBy int `json:"sortBy,optional"` //排序
52 } 53 }
53 54
54 TagCreateResponse { 55 TagCreateResponse {
@@ -66,6 +67,7 @@ type ( @@ -66,6 +67,7 @@ type (
66 Category string `json:"category"` // 标签分类 67 Category string `json:"category"` // 标签分类
67 Remark string `json:"remark,optional"` // 备注 68 Remark string `json:"remark,optional"` // 备注
68 Other string `json:"other,optional"` 69 Other string `json:"other,optional"`
  70 + SortBy int `json:"sortBy,optional"` // 排序
69 } 71 }
70 72
71 TagEditResponse { 73 TagEditResponse {
@@ -86,6 +88,7 @@ type ( @@ -86,6 +88,7 @@ type (
86 Category string `json:"category"` // 标签分类 88 Category string `json:"category"` // 标签分类
87 Remark string `json:"remark"` // 备注 89 Remark string `json:"remark"` // 备注
88 Other string `json:"other"` 90 Other string `json:"other"`
  91 + SortBy int `json:"sortBy,optional"` // 排序
89 } 92 }
90 ) 93 )
91 94
@@ -110,6 +113,7 @@ type ( @@ -110,6 +113,7 @@ type (
110 Category string `json:"category"` // 标签分类 113 Category string `json:"category"` // 标签分类
111 Remark string `json:"remark"` // 备注 114 Remark string `json:"remark"` // 备注
112 CreatedAt int64 `json:"createdAt"` 115 CreatedAt int64 `json:"createdAt"`
  116 + SortBy int `json:"sortBy,optional"` // 排序
113 } 117 }
114 ) 118 )
115 119
@@ -323,7 +323,7 @@ type ( @@ -323,7 +323,7 @@ type (
323 TagGroup []ArticleTagGroup `json:"tagGroup"` 323 TagGroup []ArticleTagGroup `json:"tagGroup"`
324 } 324 }
325 ArticleTagGroup { 325 ArticleTagGroup {
326 - Category string `json:"category"` 326 + Category string `json:"category"`
327 Tags []ArticleTagItem `json:"tags"` 327 Tags []ArticleTagItem `json:"tags"`
328 } 328 }
329 ArticleTagItem { 329 ArticleTagItem {
@@ -331,6 +331,7 @@ type ( @@ -331,6 +331,7 @@ type (
331 Category string `json:"category"` 331 Category string `json:"category"`
332 Name string `json:"name"` 332 Name string `json:"name"`
333 Image string `json:"image"` 333 Image string `json:"image"`
  334 + SortBy int `json:"sortBy"`
334 } 335 }
335 ) 336 )
336 337
@@ -42,6 +42,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR @@ -42,6 +42,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
42 Category: val.Category, 42 Category: val.Category,
43 Name: val.Name, 43 Name: val.Name,
44 Image: val.Image.Url, 44 Image: val.Image.Url,
  45 + SortBy: int(val.SortBy),
45 }) 46 })
46 tagMap[val.Category] = m 47 tagMap[val.Category] = m
47 } else { 48 } else {
@@ -52,6 +53,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR @@ -52,6 +53,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
52 Category: val.Category, 53 Category: val.Category,
53 Name: val.Name, 54 Name: val.Name,
54 Image: val.Image.Url, 55 Image: val.Image.Url,
  56 + SortBy: int(val.SortBy),
55 }, 57 },
56 } 58 }
57 } 59 }
@@ -56,6 +56,11 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag @@ -56,6 +56,11 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
56 Category: req.Category, 56 Category: req.Category,
57 Remark: req.Remark, 57 Remark: req.Remark,
58 Other: req.Other, 58 Other: req.Other,
  59 + SortBy: int64(req.SortBy),
  60 + }
  61 + err = newTag.SetCategory(req.Category)
  62 + if err != nil {
  63 + return nil, xerr.NewErrMsgErr("添加标签失败", err)
59 } 64 }
60 if len(req.Image) > 0 { 65 if len(req.Image) > 0 {
61 //获取图片的尺寸大小 66 //获取图片的尺寸大小
@@ -70,6 +70,11 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe @@ -70,6 +70,11 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
70 oldTag.Name = req.Name 70 oldTag.Name = req.Name
71 oldTag.Remark = req.Remark 71 oldTag.Remark = req.Remark
72 oldTag.Other = req.Other 72 oldTag.Other = req.Other
  73 + oldTag.SortBy = int64(req.SortBy)
  74 + err = oldTag.SetCategory(req.Category)
  75 + if err != nil {
  76 + return nil, xerr.NewErrMsgErr("添加标签失败", err)
  77 + }
73 oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag) 78 oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag)
74 if err != nil { 79 if err != nil {
75 return nil, xerr.NewErrMsgErr("添加标签失败", err) 80 return nil, xerr.NewErrMsgErr("添加标签失败", err)
@@ -41,6 +41,7 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon @@ -41,6 +41,7 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon
41 Category: oldTag.Category, 41 Category: oldTag.Category,
42 Remark: oldTag.Remark, 42 Remark: oldTag.Remark,
43 Other: oldTag.Other, 43 Other: oldTag.Other,
  44 + SortBy: int(oldTag.SortBy),
44 } 45 }
45 return 46 return
46 } 47 }
@@ -53,6 +53,7 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi @@ -53,6 +53,7 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
53 Category: tagList[i].Category, 53 Category: tagList[i].Category,
54 Remark: tagList[i].Remark, 54 Remark: tagList[i].Remark,
55 CreatedAt: tagList[i].CreatedAt, 55 CreatedAt: tagList[i].CreatedAt,
  56 + SortBy: int(tagList[i].SortBy),
56 } 57 }
57 } 58 }
58 return resp, nil 59 return resp, nil
@@ -323,6 +323,7 @@ type TagCreateRequest struct { @@ -323,6 +323,7 @@ type TagCreateRequest struct {
323 Category string `json:"category"` // 标签分类 323 Category string `json:"category"` // 标签分类
324 Remark string `json:"remark,optional"` // 备注 324 Remark string `json:"remark,optional"` // 备注
325 Other string `json:"other,optional"` 325 Other string `json:"other,optional"`
  326 + SortBy int `json:"sortBy,optional"` //排序
326 } 327 }
327 328
328 type TagCreateResponse struct { 329 type TagCreateResponse struct {
@@ -337,6 +338,7 @@ type TagEditRequest struct { @@ -337,6 +338,7 @@ type TagEditRequest struct {
337 Category string `json:"category"` // 标签分类 338 Category string `json:"category"` // 标签分类
338 Remark string `json:"remark,optional"` // 备注 339 Remark string `json:"remark,optional"` // 备注
339 Other string `json:"other,optional"` 340 Other string `json:"other,optional"`
  341 + SortBy int `json:"sortBy,optional"` // 排序
340 } 342 }
341 343
342 type TagEditResponse struct { 344 type TagEditResponse struct {
@@ -355,6 +357,7 @@ type TagGetResponse struct { @@ -355,6 +357,7 @@ type TagGetResponse struct {
355 Category string `json:"category"` // 标签分类 357 Category string `json:"category"` // 标签分类
356 Remark string `json:"remark"` // 备注 358 Remark string `json:"remark"` // 备注
357 Other string `json:"other"` 359 Other string `json:"other"`
  360 + SortBy int `json:"sortBy,optional"` // 排序
358 } 361 }
359 362
360 type TagListRequest struct { 363 type TagListRequest struct {
@@ -378,6 +381,7 @@ type TagItem struct { @@ -378,6 +381,7 @@ type TagItem struct {
378 Category string `json:"category"` // 标签分类 381 Category string `json:"category"` // 标签分类
379 Remark string `json:"remark"` // 备注 382 Remark string `json:"remark"` // 备注
380 CreatedAt int64 `json:"createdAt"` 383 CreatedAt int64 `json:"createdAt"`
  384 + SortBy int `json:"sortBy,optional"` // 排序
381 } 385 }
382 386
383 type TagDeleteRequest struct { 387 type TagDeleteRequest struct {
@@ -1075,6 +1079,7 @@ type ArticleTagItem struct { @@ -1075,6 +1079,7 @@ type ArticleTagItem struct {
1075 Category string `json:"category"` 1079 Category string `json:"category"`
1076 Name string `json:"name"` 1080 Name string `json:"name"`
1077 Image string `json:"image"` 1081 Image string `json:"image"`
  1082 + SortBy int `json:"sortBy"`
1078 } 1083 }
1079 1084
1080 type SystemArticleGetRequest struct { 1085 type SystemArticleGetRequest struct {
@@ -2,6 +2,7 @@ package domain @@ -2,6 +2,7 @@ package domain
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "fmt"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
7 ) 8 )
@@ -22,6 +23,7 @@ type ArticleTag struct { @@ -22,6 +23,7 @@ type ArticleTag struct {
22 SortBy int64 `json:"sortBy"` // 顺序 23 SortBy int64 `json:"sortBy"` // 顺序
23 Other string `json:"other"` // 24 Other string `json:"other"` //
24 } 25 }
  26 +
25 type ArticleTagRepository interface { 27 type ArticleTagRepository interface {
26 Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error) 28 Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
27 CreateInBatches(ctx context.Context, conn transaction.Conn, dm []*ArticleTag) error 29 CreateInBatches(ctx context.Context, conn transaction.Conn, dm []*ArticleTag) error
@@ -31,3 +33,14 @@ type ArticleTagRepository interface { @@ -31,3 +33,14 @@ type ArticleTagRepository interface {
31 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleTag, error) 33 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleTag, error)
32 Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*ArticleTag, error) 34 Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*ArticleTag, error)
33 } 35 }
  36 +
  37 +func (m *ArticleTag) SetCategory(str string) error {
  38 + var err error
  39 + switch str {
  40 + case "紧急重要", "机会风险":
  41 + m.Category = str
  42 + default:
  43 + err = fmt.Errorf("ArticleTag.Category error")
  44 + }
  45 + return err
  46 +}