正在显示
78 个修改的文件
包含
3905 行增加
和
71 行删除
@@ -10,3 +10,4 @@ import "core/article_type.api" | @@ -10,3 +10,4 @@ import "core/article_type.api" | ||
10 | import "core/article.api" | 10 | import "core/article.api" |
11 | import "core/role.api" | 11 | import "core/role.api" |
12 | import "core/department.api" | 12 | import "core/department.api" |
13 | +import "core/article_category.api" |
此 diff 太大无法显示。
@@ -19,12 +19,15 @@ service Core { | @@ -19,12 +19,15 @@ service Core { | ||
19 | @doc "小程序创建发布内容" | 19 | @doc "小程序创建发布内容" |
20 | @handler MiniCreateArticle | 20 | @handler MiniCreateArticle |
21 | post /article (MiniArticleCreateRequest) returns (MiniArticleCreateResponse) | 21 | post /article (MiniArticleCreateRequest) returns (MiniArticleCreateResponse) |
22 | + | ||
22 | @doc "小程序获取文章内容详情" | 23 | @doc "小程序获取文章内容详情" |
23 | @handler MiniGetArticle | 24 | @handler MiniGetArticle |
24 | get /article/:id (MiniArticleGetRequest) returns (MiniArticleGetResponse) | 25 | get /article/:id (MiniArticleGetRequest) returns (MiniArticleGetResponse) |
26 | + | ||
25 | @doc "小程序获取文章的点赞人员列表" | 27 | @doc "小程序获取文章的点赞人员列表" |
26 | @handler MiniUserLikeArticle | 28 | @handler MiniUserLikeArticle |
27 | post /article/user_like/list (MiniUserLikeArticleRequest) returns (MiniUserLikeArticleResponse) | 29 | post /article/user_like/list (MiniUserLikeArticleRequest) returns (MiniUserLikeArticleResponse) |
30 | + | ||
28 | @doc "小程序人员操作点赞文章/评论" | 31 | @doc "小程序人员操作点赞文章/评论" |
29 | @handler MiniSetUserLike | 32 | @handler MiniSetUserLike |
30 | post /article/user_like/set (MiniSetUserLikeRequset) returns (MiniSetUserLikeResponse) | 33 | post /article/user_like/set (MiniSetUserLikeRequset) returns (MiniSetUserLikeResponse) |
@@ -41,6 +44,14 @@ service Core { | @@ -41,6 +44,14 @@ service Core { | ||
41 | @handler MiniArticleSearchMe | 44 | @handler MiniArticleSearchMe |
42 | post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) | 45 | post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) |
43 | 46 | ||
47 | + @doc "小程序我的帖子设置可见范围" | ||
48 | + @handler MiniArticleSetView | ||
49 | + post /article/set_view (MiniArticleSetViewRequest) returns (MiniArticleSetViewResponse) | ||
50 | + | ||
51 | + @doc "小程序删除我的帖子" | ||
52 | + @handler MiniArticleDelete | ||
53 | + delete /article/delete (MiniArticleDeleteRequest) returns (MiniArticleDeleteResponse) | ||
54 | + | ||
44 | @doc "小程序创建文章进草稿箱" | 55 | @doc "小程序创建文章进草稿箱" |
45 | @handler MiniCreateArticleDraft | 56 | @handler MiniCreateArticleDraft |
46 | post /article_draft (MiniArticleDraftCreateRequest) returns (MiniArticleDraftCreateResponse) | 57 | post /article_draft (MiniArticleDraftCreateRequest) returns (MiniArticleDraftCreateResponse) |
@@ -121,4 +132,40 @@ service Core { | @@ -121,4 +132,40 @@ service Core { | ||
121 | @doc "管理后台文章恢复" | 132 | @doc "管理后台文章恢复" |
122 | @handler SystemArticleRestore | 133 | @handler SystemArticleRestore |
123 | post /article/restore (SystemArticleRestoreRequest) returns (SystemArticleRestoreResponse) | 134 | post /article/restore (SystemArticleRestoreRequest) returns (SystemArticleRestoreResponse) |
135 | + | ||
136 | + @doc "管理后台删除文章" | ||
137 | + @handler SystemDeleteArticle | ||
138 | + delete /article (SystemArticleDeleteRequest) returns (SystemArticleDeleteResponse) | ||
139 | + | ||
140 | + @doc "管理后台新增文章" | ||
141 | + @handler SystemCreateArticle | ||
142 | + post /article (SystemArticleCreateRequest) returns (SystemArticleCreateResponse) | ||
143 | + | ||
144 | + @doc "管理后台新增草稿" | ||
145 | + @handler SystemCreateArticleDraft | ||
146 | + post /article/draft (SystemArticleDraftCreateRequest) returns (SystemArticleDraftCreateResponse) | ||
147 | + | ||
148 | + @doc "管理后台编辑草稿" | ||
149 | + @handler SystemUpdateArticleDraft | ||
150 | + put /article/draft (SystemArticleDraftUpdateRequest) returns (SystemArticleDraftUpdateResponse) | ||
151 | + | ||
152 | + @doc "管理后台草稿列表" | ||
153 | + @handler SystemSearchArticleDraft | ||
154 | + post /article/draft/search (SystemArticleDraftSearchRequest) returns (SystemArticleDraftSearchResponse) | ||
155 | + | ||
156 | + @doc "管理后台删除草稿" | ||
157 | + @handler SystemDeleteArticleDraft | ||
158 | + delete /article/draft (SystemArticleDraftDeleteRequest) returns (SystemArticleDraftDeleteResponse) | ||
159 | + | ||
160 | + @doc "管理后台获取草稿" | ||
161 | + @handler SystemGetArticleDraft | ||
162 | + get /article/draft/:id (SystemArticleDraftGetRequest) returns (SystemArticleDraftGetResponse) | ||
163 | + | ||
164 | + @doc "管理后台已删除列表" | ||
165 | + @handler SystemArticleSearchDeleted | ||
166 | + post /article/deleted/list (SystemArticleSearchDeletedRequest) returns (SystemArticleSearchDeletedResponse) | ||
167 | + | ||
168 | + @doc "管理后台文章删除恢复" | ||
169 | + @handler SystemRestoreArticleDeleted | ||
170 | + put /article/deleted/restore (SystemArticleDeletedRestoreRequest) returns (SystemArticleDeletedRestoreResponse) | ||
124 | } | 171 | } |
1 | +@server( | ||
2 | + prefix: v1/system | ||
3 | + group: tags | ||
4 | + middleware: LoginStatusCheck,LogRequest | ||
5 | + jwt: SystemAuth | ||
6 | +) | ||
7 | +service Core { | ||
8 | + @doc "标签分类详情" | ||
9 | + @handler articleCategoryGet | ||
10 | + get /article_category/:id (ArticleCategoryGetRequest) returns (ArticleCategoryGetResponse) | ||
11 | + @doc "标签分类保存" | ||
12 | + @handler articleCategorySave | ||
13 | + post /article_category (ArticleCategorySaveRequest) returns (ArticleCategorySaveResponse) | ||
14 | + @doc "标签分类删除" | ||
15 | + @handler articleCategoryDelete | ||
16 | + delete /article_category/:id (ArticleCategoryDeleteRequest) returns (ArticleCategoryDeleteResponse) | ||
17 | + @doc "标签分类更新" | ||
18 | + @handler articleCategoryUpdate | ||
19 | + put /article_category/:id (ArticleCategoryUpdateRequest) returns (ArticleCategoryUpdateResponse) | ||
20 | + @doc "标签分类搜索" | ||
21 | + @handler articleCategorySearch | ||
22 | + post /article_category/search (ArticleCategorySearchRequest) returns (ArticleCategorySearchResponse) | ||
23 | + @doc "标签分类下拉列表" | ||
24 | + @handler articleCategoryOptions | ||
25 | + get /article_category/options (CategoryOptionsRequest) returns (CategoryOptionsResponse) | ||
26 | +} | ||
27 | + | ||
28 | +@server( | ||
29 | + prefix: v1/system | ||
30 | + group: tags | ||
31 | +) | ||
32 | +service Core { | ||
33 | + @doc "标签分类初始化" | ||
34 | + @handler articleCategoryInit | ||
35 | + get /article_category/init | ||
36 | +} | ||
37 | + | ||
38 | +type ( | ||
39 | + ArticleCategoryGetRequest { | ||
40 | + Id int64 `path:"id"` | ||
41 | + } | ||
42 | + ArticleCategoryGetResponse struct{ | ||
43 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
44 | + } | ||
45 | + | ||
46 | + ArticleCategorySaveRequest struct{ | ||
47 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
48 | + } | ||
49 | + ArticleCategorySaveResponse struct{} | ||
50 | + | ||
51 | + ArticleCategoryDeleteRequest struct{ | ||
52 | + Id int64 `path:"id"` | ||
53 | + } | ||
54 | + ArticleCategoryDeleteResponse struct{} | ||
55 | + | ||
56 | + ArticleCategoryUpdateRequest struct{ | ||
57 | + Id int64 `path:"id"` | ||
58 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
59 | + } | ||
60 | + ArticleCategoryUpdateResponse struct{} | ||
61 | + | ||
62 | + ArticleCategorySearchRequest struct{ | ||
63 | + Page int `json:"page"` | ||
64 | + Size int `json:"size"` | ||
65 | + } | ||
66 | + ArticleCategorySearchResponse{ | ||
67 | + List []ArticleCategoryItem `json:"list"` | ||
68 | + Total int64 `json:"total"` | ||
69 | + } | ||
70 | + ArticleCategoryItem struct{ | ||
71 | + Id int64 `json:"id,optional"` // 唯一标识 | ||
72 | + CompanyId int64 `json:"companyId,optional,omitempty"` | ||
73 | + Name string `json:"name"` | ||
74 | + SortBy int `json:"sortBy,optional,omitempty"` // 排序 | ||
75 | + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 | ||
76 | + Other string `json:"other,optional,omitempty"` // 其他备注说明 | ||
77 | + } | ||
78 | +) | ||
79 | + | ||
80 | +//标签下拉列表 | ||
81 | +type ( | ||
82 | + CategoryOptionsRequest { | ||
83 | + Enable int `form:"enable,optional"` // 启用状态 1:启用 | ||
84 | + } | ||
85 | + CategoryOptionsResponse { | ||
86 | + Options []CategoryOptions `json:"options"` | ||
87 | + } | ||
88 | + CategoryOptions { | ||
89 | + Value int64 `json:"value"` // 分类ID | ||
90 | + Label string `json:"label"` // 分组名称 | ||
91 | + Enable int `json:"enable,optional,omitempty"` // 启用状态 1:启用 | ||
92 | + //Options []CategoryOptionValue `json:"options,omitempty"` | ||
93 | + } | ||
94 | + CategoryOptionValue { | ||
95 | + Label string `json:"label"` // 名称 | ||
96 | + Value int64 `json:"value"` // 分类ID | ||
97 | + } | ||
98 | +) |
@@ -46,10 +46,11 @@ type ( | @@ -46,10 +46,11 @@ type ( | ||
46 | CompanyId int64 `json:",optional"` | 46 | CompanyId int64 `json:",optional"` |
47 | Image string `json:"image"` | 47 | Image string `json:"image"` |
48 | Name string `json:"name"` // 标签名称 | 48 | Name string `json:"name"` // 标签名称 |
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 | SortBy int `json:"sortBy,optional"` //排序 |
53 | + CategoryId int64 `json:"categoryId"` // 标签Id | ||
53 | } | 54 | } |
54 | 55 | ||
55 | TagCreateResponse { | 56 | TagCreateResponse { |
@@ -64,7 +65,8 @@ type ( | @@ -64,7 +65,8 @@ type ( | ||
64 | CompanyId int64 `json:",optional"` | 65 | CompanyId int64 `json:",optional"` |
65 | Image string `json:"image"` | 66 | Image string `json:"image"` |
66 | Name string `json:"name"` // 标签名称 | 67 | Name string `json:"name"` // 标签名称 |
67 | - Category string `json:"category"` // 标签分类 | 68 | + //Category string `json:"category"` // 标签分类 |
69 | + CategoryId int64 `json:"categoryId"` // 标签Id | ||
68 | Remark string `json:"remark,optional"` // 备注 | 70 | Remark string `json:"remark,optional"` // 备注 |
69 | Other string `json:"other,optional"` | 71 | Other string `json:"other,optional"` |
70 | SortBy int `json:"sortBy,optional"` // 排序 | 72 | SortBy int `json:"sortBy,optional"` // 排序 |
@@ -86,6 +88,7 @@ type ( | @@ -86,6 +88,7 @@ type ( | ||
86 | Image string `json:"image"` | 88 | Image string `json:"image"` |
87 | Name string `json:"name"` // 标签名称 | 89 | Name string `json:"name"` // 标签名称 |
88 | Category string `json:"category"` // 标签分类 | 90 | Category string `json:"category"` // 标签分类 |
91 | + CategoryId int64 `json:"categoryId"` // 标签分类Id | ||
89 | Remark string `json:"remark"` // 备注 | 92 | Remark string `json:"remark"` // 备注 |
90 | Other string `json:"other"` | 93 | Other string `json:"other"` |
91 | SortBy int `json:"sortBy,optional"` // 排序 | 94 | SortBy int `json:"sortBy,optional"` // 排序 |
@@ -99,7 +102,7 @@ type ( | @@ -99,7 +102,7 @@ type ( | ||
99 | Size int `json:"size"` | 102 | Size int `json:"size"` |
100 | CompanyId int64 `json:",optional"` | 103 | CompanyId int64 `json:",optional"` |
101 | TagName string `json:"tagName,optional"` | 104 | TagName string `json:"tagName,optional"` |
102 | - Category string `json:"category,optional"` | 105 | + CategoryId int64 `json:"categoryId,optional"` |
103 | Remark string `json:"remark,optional"` | 106 | Remark string `json:"remark,optional"` |
104 | } | 107 | } |
105 | TagListResponse { | 108 | TagListResponse { |
@@ -111,9 +114,11 @@ type ( | @@ -111,9 +114,11 @@ type ( | ||
111 | Image string `json:"image"` | 114 | Image string `json:"image"` |
112 | Name string `json:"name"` // 标签名称 | 115 | Name string `json:"name"` // 标签名称 |
113 | Category string `json:"category"` // 标签分类 | 116 | Category string `json:"category"` // 标签分类 |
117 | + CategoryId int64 `json:"categoryId"` // 标签分类Id | ||
114 | Remark string `json:"remark"` // 备注 | 118 | Remark string `json:"remark"` // 备注 |
115 | CreatedAt int64 `json:"createdAt"` | 119 | CreatedAt int64 `json:"createdAt"` |
116 | SortBy int `json:"sortBy,optional"` // 排序 | 120 | SortBy int `json:"sortBy,optional"` // 排序 |
121 | + Removeable bool `json:"removeable,optional"` // 可删除 | ||
117 | } | 122 | } |
118 | ) | 123 | ) |
119 | 124 | ||
@@ -137,7 +142,8 @@ type ( | @@ -137,7 +142,8 @@ type ( | ||
137 | Options []TagOptions `json:"options"` | 142 | Options []TagOptions `json:"options"` |
138 | } | 143 | } |
139 | TagOptions { | 144 | TagOptions { |
140 | - Label string `json:"label"` // 分组名称 | 145 | + Value int64 `json:"value"` // 分类ID |
146 | + Label string `json:"label"` // 分类名称 | ||
141 | Options []TagOptionValue `json:"options"` | 147 | Options []TagOptionValue `json:"options"` |
142 | } | 148 | } |
143 | TagOptionValue { | 149 | TagOptionValue { |
@@ -25,6 +25,11 @@ type ArticleAuthor { | @@ -25,6 +25,11 @@ type ArticleAuthor { | ||
25 | Company string `json:"company"` // 公司 | 25 | Company string `json:"company"` // 公司 |
26 | } | 26 | } |
27 | 27 | ||
28 | +type Operator { | ||
29 | + Id int64 `json:"id,string"`// 人员id | ||
30 | + Name string `json:"name"` // 人员的名字 | ||
31 | +} | ||
32 | + | ||
28 | //小程序端创建发布文章 | 33 | //小程序端创建发布文章 |
29 | type ( | 34 | type ( |
30 | MiniArticleCreateRequest { | 35 | MiniArticleCreateRequest { |
@@ -102,6 +107,10 @@ type ( | @@ -102,6 +107,10 @@ type ( | ||
102 | CountComment int `json:"countComment"` //评论数量 | 107 | CountComment int `json:"countComment"` //评论数量 |
103 | CountRead int `json:"countRead"` //浏览数量 | 108 | CountRead int `json:"countRead"` //浏览数量 |
104 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 109 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
110 | + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
111 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
112 | + IsDel int `json:"isDel"` //是否删除 1-删除 0-否 | ||
113 | + DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除 | ||
105 | } | 114 | } |
106 | 115 | ||
107 | SystemArticleSearchMeRequest { | 116 | SystemArticleSearchMeRequest { |
@@ -117,6 +126,30 @@ type ( | @@ -117,6 +126,30 @@ type ( | ||
117 | } | 126 | } |
118 | ) | 127 | ) |
119 | 128 | ||
129 | +//小程序我的帖子设置可见范围 | ||
130 | +type ( | ||
131 | + MiniArticleSetViewRequest { | ||
132 | + Id int64 `json:"id"` //id | ||
133 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
134 | + } | ||
135 | + MiniArticleSetViewResponse { | ||
136 | + Id int64 `json:"id"` //id | ||
137 | + Title string `json:"title"` //标题 | ||
138 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
139 | + } | ||
140 | +) | ||
141 | + | ||
142 | +//小程序删除我的帖子 | ||
143 | +type ( | ||
144 | + MiniArticleDeleteRequest { | ||
145 | + Id int64 `json:"id"` //id | ||
146 | + } | ||
147 | + MiniArticleDeleteResponse { | ||
148 | + Id int64 `json:"id"` //id | ||
149 | + Title string `json:"title"` //标题 | ||
150 | + } | ||
151 | +) | ||
152 | + | ||
120 | //小程序端获取文章有哪些人进行了点赞 | 153 | //小程序端获取文章有哪些人进行了点赞 |
121 | type ( | 154 | type ( |
122 | MiniUserLikeArticleRequest { | 155 | MiniUserLikeArticleRequest { |
@@ -431,11 +464,14 @@ type ( | @@ -431,11 +464,14 @@ type ( | ||
431 | Author string `json:"author"` //发布人 | 464 | Author string `json:"author"` //发布人 |
432 | Images []string `json:"images"` //图片 | 465 | Images []string `json:"images"` //图片 |
433 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 466 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
467 | + UpdatedAt int64 `json:"updatedAt"` //文章的编辑日期 | ||
434 | CountLove int `json:"countLove"` //点赞数量 | 468 | CountLove int `json:"countLove"` //点赞数量 |
435 | CountComment int `json:"countComment"` //评论数量 | 469 | CountComment int `json:"countComment"` //评论数量 |
436 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 470 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
437 | Tags []string `json:"tags"` //标签 | 471 | Tags []string `json:"tags"` //标签 |
438 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 472 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
473 | + Operator Operator `json:"operator"` //运营操作人 | ||
474 | + Source int `json:"source"` //来源[1用户发布、2运营发布] | ||
439 | } | 475 | } |
440 | ) | 476 | ) |
441 | // 管理后台编辑文章 | 477 | // 管理后台编辑文章 |
@@ -469,6 +505,46 @@ type ( | @@ -469,6 +505,46 @@ type ( | ||
469 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 505 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
470 | } | 506 | } |
471 | ) | 507 | ) |
508 | +// 管理后台新增文章 | ||
509 | +type ( | ||
510 | + SystemArticleCreateRequest { | ||
511 | + Title string `json:"title"` //标题 | ||
512 | + Content string `json:"content"` //文章的文本内容 | ||
513 | + AuthorId int64 `json:"authorId"` //发布人id | ||
514 | + Images []string `json:"images,optional"` //图片 | ||
515 | + Videos []Video `json:"video,optional"` // 视频 | ||
516 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
517 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
518 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
519 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
520 | + ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID | ||
521 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
522 | + } | ||
523 | + SystemArticleCreateResponse { | ||
524 | + Id int64 `json:"id"` //id | ||
525 | + Title string `json:"title"` //标题 | ||
526 | + Content string `json:"content"` //文章的文本内容 | ||
527 | + AuthorId int64 `json:"authorId,optional"` //发布人id | ||
528 | + Images []string `json:"images,optional"` //图片 | ||
529 | + Videos []Video `json:"video,optional"` // 视频 | ||
530 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
531 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
532 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
533 | + MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | ||
534 | + } | ||
535 | +) | ||
536 | +//管理后台删除文章 | ||
537 | +type ( | ||
538 | + SystemArticleDeleteRequest { | ||
539 | + Id int64 `json:"id"` //id | ||
540 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
541 | + } | ||
542 | + SystemArticleDeleteResponse { | ||
543 | + Id int64 `json:"id"` //id | ||
544 | + Title string `json:"title"` //标题 | ||
545 | + AuthorId int64 `json:"authorId,optional"` //发布人id | ||
546 | + } | ||
547 | +) | ||
472 | // 管理后台编辑历史列表 | 548 | // 管理后台编辑历史列表 |
473 | type ( | 549 | type ( |
474 | //历史 | 550 | //历史 |
@@ -579,3 +655,173 @@ type ( | @@ -579,3 +655,173 @@ type ( | ||
579 | MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] | 655 | MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] |
580 | } | 656 | } |
581 | ) | 657 | ) |
658 | + | ||
659 | +//后台新增文章草稿 | ||
660 | +type ( | ||
661 | + SystemArticleDraftCreateRequest { | ||
662 | + Title string `json:"title"` //标题 | ||
663 | + Content string `json:"content"` //文章的文本内容 | ||
664 | + AuthorId int64 `json:"authorId"` //发布人id | ||
665 | + Images []string `json:"images,optional"` //图片 | ||
666 | + Videos []Video `json:"video,optional"` // 视频 | ||
667 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
668 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
669 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
670 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
671 | + Tags []int64 `json:"tags"` // 标签 | ||
672 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
673 | + } | ||
674 | + SystemArticleDraftCreateResponse { | ||
675 | + Id int64 `json:"id"` //ID | ||
676 | + Title string `json:"title"` //标题 | ||
677 | + Content string `json:"content"` //文章的文本内容 | ||
678 | + AuthorId int64 `json:"authorId"` //发布人id | ||
679 | + Images []string `json:"images,optional"` //图片 | ||
680 | + Videos []Video `json:"video,optional"` // 视频 | ||
681 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
682 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
683 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
684 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
685 | + Tags []int64 `json:"tags"` // 标签 | ||
686 | + } | ||
687 | +) | ||
688 | + | ||
689 | +//后台编辑文章草稿 | ||
690 | +type ( | ||
691 | + SystemArticleDraftUpdateRequest { | ||
692 | + Id int64 `json:"id"` // ID | ||
693 | + Title string `json:"title"` //标题 | ||
694 | + Content string `json:"content"` //文章的文本内容 | ||
695 | + AuthorId int64 `json:"authorId"` //发布人id | ||
696 | + Images []string `json:"images,optional"` //图片 | ||
697 | + Videos []Video `json:"video,optional"` // 视频 | ||
698 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
699 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
700 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
701 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
702 | + Tags []int64 `json:"tags"` // 标签 | ||
703 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
704 | + } | ||
705 | + SystemArticleDraftUpdateResponse { | ||
706 | + Id int64 `json:"id"` //ID | ||
707 | + Title string `json:"title"` //标题 | ||
708 | + Content string `json:"content"` //文章的文本内容 | ||
709 | + AuthorId int64 `json:"authorId"` //发布人id | ||
710 | + Images []string `json:"images,optional"` //图片 | ||
711 | + Videos []Video `json:"video,optional"` // 视频 | ||
712 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
713 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
714 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
715 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
716 | + Tags []int64 `json:"tags"` // 标签 | ||
717 | + } | ||
718 | +) | ||
719 | + | ||
720 | +//管理后台文章草稿列表 | ||
721 | +type ( | ||
722 | + SystemArticleDraftSearchRequest { | ||
723 | + Page int `json:"page"` //页码 | ||
724 | + Size int `json:"size"` //每页行数 | ||
725 | + CompanyId int64 `json:"companyId,optional"` //公司ID(前端不传) | ||
726 | + Title string `json:"title,optional"` //标题 | ||
727 | + Operator string `json:"operator,optional"` //编辑人 | ||
728 | + BeginTime int64 `json:"beginTime,optional"`//开始时间 | ||
729 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
730 | + } | ||
731 | + SystemArticleDraftSearchResponse { | ||
732 | + Total int `json:"total"` | ||
733 | + List []SystemArticleDraftSearch `json:"list"` | ||
734 | + } | ||
735 | + SystemArticleDraftSearch { | ||
736 | + Id int64 `json:"id"` //ID | ||
737 | + Title string `json:"title"` //标题 | ||
738 | + Images []string `json:"images"` //图片 | ||
739 | + Operator string `json:"operator"` //操作人 | ||
740 | + AuthorId int64 `json:"authorId"` //发布人id | ||
741 | + Author string `json:"author"` //发布人 | ||
742 | + UpdatedAt int64 `json:"updatedAt"` //编辑时间 | ||
743 | + } | ||
744 | +) | ||
745 | + | ||
746 | +//管理后台删除草稿 | ||
747 | +type ( | ||
748 | + SystemArticleDraftDeleteRequest { | ||
749 | + Id int64 `json:"id"` //ID | ||
750 | + } | ||
751 | + SystemArticleDraftDeleteResponse { | ||
752 | + Id int64 `json:"id"` //ID | ||
753 | + Title string `json:"title"` //标题 | ||
754 | + Content string `json:"content"` //文章的文本内容 | ||
755 | + AuthorId int64 `json:"authorId"` //发布人id | ||
756 | + Images []string `json:"images,optional"` //图片 | ||
757 | + Videos []Video `json:"video,optional"` // 视频 | ||
758 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
759 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
760 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
761 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
762 | + Tags []int64 `json:"tags"` // 标签 | ||
763 | + } | ||
764 | +) | ||
765 | + | ||
766 | +//管理后台获取草稿 | ||
767 | +type ( | ||
768 | + SystemArticleDraftGetRequest { | ||
769 | + Id int64 `path:"id"` //id | ||
770 | + CompanyId int64 `path:",optional"` //公司ID(前端不传) | ||
771 | + } | ||
772 | + SystemArticleDraftGetResponse { | ||
773 | + Id int64 `json:"id"` //ID | ||
774 | + Title string `json:"title"` //标题 | ||
775 | + Content string `json:"content"` //文章的文本内容 | ||
776 | + AuthorId int64 `json:"authorId"` //发布人id | ||
777 | + Images []string `json:"images,optional"` //图片 | ||
778 | + Videos []Video `json:"video,optional"` // 视频 | ||
779 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
780 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
781 | + WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | ||
782 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
783 | + WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 | ||
784 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
785 | + Tags []int64 `json:"tags"` // 标签 | ||
786 | + } | ||
787 | +) | ||
788 | + | ||
789 | +//管理后台已删除列表 | ||
790 | +type ( | ||
791 | + SystemArticleSearchDeletedRequest { | ||
792 | + Page int `json:"page"` //页码 | ||
793 | + Size int `json:"size"` //每页行数 | ||
794 | + Title string `json:"title,optional"` //标题 | ||
795 | + Author int64 `json:"author,optional"` //发布人 | ||
796 | + DeletedType int `json:"deletedType,optional"`//类型 1-运营删除 2-用户删除 | ||
797 | + BeginTime int64 `json:"beginTime,optional"`//开始时间 | ||
798 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
799 | + } | ||
800 | + SystemArticleSearchDeletedResponse { | ||
801 | + Total int `json:"total"` | ||
802 | + List []SystemArticleSearchDeletedItem `json:"list"` | ||
803 | + } | ||
804 | + SystemArticleSearchDeletedItem { | ||
805 | + Id int64 `json:"id"` //ID | ||
806 | + Title string `json:"title"` //标题 | ||
807 | + Images []string `json:"images"` //图片 | ||
808 | + AuthorId int64 `json:"authorId"` //发布人id | ||
809 | + Author string `json:"author"` //发布人 | ||
810 | + Source int `json:"source"` //来源 1-用户发布 2-运营发布 | ||
811 | + DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除 | ||
812 | + DeletedAt int64 `json:"deletedAt"` //删除时间 | ||
813 | + } | ||
814 | +) | ||
815 | + | ||
816 | +//管理后台已删除文章恢复 | ||
817 | +type ( | ||
818 | + SystemArticleDeletedRestoreRequest { | ||
819 | + Id int64 `json:"id"` //ID | ||
820 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
821 | + } | ||
822 | + SystemArticleDeletedRestoreResponse { | ||
823 | + Id int64 `json:"id"` //ID | ||
824 | + Title string `json:"title"` //标题 | ||
825 | + AuthorId int64 `json:"authorId"` //发布人id | ||
826 | + } | ||
827 | +) |
@@ -41,6 +41,10 @@ service Core { | @@ -41,6 +41,10 @@ service Core { | ||
41 | jwt : SystemAuth | 41 | jwt : SystemAuth |
42 | ) | 42 | ) |
43 | service Core { | 43 | service Core { |
44 | + @doc "公司可见开关" | ||
45 | + @handler systemCompanyVisibleSwitch | ||
46 | + post /system/company/visible_switch(CompanyVisibleSwitchRequest) returns (CompanyVisibleSwitchResponse) | ||
47 | + | ||
44 | @doc "公司搜索" | 48 | @doc "公司搜索" |
45 | @handler systemCompanySearch | 49 | @handler systemCompanySearch |
46 | post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse) | 50 | post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse) |
@@ -70,6 +74,13 @@ type ( | @@ -70,6 +74,13 @@ type ( | ||
70 | Logo string `json:"logo,omitempty"` // 公司LOGO | 74 | Logo string `json:"logo,omitempty"` // 公司LOGO |
71 | JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) | 75 | JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) |
72 | } | 76 | } |
77 | + | ||
78 | + CompanyVisibleSwitchRequest{ | ||
79 | + Visible bool `json:"visible"` // 可见性 true:可被搜索 false:不可被搜索 | ||
80 | + } | ||
81 | + CompanyVisibleSwitchResponse{ | ||
82 | + | ||
83 | + } | ||
73 | ) | 84 | ) |
74 | 85 | ||
75 | // 公司职位搜索 | 86 | // 公司职位搜索 |
@@ -59,6 +59,7 @@ type ( | @@ -59,6 +59,7 @@ type ( | ||
59 | DepartmentListRequest { | 59 | DepartmentListRequest { |
60 | Page int `json:"page"` | 60 | Page int `json:"page"` |
61 | Size int `json:"size"` | 61 | Size int `json:"size"` |
62 | + IncludeRootCompany bool `json:"includeRootCompany,optional"` // 包含公司(把公司当作部门作为顶级节点 部门ID:0) | ||
62 | } | 63 | } |
63 | 64 | ||
64 | DepartmentListResponse { | 65 | DepartmentListResponse { |
@@ -209,6 +209,7 @@ type( | @@ -209,6 +209,7 @@ type( | ||
209 | ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户) | 209 | ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户) |
210 | RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户 | 210 | RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户 |
211 | Keywords string `json:"keywords,optional"` // 按关键字搜索(名称) | 211 | Keywords string `json:"keywords,optional"` // 按关键字搜索(名称) |
212 | + DepartmentId *int64 `json:"departmentId,optional"` // 按部门过滤 | ||
212 | } | 213 | } |
213 | MiniUserNewsRequest{ | 214 | MiniUserNewsRequest{ |
214 | AuthorId int64 `json:"authorId,optional"` // 特定作者ID | 215 | AuthorId int64 `json:"authorId,optional"` // 特定作者ID |
@@ -273,7 +274,7 @@ type( | @@ -273,7 +274,7 @@ type( | ||
273 | Position string `json:"position"`// 职位 | 274 | Position string `json:"position"`// 职位 |
274 | } | 275 | } |
275 | Department struct { | 276 | Department struct { |
276 | - Id int64 `json:"id,omitempty"` // 部门ID | 277 | + Id int64 `json:"id"` // 部门ID |
277 | CompanyId int64 `json:"companyId"` // 公司ID | 278 | CompanyId int64 `json:"companyId"` // 公司ID |
278 | ParentId int64 `json:"parentId"` // 父级ID | 279 | ParentId int64 `json:"parentId"` // 父级ID |
279 | Name string `json:"name"` // 部门名称 | 280 | Name string `json:"name"` // 部门名称 |
@@ -417,6 +418,7 @@ type( | @@ -417,6 +418,7 @@ type( | ||
417 | CompanyId int64 `json:"companyId"` | 418 | CompanyId int64 `json:"companyId"` |
418 | CompanyName string `json:"companyName"` | 419 | CompanyName string `json:"companyName"` |
419 | Code string `json:"code"` | 420 | Code string `json:"code"` |
421 | + CompanyVisible bool `json:"companyVisible"` | ||
420 | } | 422 | } |
421 | UserStatisticsRequest{ | 423 | UserStatisticsRequest{ |
422 | UserId int64 `json:"userId,optional"` | 424 | UserId int64 `json:"userId,optional"` |
@@ -2,7 +2,7 @@ Name: discuss | @@ -2,7 +2,7 @@ Name: discuss | ||
2 | Host: 0.0.0.0 | 2 | Host: 0.0.0.0 |
3 | Port: 8081 | 3 | Port: 8081 |
4 | Verbose: false | 4 | Verbose: false |
5 | -Migrate: false | 5 | +Migrate: true |
6 | Timeout: 30000 | 6 | Timeout: 30000 |
7 | # CertFile: ./key/fjmaimaimai.com_bundle.crt | 7 | # CertFile: ./key/fjmaimaimai.com_bundle.crt |
8 | # KeyFile: ./key/fjmaimaimai.com.key | 8 | # KeyFile: ./key/fjmaimaimai.com.key |
@@ -40,3 +40,4 @@ ApiAuth: | @@ -40,3 +40,4 @@ ApiAuth: | ||
40 | Wechat: | 40 | Wechat: |
41 | AppID: wxae5b305849343ec8 | 41 | AppID: wxae5b305849343ec8 |
42 | AppSecret: f584adb68f7d784425b60e1ebb2ffd4b | 42 | AppSecret: f584adb68f7d784425b60e1ebb2ffd4b |
43 | + QrcodeEnv: trial |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func MiniArticleDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.MiniArticleDeleteRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewMiniArticleDeleteLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.MiniArticleDelete(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func MiniArticleSetViewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.MiniArticleSetViewRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewMiniArticleSetViewLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.MiniArticleSetView(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func SystemArticleSearchDeletedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleSearchDeletedRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemArticleSearchDeletedLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemArticleSearchDeleted(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func SystemCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleDraftCreateRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemCreateArticleDraftLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemCreateArticleDraft(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func SystemCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleCreateRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemCreateArticleLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemCreateArticle(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func SystemDeleteArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleDraftDeleteRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemDeleteArticleDraftLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemDeleteArticleDraft(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func SystemDeleteArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleDeleteRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemDeleteArticleLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemDeleteArticle(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func SystemGetArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleDraftGetRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemGetArticleDraftLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemGetArticleDraft(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func SystemRestoreArticleDeletedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleDeletedRestoreRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemRestoreArticleDeletedLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemRestoreArticleDeleted(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
6 | + "net/http" | ||
7 | + | ||
8 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
12 | +) | ||
13 | + | ||
14 | +func SystemSearchArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.SystemArticleDraftSearchRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
19 | + return | ||
20 | + } | ||
21 | + userToken := contextdata.GetUserTokenFromCtx(r.Context()) | ||
22 | + req.CompanyId = userToken.CompanyId | ||
23 | + l := article.NewSystemSearchArticleDraftLogic(r.Context(), svcCtx) | ||
24 | + resp, err := l.SystemSearchArticleDraft(&req) | ||
25 | + result.HttpResult(r, w, resp, err) | ||
26 | + } | ||
27 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func SystemUpdateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleDraftUpdateRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemUpdateArticleDraftLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemUpdateArticleDraft(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package company | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/company" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | +) | ||
11 | + | ||
12 | +func SystemCompanyVisibleSwitchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
14 | + var req types.CompanyVisibleSwitchRequest | ||
15 | + if err := httpx.Parse(r, &req); err != nil { | ||
16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
17 | + return | ||
18 | + } | ||
19 | + | ||
20 | + l := company.NewSystemCompanyVisibleSwitchLogic(r.Context(), svcCtx) | ||
21 | + resp, err := l.SystemCompanyVisibleSwitch(&req) | ||
22 | + if err != nil { | ||
23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
24 | + } else { | ||
25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
26 | + } | ||
27 | + } | ||
28 | +} |
@@ -445,6 +445,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -445,6 +445,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
445 | []rest.Route{ | 445 | []rest.Route{ |
446 | { | 446 | { |
447 | Method: http.MethodPost, | 447 | Method: http.MethodPost, |
448 | + Path: "/system/company/visible_switch", | ||
449 | + Handler: company.SystemCompanyVisibleSwitchHandler(serverCtx), | ||
450 | + }, | ||
451 | + { | ||
452 | + Method: http.MethodPost, | ||
448 | Path: "/system/company/search", | 453 | Path: "/system/company/search", |
449 | Handler: company.SystemCompanySearchHandler(serverCtx), | 454 | Handler: company.SystemCompanySearchHandler(serverCtx), |
450 | }, | 455 | }, |
@@ -500,6 +505,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -500,6 +505,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
500 | }, | 505 | }, |
501 | { | 506 | { |
502 | Method: http.MethodPost, | 507 | Method: http.MethodPost, |
508 | + Path: "/article/set_view", | ||
509 | + Handler: article.MiniArticleSetViewHandler(serverCtx), | ||
510 | + }, | ||
511 | + { | ||
512 | + Method: http.MethodDelete, | ||
513 | + Path: "/article/delete", | ||
514 | + Handler: article.MiniArticleDeleteHandler(serverCtx), | ||
515 | + }, | ||
516 | + { | ||
517 | + Method: http.MethodPost, | ||
503 | Path: "/article_draft", | 518 | Path: "/article_draft", |
504 | Handler: article.MiniCreateArticleDraftHandler(serverCtx), | 519 | Handler: article.MiniCreateArticleDraftHandler(serverCtx), |
505 | }, | 520 | }, |
@@ -598,6 +613,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -598,6 +613,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
598 | Path: "/article/restore", | 613 | Path: "/article/restore", |
599 | Handler: article.SystemArticleRestoreHandler(serverCtx), | 614 | Handler: article.SystemArticleRestoreHandler(serverCtx), |
600 | }, | 615 | }, |
616 | + { | ||
617 | + Method: http.MethodDelete, | ||
618 | + Path: "/article", | ||
619 | + Handler: article.SystemDeleteArticleHandler(serverCtx), | ||
620 | + }, | ||
621 | + { | ||
622 | + Method: http.MethodPost, | ||
623 | + Path: "/article", | ||
624 | + Handler: article.SystemCreateArticleHandler(serverCtx), | ||
625 | + }, | ||
626 | + { | ||
627 | + Method: http.MethodPost, | ||
628 | + Path: "/article/draft", | ||
629 | + Handler: article.SystemCreateArticleDraftHandler(serverCtx), | ||
630 | + }, | ||
631 | + { | ||
632 | + Method: http.MethodPut, | ||
633 | + Path: "/article/draft", | ||
634 | + Handler: article.SystemUpdateArticleDraftHandler(serverCtx), | ||
635 | + }, | ||
636 | + { | ||
637 | + Method: http.MethodPost, | ||
638 | + Path: "/article/draft/search", | ||
639 | + Handler: article.SystemSearchArticleDraftHandler(serverCtx), | ||
640 | + }, | ||
641 | + { | ||
642 | + Method: http.MethodDelete, | ||
643 | + Path: "/article/draft", | ||
644 | + Handler: article.SystemDeleteArticleDraftHandler(serverCtx), | ||
645 | + }, | ||
646 | + { | ||
647 | + Method: http.MethodGet, | ||
648 | + Path: "/article/draft/:id", | ||
649 | + Handler: article.SystemGetArticleDraftHandler(serverCtx), | ||
650 | + }, | ||
651 | + { | ||
652 | + Method: http.MethodPost, | ||
653 | + Path: "/article/deleted/list", | ||
654 | + Handler: article.SystemArticleSearchDeletedHandler(serverCtx), | ||
655 | + }, | ||
656 | + { | ||
657 | + Method: http.MethodPut, | ||
658 | + Path: "/article/deleted/restore", | ||
659 | + Handler: article.SystemRestoreArticleDeletedHandler(serverCtx), | ||
660 | + }, | ||
601 | }..., | 661 | }..., |
602 | ), | 662 | ), |
603 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 663 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
@@ -678,4 +738,55 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -678,4 +738,55 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
678 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 738 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
679 | rest.WithPrefix("/v1"), | 739 | rest.WithPrefix("/v1"), |
680 | ) | 740 | ) |
741 | + | ||
742 | + server.AddRoutes( | ||
743 | + rest.WithMiddlewares( | ||
744 | + []rest.Middleware{serverCtx.LoginStatusCheck, serverCtx.LogRequest}, | ||
745 | + []rest.Route{ | ||
746 | + { | ||
747 | + Method: http.MethodGet, | ||
748 | + Path: "/article_category/:id", | ||
749 | + Handler: tags.ArticleCategoryGetHandler(serverCtx), | ||
750 | + }, | ||
751 | + { | ||
752 | + Method: http.MethodPost, | ||
753 | + Path: "/article_category", | ||
754 | + Handler: tags.ArticleCategorySaveHandler(serverCtx), | ||
755 | + }, | ||
756 | + { | ||
757 | + Method: http.MethodDelete, | ||
758 | + Path: "/article_category/:id", | ||
759 | + Handler: tags.ArticleCategoryDeleteHandler(serverCtx), | ||
760 | + }, | ||
761 | + { | ||
762 | + Method: http.MethodPut, | ||
763 | + Path: "/article_category/:id", | ||
764 | + Handler: tags.ArticleCategoryUpdateHandler(serverCtx), | ||
765 | + }, | ||
766 | + { | ||
767 | + Method: http.MethodPost, | ||
768 | + Path: "/article_category/search", | ||
769 | + Handler: tags.ArticleCategorySearchHandler(serverCtx), | ||
770 | + }, | ||
771 | + { | ||
772 | + Method: http.MethodGet, | ||
773 | + Path: "/article_category/options", | ||
774 | + Handler: tags.ArticleCategoryOptionsHandler(serverCtx), | ||
775 | + }, | ||
776 | + }..., | ||
777 | + ), | ||
778 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
779 | + rest.WithPrefix("/v1/system"), | ||
780 | + ) | ||
781 | + | ||
782 | + server.AddRoutes( | ||
783 | + []rest.Route{ | ||
784 | + { | ||
785 | + Method: http.MethodGet, | ||
786 | + Path: "/article_category/init", | ||
787 | + Handler: tags.ArticleCategoryInitHandler(serverCtx), | ||
788 | + }, | ||
789 | + }, | ||
790 | + rest.WithPrefix("/v1/system"), | ||
791 | + ) | ||
681 | } | 792 | } |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func ArticleCategoryDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.ArticleCategoryDeleteRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := tags.NewArticleCategoryDeleteLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.ArticleCategoryDelete(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func ArticleCategoryGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.ArticleCategoryGetRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := tags.NewArticleCategoryGetLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.ArticleCategoryGet(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | +) | ||
10 | + | ||
11 | +func ArticleCategoryInitHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
12 | + return func(w http.ResponseWriter, r *http.Request) { | ||
13 | + l := tags.NewArticleCategoryInitLogic(r.Context(), svcCtx) | ||
14 | + err := l.ArticleCategoryInit() | ||
15 | + if err != nil { | ||
16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
17 | + } else { | ||
18 | + httpx.Ok(w) | ||
19 | + } | ||
20 | + } | ||
21 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func ArticleCategoryOptionsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.CategoryOptionsRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := tags.NewArticleCategoryOptionsLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.ArticleCategoryOptions(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func ArticleCategorySaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.ArticleCategorySaveRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := tags.NewArticleCategorySaveLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.ArticleCategorySave(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func ArticleCategorySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.ArticleCategorySearchRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := tags.NewArticleCategorySearchLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.ArticleCategorySearch(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func ArticleCategoryUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.ArticleCategoryUpdateRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := tags.NewArticleCategoryUpdateLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.ArticleCategoryUpdate(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
@@ -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 |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
9 | + | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
12 | + | ||
13 | + "github.com/zeromicro/go-zero/core/logx" | ||
14 | +) | ||
15 | + | ||
16 | +type MiniArticleDeleteLogic struct { | ||
17 | + logx.Logger | ||
18 | + ctx context.Context | ||
19 | + svcCtx *svc.ServiceContext | ||
20 | + conn transaction.Conn | ||
21 | +} | ||
22 | + | ||
23 | +func NewMiniArticleDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleDeleteLogic { | ||
24 | + return &MiniArticleDeleteLogic{ | ||
25 | + Logger: logx.WithContext(ctx), | ||
26 | + ctx: ctx, | ||
27 | + svcCtx: svcCtx, | ||
28 | + conn: svcCtx.DefaultDBConn(), | ||
29 | + } | ||
30 | +} | ||
31 | + | ||
32 | +func (l *MiniArticleDeleteLogic) MiniArticleDelete(req *types.MiniArticleDeleteRequest) (resp *types.MiniArticleDeleteResponse, err error) { | ||
33 | + // 文章数据 | ||
34 | + article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, l.conn, req.Id) | ||
35 | + if err != nil { | ||
36 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
37 | + } | ||
38 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
39 | + if userToken.UserId != article.AuthorId || userToken.CompanyId != article.CompanyId { | ||
40 | + return nil, xerr.NewErrMsg("您没有权限删除") | ||
41 | + } | ||
42 | + // 检查发布人 | ||
43 | + author, err := l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, article.AuthorId) | ||
44 | + if err != nil { | ||
45 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
46 | + } | ||
47 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.conn, author.CompanyId) | ||
48 | + if err != nil { | ||
49 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
50 | + } | ||
51 | + articleAuthor := domain.UserSimple{ | ||
52 | + Id: author.Id, | ||
53 | + Name: author.Name, | ||
54 | + Avatar: author.Avatar, | ||
55 | + Position: author.Position, | ||
56 | + Company: companyInfo.Name, | ||
57 | + CompanyId: author.CompanyId, | ||
58 | + } | ||
59 | + article.DeletedType = domain.ArticleDeletedTypeUser | ||
60 | + //文章内容详情 | ||
61 | + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", req.Id) | ||
62 | + _, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, l.conn, queryOption) | ||
63 | + if err != nil { | ||
64 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
65 | + } | ||
66 | + var backup domain.ArticleBackup | ||
67 | + backup.MakeBackup(articleAuthor, article, sectionList, "删除") | ||
68 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
69 | + //更新删除类型 | ||
70 | + _, err = l.svcCtx.ArticleRepository.Update(l.ctx, conn, article) | ||
71 | + if err != nil { | ||
72 | + return err | ||
73 | + } | ||
74 | + //删除 | ||
75 | + _, err = l.svcCtx.ArticleRepository.Delete(l.ctx, conn, article) | ||
76 | + if err != nil { | ||
77 | + return err | ||
78 | + } | ||
79 | + //备份 | ||
80 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, conn, &backup) | ||
81 | + if err != nil { | ||
82 | + return xerr.NewErrMsgErr("删除失败", err) | ||
83 | + } | ||
84 | + return nil | ||
85 | + }, true) | ||
86 | + if err != nil { | ||
87 | + return nil, xerr.NewErrMsgErr("删除失败", err) | ||
88 | + } | ||
89 | + resp = &types.MiniArticleDeleteResponse{ | ||
90 | + Id: article.Id, | ||
91 | + Title: article.Title, | ||
92 | + } | ||
93 | + return | ||
94 | +} |
@@ -33,6 +33,7 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea | @@ -33,6 +33,7 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea | ||
33 | } | 33 | } |
34 | queryOptions := domain.NewQueryOptions(). | 34 | queryOptions := domain.NewQueryOptions(). |
35 | WithOffsetLimit(req.Page, req.Size). | 35 | WithOffsetLimit(req.Page, req.Size). |
36 | + WithKV("showDel", true). | ||
36 | MustWithKV("authorId", req.AuthorId) | 37 | MustWithKV("authorId", req.AuthorId) |
37 | 38 | ||
38 | cnt, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) | 39 | cnt, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) |
@@ -64,6 +65,10 @@ func NewArticle(article *domain.Article) types.ArticleSearchMe { | @@ -64,6 +65,10 @@ func NewArticle(article *domain.Article) types.ArticleSearchMe { | ||
64 | CountComment: article.CountComment, | 65 | CountComment: article.CountComment, |
65 | CountRead: article.CountRead, | 66 | CountRead: article.CountRead, |
66 | Show: int(article.Show), | 67 | Show: int(article.Show), |
68 | + TargetUser: int(article.TargetUser), | ||
69 | + WhoRead: article.WhoRead, | ||
70 | + IsDel: article.IsDel, | ||
71 | + DeletedType: article.DeletedType, | ||
67 | } | 72 | } |
68 | return articleSearchMe | 73 | return articleSearchMe |
69 | } | 74 | } |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/samber/lo" | ||
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/domain" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
13 | + | ||
14 | + "github.com/zeromicro/go-zero/core/logx" | ||
15 | +) | ||
16 | + | ||
17 | +type MiniArticleSetViewLogic struct { | ||
18 | + logx.Logger | ||
19 | + ctx context.Context | ||
20 | + svcCtx *svc.ServiceContext | ||
21 | + conn transaction.Conn | ||
22 | +} | ||
23 | + | ||
24 | +func NewMiniArticleSetViewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleSetViewLogic { | ||
25 | + return &MiniArticleSetViewLogic{ | ||
26 | + Logger: logx.WithContext(ctx), | ||
27 | + ctx: ctx, | ||
28 | + svcCtx: svcCtx, | ||
29 | + conn: svcCtx.DefaultDBConn(), | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +func (l *MiniArticleSetViewLogic) MiniArticleSetView(req *types.MiniArticleSetViewRequest) (resp *types.MiniArticleSetViewResponse, err error) { | ||
34 | + // 文章数据 | ||
35 | + article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, l.conn, req.Id) | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
38 | + } | ||
39 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
40 | + if userToken.UserId != article.AuthorId || userToken.CompanyId != article.CompanyId { | ||
41 | + return nil, xerr.NewErrMsg("您没有权限修改") | ||
42 | + } | ||
43 | + // 检查发布人 | ||
44 | + author, err := l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, article.AuthorId) | ||
45 | + if err != nil { | ||
46 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
47 | + } | ||
48 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.conn, author.CompanyId) | ||
49 | + if err != nil { | ||
50 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
51 | + } | ||
52 | + articleAuthor := domain.UserSimple{ | ||
53 | + Id: author.Id, | ||
54 | + Name: author.Name, | ||
55 | + Avatar: author.Avatar, | ||
56 | + Position: author.Position, | ||
57 | + Company: companyInfo.Name, | ||
58 | + CompanyId: author.CompanyId, | ||
59 | + } | ||
60 | + //检查文章可被哪些人查看 | ||
61 | + whoRead := []int64{} | ||
62 | + if len(req.WhoRead) > 0 { | ||
63 | + whoRead = lo.Uniq(req.WhoRead) | ||
64 | + var u *domain.User | ||
65 | + for _, val := range whoRead { | ||
66 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, val) | ||
67 | + if err != nil { | ||
68 | + return nil, xerr.NewErrMsgErr("文章可查看人设置错误", err) | ||
69 | + } | ||
70 | + if u.CompanyId != userToken.CompanyId { | ||
71 | + return nil, xerr.NewErrMsg("文章可查看人设置错误") | ||
72 | + } | ||
73 | + } | ||
74 | + } | ||
75 | + //文章内容详情 | ||
76 | + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", req.Id) | ||
77 | + _, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, l.conn, queryOption) | ||
78 | + if err != nil { | ||
79 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
80 | + } | ||
81 | + var oldBackup domain.ArticleBackup | ||
82 | + oldBackup.MakeBackup(articleAuthor, article, sectionList, "设置可见范围") | ||
83 | + //更新数据 | ||
84 | + article.TargetUser = domain.ArticleTargetLimit | ||
85 | + article.WhoRead = whoRead | ||
86 | + article.WhoReview = whoRead | ||
87 | + | ||
88 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, c transaction.Conn) error { | ||
89 | + //更新文章内容 | ||
90 | + _, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article) | ||
91 | + if err != nil { | ||
92 | + return xerr.NewErrMsgErr("保存帖子失败", err) | ||
93 | + } | ||
94 | + //备份文章 | ||
95 | + var backup domain.ArticleBackup | ||
96 | + backup.MakeBackup(articleAuthor, article, sectionList, "设置可见范围") | ||
97 | + if ok := backup.CheckChangeField(&oldBackup); ok { | ||
98 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, &backup) | ||
99 | + if err != nil { | ||
100 | + return xerr.NewErrMsgErr("保存文章日志失败", err) | ||
101 | + } | ||
102 | + } | ||
103 | + return nil | ||
104 | + }, true) | ||
105 | + resp = &types.MiniArticleSetViewResponse{ | ||
106 | + Id: article.Id, | ||
107 | + Title: article.Title, | ||
108 | + WhoRead: article.WhoRead, | ||
109 | + } | ||
110 | + return | ||
111 | +} |
@@ -47,10 +47,15 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) | @@ -47,10 +47,15 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) | ||
47 | countDataMap[val.TagId] = val | 47 | countDataMap[val.TagId] = val |
48 | } | 48 | } |
49 | 49 | ||
50 | - tagCategory := []string{} | ||
51 | - tagCount := []types.ArticleTagCount{} | 50 | + _, categoryList, _ := l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions().MustWithKV("enable", 1)) |
51 | + tagCount := make([]types.ArticleTagCount, 0) | ||
52 | + tagCategory := domain.Values(categoryList, func(item *domain.ArticleCategory) string { | ||
53 | + return item.Name | ||
54 | + }) | ||
55 | + categoryMap := lo.KeyBy(categoryList, func(item *domain.ArticleCategory) int64 { | ||
56 | + return item.Id | ||
57 | + }) | ||
52 | for _, val := range allTags { | 58 | for _, val := range allTags { |
53 | - tagCategory = append(tagCategory, val.Category) | ||
54 | m := types.ArticleTagCount{ | 59 | m := types.ArticleTagCount{ |
55 | TagCategory: val.Category, | 60 | TagCategory: val.Category, |
56 | TagId: val.Id, | 61 | TagId: val.Id, |
@@ -65,9 +70,13 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) | @@ -65,9 +70,13 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) | ||
65 | m.TotalArticle = count.TotalArticle | 70 | m.TotalArticle = count.TotalArticle |
66 | m.ReadArticle = count.ReadArticle | 71 | m.ReadArticle = count.ReadArticle |
67 | } | 72 | } |
73 | + if v, ok := categoryMap[val.CategoryId]; ok { | ||
74 | + m.TagCategory = v.Name | ||
75 | + } else { | ||
76 | + continue | ||
77 | + } | ||
68 | tagCount = append(tagCount, m) | 78 | tagCount = append(tagCount, m) |
69 | } | 79 | } |
70 | - tagCategory = lo.Uniq(tagCategory) | ||
71 | resp = &types.MiniHomePageResponse{ | 80 | resp = &types.MiniHomePageResponse{ |
72 | TagCategory: tagCategory, | 81 | TagCategory: tagCategory, |
73 | Tags: tagCount, | 82 | Tags: tagCount, |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/samber/lo" | ||
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/domain" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
13 | + | ||
14 | + "github.com/zeromicro/go-zero/core/logx" | ||
15 | +) | ||
16 | + | ||
17 | +type SystemArticleSearchDeletedLogic struct { | ||
18 | + logx.Logger | ||
19 | + ctx context.Context | ||
20 | + svcCtx *svc.ServiceContext | ||
21 | + conn transaction.Conn | ||
22 | +} | ||
23 | + | ||
24 | +func NewSystemArticleSearchDeletedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleSearchDeletedLogic { | ||
25 | + return &SystemArticleSearchDeletedLogic{ | ||
26 | + Logger: logx.WithContext(ctx), | ||
27 | + ctx: ctx, | ||
28 | + svcCtx: svcCtx, | ||
29 | + conn: svcCtx.DefaultDBConn(), | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +func (l *SystemArticleSearchDeletedLogic) SystemArticleSearchDeleted(req *types.SystemArticleSearchDeletedRequest) (resp *types.SystemArticleSearchDeletedResponse, err error) { | ||
34 | + queryOptions := domain.NewQueryOptions(). | ||
35 | + WithOffsetLimit(req.Page, req.Size). | ||
36 | + WithKV("isDel", 1). | ||
37 | + WithKV("title", req.Title). | ||
38 | + WithKV("authorId", req.Author). | ||
39 | + WithKV("beginDeletedAt", req.BeginTime). | ||
40 | + WithKV("endDeletedAt", req.EndTime). | ||
41 | + WithKV("deletedType", req.DeletedType). | ||
42 | + WithKV("orderMode", "deletedAt descending") | ||
43 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
44 | + total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.conn, userToken.CompanyId, queryOptions) | ||
45 | + if err != nil { | ||
46 | + return nil, xerr.NewErrMsgErr("搜索已删除列表异常", err) | ||
47 | + } | ||
48 | + resp = &types.SystemArticleSearchDeletedResponse{ | ||
49 | + Total: int(total), | ||
50 | + List: make([]types.SystemArticleSearchDeletedItem, 0), | ||
51 | + } | ||
52 | + authorIds := make([]int64, 0) | ||
53 | + lo.ForEach(articles, func(item *domain.Article, index int) { | ||
54 | + authorIds = append(authorIds, item.AuthorId) | ||
55 | + }) | ||
56 | + //查询用户数据,重新赋值更新用户名称 | ||
57 | + _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, l.conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds)) | ||
58 | + lo.ForEach(articles, func(item *domain.Article, index int) { | ||
59 | + //图片 | ||
60 | + images := make([]string, 0) | ||
61 | + lo.ForEach(item.Images, func(img domain.Image, n int) { | ||
62 | + images = append(images, img.Url) | ||
63 | + }) | ||
64 | + //发布人 | ||
65 | + author := item.Author.Name | ||
66 | + for _, user := range users { | ||
67 | + if user.Id == item.AuthorId { | ||
68 | + author = user.Name | ||
69 | + } | ||
70 | + } | ||
71 | + resp.List = append(resp.List, types.SystemArticleSearchDeletedItem{ | ||
72 | + Id: item.Id, | ||
73 | + Title: item.Title, | ||
74 | + Images: images, | ||
75 | + AuthorId: item.AuthorId, | ||
76 | + Author: author, | ||
77 | + Source: item.Source, | ||
78 | + DeletedType: item.DeletedType, | ||
79 | + DeletedAt: item.DeletedAt, | ||
80 | + }) | ||
81 | + }) | ||
82 | + return | ||
83 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
11 | + "strconv" | ||
12 | + | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
15 | + | ||
16 | + "github.com/zeromicro/go-zero/core/logx" | ||
17 | +) | ||
18 | + | ||
19 | +type SystemCreateArticleDraftLogic struct { | ||
20 | + logx.Logger | ||
21 | + ctx context.Context | ||
22 | + svcCtx *svc.ServiceContext | ||
23 | + conn transaction.Conn | ||
24 | +} | ||
25 | + | ||
26 | +func NewSystemCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCreateArticleDraftLogic { | ||
27 | + return &SystemCreateArticleDraftLogic{ | ||
28 | + Logger: logx.WithContext(ctx), | ||
29 | + ctx: ctx, | ||
30 | + svcCtx: svcCtx, | ||
31 | + conn: svcCtx.DefaultDBConn(), | ||
32 | + } | ||
33 | +} | ||
34 | + | ||
35 | +func (l *SystemCreateArticleDraftLogic) SystemCreateArticleDraft(req *types.SystemArticleDraftCreateRequest) (resp *types.SystemArticleDraftCreateResponse, err error) { | ||
36 | + // 检查发布人 | ||
37 | + author, err := l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, req.AuthorId) | ||
38 | + if err != nil { | ||
39 | + return nil, xerr.NewErrMsgErr("创建草稿失败", err) | ||
40 | + } | ||
41 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.conn, author.CompanyId) | ||
42 | + if err != nil { | ||
43 | + return nil, xerr.NewErrMsgErr("创建草稿失败", err) | ||
44 | + } | ||
45 | + //图片 | ||
46 | + images, err := getImages(req.Images) | ||
47 | + if err != nil { | ||
48 | + return nil, xerr.NewErrMsg(err.Error()) | ||
49 | + } | ||
50 | + //视频 | ||
51 | + videos, err := getVideos(req.Videos) | ||
52 | + if err != nil { | ||
53 | + return nil, xerr.NewErrMsg(err.Error()) | ||
54 | + } | ||
55 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
56 | + // 获取当前用户信息 | ||
57 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
58 | + if err != nil { | ||
59 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
60 | + } | ||
61 | + articleDraft := &domain.ArticleDraftOperation{ | ||
62 | + CompanyId: companyInfo.Id, | ||
63 | + AuthorId: req.AuthorId, | ||
64 | + Title: req.Title, | ||
65 | + Content: req.Content, | ||
66 | + Images: images, | ||
67 | + Videos: videos, | ||
68 | + TargetUser: domain.ArticleTarget(req.TargetUser), | ||
69 | + WhoRead: req.WhoRead, | ||
70 | + WhoReview: req.WhoReview, | ||
71 | + MatchUrl: req.MatchUrl, | ||
72 | + Source: domain.ArticleSourceOperator, | ||
73 | + Operator: domain.Operator{ | ||
74 | + Id: userToken.UserId, | ||
75 | + Name: userMe.User.NickName, | ||
76 | + }, | ||
77 | + Tags: req.Tags, | ||
78 | + } | ||
79 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
80 | + _, err := l.svcCtx.ArticleDraftOperationRepository.Insert(ctx, conn, articleDraft) | ||
81 | + if err != nil { | ||
82 | + return err | ||
83 | + } | ||
84 | + return nil | ||
85 | + }, true) | ||
86 | + resp = &types.SystemArticleDraftCreateResponse{ | ||
87 | + Id: articleDraft.Id, | ||
88 | + Title: articleDraft.Title, | ||
89 | + Content: articleDraft.Content, | ||
90 | + AuthorId: articleDraft.AuthorId, | ||
91 | + Images: req.Images, | ||
92 | + Videos: req.Videos, | ||
93 | + TargetUser: req.TargetUser, | ||
94 | + WhoRead: req.WhoRead, | ||
95 | + WhoReview: req.WhoReview, | ||
96 | + MatchUrl: req.MatchUrl, | ||
97 | + Tags: req.Tags, | ||
98 | + } | ||
99 | + return | ||
100 | +} | ||
101 | + | ||
102 | +// getImages 获取图片信息 | ||
103 | +func getImages(imgs []string) ([]domain.Image, error) { | ||
104 | + // 获取图片的尺寸大小 | ||
105 | + images := make([]domain.Image, 0) | ||
106 | + if len(imgs) <= 0 { | ||
107 | + return images, nil | ||
108 | + } | ||
109 | + for _, val := range imgs { | ||
110 | + fInfo, err := oss.GetImageInfo(val) | ||
111 | + if err != nil { | ||
112 | + return images, xerr.NewErrMsg("获取图片失败") | ||
113 | + } | ||
114 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
115 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
116 | + images = append(images, domain.Image{ | ||
117 | + Url: val, | ||
118 | + Width: w, | ||
119 | + Height: h, | ||
120 | + }) | ||
121 | + } | ||
122 | + return images, nil | ||
123 | +} | ||
124 | + | ||
125 | +// getVideos 获取视频信息 | ||
126 | +func getVideos(list []types.Video) ([]domain.Video, error) { | ||
127 | + videos := make([]domain.Video, 0) | ||
128 | + if len(list) <= 0 { | ||
129 | + return videos, nil | ||
130 | + } | ||
131 | + if len(list) > 0 { | ||
132 | + for _, item := range list { | ||
133 | + cover, w, h, err := oss.GetVideoCover(item.Url) | ||
134 | + if err != nil { | ||
135 | + return videos, xerr.NewErrMsg("获取视频信息失败") | ||
136 | + } | ||
137 | + videos = append(videos, domain.Video{ | ||
138 | + Url: item.Url, | ||
139 | + Cover: cover, | ||
140 | + Width: w, | ||
141 | + Height: h, | ||
142 | + }) | ||
143 | + } | ||
144 | + } | ||
145 | + return videos, nil | ||
146 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/pkg/errors" | ||
6 | + "github.com/samber/lo" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
13 | + "strconv" | ||
14 | + "strings" | ||
15 | + "unicode/utf8" | ||
16 | + | ||
17 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
18 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
19 | + | ||
20 | + "github.com/zeromicro/go-zero/core/logx" | ||
21 | +) | ||
22 | + | ||
23 | +type SystemCreateArticleLogic struct { | ||
24 | + logx.Logger | ||
25 | + ctx context.Context | ||
26 | + svcCtx *svc.ServiceContext | ||
27 | + conn transaction.Conn | ||
28 | +} | ||
29 | + | ||
30 | +func NewSystemCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCreateArticleLogic { | ||
31 | + return &SystemCreateArticleLogic{ | ||
32 | + Logger: logx.WithContext(ctx), | ||
33 | + ctx: ctx, | ||
34 | + svcCtx: svcCtx, | ||
35 | + conn: svcCtx.DefaultDBConn(), | ||
36 | + } | ||
37 | +} | ||
38 | + | ||
39 | +func (l *SystemCreateArticleLogic) SystemCreateArticle(req *types.SystemArticleCreateRequest) (resp *types.SystemArticleCreateResponse, err error) { | ||
40 | + err = l.validate(req) | ||
41 | + if err != nil { | ||
42 | + return nil, xerr.NewErrMsg(err.Error()) | ||
43 | + } | ||
44 | + // 检查发布人 | ||
45 | + author, err := l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, req.AuthorId) | ||
46 | + if err != nil { | ||
47 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
48 | + } | ||
49 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.conn, author.CompanyId) | ||
50 | + if err != nil { | ||
51 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
52 | + } | ||
53 | + //文章作者 | ||
54 | + articleAuthor := domain.UserSimple{ | ||
55 | + Id: author.Id, | ||
56 | + Name: author.Name, | ||
57 | + Avatar: author.Avatar, | ||
58 | + Position: author.Position, | ||
59 | + Company: companyInfo.Name, | ||
60 | + CompanyId: author.CompanyId, | ||
61 | + } | ||
62 | + //图片 | ||
63 | + images, err := l.getImages(req) | ||
64 | + if err != nil { | ||
65 | + return nil, xerr.NewErrMsg(err.Error()) | ||
66 | + } | ||
67 | + //视频 | ||
68 | + videos, err := l.getVideos(req) | ||
69 | + if err != nil { | ||
70 | + return nil, xerr.NewErrMsg(err.Error()) | ||
71 | + } | ||
72 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
73 | + // 获取当前用户信息 | ||
74 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
75 | + if err != nil { | ||
76 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
77 | + } | ||
78 | + article := &domain.Article{ | ||
79 | + CompanyId: companyInfo.Id, | ||
80 | + AuthorId: req.AuthorId, | ||
81 | + Author: articleAuthor, | ||
82 | + Title: req.Title, | ||
83 | + Images: images, | ||
84 | + Videos: videos, | ||
85 | + WhoRead: make([]int64, 0), | ||
86 | + WhoReview: make([]int64, 0), | ||
87 | + Location: domain.Location{}, | ||
88 | + TargetUser: domain.ArticleTarget(req.TargetUser), | ||
89 | + Show: domain.ArticleShowEnable, | ||
90 | + Tags: make([]int64, 0), | ||
91 | + MatchUrl: make(map[string]string), | ||
92 | + Source: domain.ArticleSourceOperator, | ||
93 | + Operator: domain.Operator{ | ||
94 | + Id: userToken.UserId, | ||
95 | + Name: userMe.User.NickName, | ||
96 | + }, | ||
97 | + } | ||
98 | + if len(req.MatchUrl) > 0 { | ||
99 | + article.MatchUrl = req.MatchUrl | ||
100 | + } | ||
101 | + //检查文章可被哪些人查看 | ||
102 | + whoRead, err := l.validateAndGetWhoRead(req, article) | ||
103 | + if err != nil { | ||
104 | + return nil, err | ||
105 | + } | ||
106 | + //检查文章可被哪些人评论 | ||
107 | + whoReview := []int64{} | ||
108 | + if len(req.WhoReview) > 0 { | ||
109 | + whoReview = lo.Uniq(req.WhoReview) | ||
110 | + } | ||
111 | + //验证可评论 | ||
112 | + if err = l.validateWhoReview(whoRead, whoReview, article); err != nil { | ||
113 | + return nil, err | ||
114 | + } | ||
115 | + article.WhoRead = whoRead | ||
116 | + article.WhoReview = whoReview | ||
117 | + sections := l.getSections(req, article) | ||
118 | + //设置内容摘要 | ||
119 | + article.SetSummary(sections) | ||
120 | + //草稿ID | ||
121 | + if req.ArticleDraftId > 0 { | ||
122 | + articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.ArticleDraftId) | ||
123 | + if err != nil { | ||
124 | + return nil, xerr.NewErrMsg("草稿不存在") | ||
125 | + } | ||
126 | + if articleDraft.CompanyId != userToken.CompanyId { | ||
127 | + return nil, xerr.NewErrMsg("您没有权限") | ||
128 | + } | ||
129 | + } | ||
130 | + //保存数据 | ||
131 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
132 | + _, err = l.svcCtx.ArticleRepository.Insert(ctx, conn, article) | ||
133 | + if err != nil { | ||
134 | + return xerr.NewErrMsgErr("创建文章失败", err) | ||
135 | + } | ||
136 | + for i := range sections { | ||
137 | + sections[i].ArticleId = article.Id | ||
138 | + _, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, conn, sections[i]) | ||
139 | + if err != nil { | ||
140 | + return xerr.NewErrMsgErr("创建文章内容失败", err) | ||
141 | + } | ||
142 | + } | ||
143 | + // 生成 备份数据 | ||
144 | + var backupData domain.ArticleBackup | ||
145 | + backupData.MakeBackup(articleAuthor, article, sections, "原始版本") | ||
146 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(l.ctx, conn, &backupData) | ||
147 | + if err != nil { | ||
148 | + return xerr.NewErrMsgErr("创建文章失败", err) | ||
149 | + } | ||
150 | + //删除草稿 | ||
151 | + if req.ArticleDraftId > 0 { | ||
152 | + _, err = l.svcCtx.ArticleDraftOperationRepository.Delete(l.ctx, conn, &domain.ArticleDraftOperation{Id: req.ArticleDraftId}) | ||
153 | + if err != nil { | ||
154 | + return xerr.NewErrMsg("删除草稿失败") | ||
155 | + } | ||
156 | + } | ||
157 | + return nil | ||
158 | + }, true) | ||
159 | + if err != nil { | ||
160 | + return nil, xerr.NewErrMsgErr("创建文章失败", err) | ||
161 | + } | ||
162 | + resp = &types.SystemArticleCreateResponse{ | ||
163 | + Id: article.Id, | ||
164 | + Title: article.Title, | ||
165 | + Content: req.Content, | ||
166 | + AuthorId: req.AuthorId, | ||
167 | + Images: req.Images, | ||
168 | + Videos: req.Videos, | ||
169 | + TargetUser: req.TargetUser, | ||
170 | + WhoRead: whoRead, | ||
171 | + WhoReview: whoReview, | ||
172 | + } | ||
173 | + return | ||
174 | +} | ||
175 | + | ||
176 | +// validate 验证 | ||
177 | +func (l *SystemCreateArticleLogic) validate(req *types.SystemArticleCreateRequest) error { | ||
178 | + //文章标题 | ||
179 | + if utf8.RuneCountInString(req.Title) > 64 { | ||
180 | + return errors.New("标题最多只能输入64字") | ||
181 | + } | ||
182 | + //文章内容 | ||
183 | + if utf8.RuneCountInString(req.Content) > 1000 { | ||
184 | + return errors.New("内容最多只能输入1000字") | ||
185 | + } | ||
186 | + //图片 | ||
187 | + if len(req.Images) > 9 { | ||
188 | + return errors.New("图片数量最多9张") | ||
189 | + } | ||
190 | + return nil | ||
191 | +} | ||
192 | + | ||
193 | +// getImages 获取图片信息 | ||
194 | +func (l *SystemCreateArticleLogic) getImages(req *types.SystemArticleCreateRequest) ([]domain.Image, error) { | ||
195 | + // 获取图片的尺寸大小 | ||
196 | + images := make([]domain.Image, 0) | ||
197 | + for _, val := range req.Images { | ||
198 | + fInfo, err := oss.GetImageInfo(val) | ||
199 | + if err != nil { | ||
200 | + return images, xerr.NewErrMsg("获取图片失败") | ||
201 | + } | ||
202 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
203 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
204 | + images = append(images, domain.Image{ | ||
205 | + Url: val, | ||
206 | + Width: w, | ||
207 | + Height: h, | ||
208 | + }) | ||
209 | + } | ||
210 | + return images, nil | ||
211 | +} | ||
212 | + | ||
213 | +// getVideo 获取视频信息 | ||
214 | +func (l *SystemCreateArticleLogic) getVideos(req *types.SystemArticleCreateRequest) ([]domain.Video, error) { | ||
215 | + videos := make([]domain.Video, 0) | ||
216 | + if len(req.Videos) > 0 { | ||
217 | + for _, item := range req.Videos { | ||
218 | + cover, w, h, err := oss.GetVideoCover(item.Url) | ||
219 | + if err != nil { | ||
220 | + return videos, xerr.NewErrMsg("获取视频信息失败") | ||
221 | + } | ||
222 | + videos = append(videos, domain.Video{ | ||
223 | + Url: item.Url, | ||
224 | + Cover: cover, | ||
225 | + Width: w, | ||
226 | + Height: h, | ||
227 | + }) | ||
228 | + } | ||
229 | + } | ||
230 | + return videos, nil | ||
231 | +} | ||
232 | + | ||
233 | +// validateAndGetWhoRead 验证并获取可阅读 | ||
234 | +func (l *SystemCreateArticleLogic) validateAndGetWhoRead(req *types.SystemArticleCreateRequest, article *domain.Article) ([]int64, error) { | ||
235 | + whoRead := make([]int64, 0) | ||
236 | + if len(req.WhoRead) > 0 { | ||
237 | + whoRead = lo.Uniq(req.WhoRead) | ||
238 | + var u *domain.User | ||
239 | + var err error | ||
240 | + for _, val := range whoRead { | ||
241 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, val) | ||
242 | + if err != nil { | ||
243 | + return whoRead, xerr.NewErrMsgErr("文章可查看人设置错误", err) | ||
244 | + } | ||
245 | + if u.CompanyId != article.CompanyId { | ||
246 | + return whoRead, xerr.NewErrMsg("文章可查看人设置错误") | ||
247 | + } | ||
248 | + } | ||
249 | + } | ||
250 | + return whoRead, nil | ||
251 | +} | ||
252 | + | ||
253 | +// validateWhoReview 验证可评论 | ||
254 | +func (l *SystemCreateArticleLogic) validateWhoReview(whoRead []int64, whoReview []int64, article *domain.Article) error { | ||
255 | + //有指定可查看人的情况 | ||
256 | + if len(whoRead) > 0 { | ||
257 | + if len(whoReview) > 0 { | ||
258 | + // 检查 whoRead 是否 完全包含 whoReview | ||
259 | + ok := lo.Every(whoRead, whoReview) | ||
260 | + if !ok { | ||
261 | + return xerr.NewErrMsg("文章可评论人设置错误") | ||
262 | + } | ||
263 | + } | ||
264 | + if len(whoReview) == 0 { | ||
265 | + //有指定可查看人 ,但未指定可评论人 | ||
266 | + return xerr.NewErrMsg("文章可评论人设置错误") | ||
267 | + } | ||
268 | + } | ||
269 | + //没有指定可查看人的情况 | ||
270 | + if len(whoRead) == 0 { | ||
271 | + if len(whoReview) > 0 { | ||
272 | + // 未指定可查看人(全员可看),有指定可评论人, | ||
273 | + var u *domain.User | ||
274 | + var err error | ||
275 | + for _, val := range whoReview { | ||
276 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, val) | ||
277 | + if err != nil { | ||
278 | + return xerr.NewErrMsgErr("文章可评论人设置错误", err) | ||
279 | + } | ||
280 | + if u.CompanyId != article.CompanyId { | ||
281 | + return xerr.NewErrMsg("文章可评论人设置错误") | ||
282 | + } | ||
283 | + } | ||
284 | + } | ||
285 | + } | ||
286 | + return nil | ||
287 | +} | ||
288 | + | ||
289 | +// getSections 文章内容 | ||
290 | +func (l *SystemCreateArticleLogic) getSections(req *types.SystemArticleCreateRequest, article *domain.Article) []*domain.ArticleSection { | ||
291 | + articleSections := make([]*domain.ArticleSection, 0) | ||
292 | + sortBy := 1 | ||
293 | + sections := strings.Split(req.Content, "\n") | ||
294 | + lo.ForEach(sections, func(item string, index int) { | ||
295 | + //去除空 | ||
296 | + item = strings.TrimSpace(item) | ||
297 | + if item != "" { | ||
298 | + section := domain.ArticleSection{ | ||
299 | + CompanyId: article.CompanyId, | ||
300 | + Version: article.Version, | ||
301 | + ArticleId: article.Id, | ||
302 | + Content: item, | ||
303 | + SortBy: sortBy, | ||
304 | + } | ||
305 | + articleSections = append(articleSections, §ion) | ||
306 | + sortBy++ | ||
307 | + } | ||
308 | + }) | ||
309 | + return articleSections | ||
310 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/samber/lo" | ||
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/domain" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
13 | + | ||
14 | + "github.com/zeromicro/go-zero/core/logx" | ||
15 | +) | ||
16 | + | ||
17 | +type SystemDeleteArticleDraftLogic struct { | ||
18 | + logx.Logger | ||
19 | + ctx context.Context | ||
20 | + svcCtx *svc.ServiceContext | ||
21 | + conn transaction.Conn | ||
22 | +} | ||
23 | + | ||
24 | +func NewSystemDeleteArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteArticleDraftLogic { | ||
25 | + return &SystemDeleteArticleDraftLogic{ | ||
26 | + Logger: logx.WithContext(ctx), | ||
27 | + ctx: ctx, | ||
28 | + svcCtx: svcCtx, | ||
29 | + conn: svcCtx.DefaultDBConn(), | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +func (l *SystemDeleteArticleDraftLogic) SystemDeleteArticleDraft(req *types.SystemArticleDraftDeleteRequest) (resp *types.SystemArticleDraftDeleteResponse, err error) { | ||
34 | + // 草稿数据 | ||
35 | + articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id) | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsg("草稿不存在") | ||
38 | + } | ||
39 | + //操作人 | ||
40 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
41 | + if userToken.CompanyId != articleDraft.CompanyId { | ||
42 | + return nil, xerr.NewErrMsg("您没有权限删除") | ||
43 | + } | ||
44 | + _, err = l.svcCtx.ArticleDraftOperationRepository.Delete(l.ctx, l.conn, articleDraft) | ||
45 | + if err != nil { | ||
46 | + return nil, xerr.NewErrMsg("删除草稿失败") | ||
47 | + } | ||
48 | + //图片 | ||
49 | + images := make([]string, 0) | ||
50 | + lo.ForEach(articleDraft.Images, func(img domain.Image, n int) { | ||
51 | + images = append(images, img.Url) | ||
52 | + }) | ||
53 | + //视频 | ||
54 | + videos := make([]types.Video, 0) | ||
55 | + lo.ForEach(articleDraft.Videos, func(video domain.Video, n int) { | ||
56 | + videos = append(videos, types.Video{ | ||
57 | + Url: video.Url, | ||
58 | + Cover: video.Cover, | ||
59 | + Width: video.Width, | ||
60 | + Height: video.Height, | ||
61 | + }) | ||
62 | + }) | ||
63 | + resp = &types.SystemArticleDraftDeleteResponse{ | ||
64 | + Id: articleDraft.Id, | ||
65 | + Title: articleDraft.Title, | ||
66 | + Content: articleDraft.Content, | ||
67 | + AuthorId: articleDraft.AuthorId, | ||
68 | + Images: images, | ||
69 | + Videos: videos, | ||
70 | + TargetUser: int(articleDraft.TargetUser), | ||
71 | + WhoRead: articleDraft.WhoRead, | ||
72 | + WhoReview: articleDraft.WhoReview, | ||
73 | + MatchUrl: articleDraft.MatchUrl, | ||
74 | + Tags: articleDraft.Tags, | ||
75 | + } | ||
76 | + return | ||
77 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | ||
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/domain" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
11 | + "time" | ||
12 | + | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
15 | + | ||
16 | + "github.com/zeromicro/go-zero/core/logx" | ||
17 | +) | ||
18 | + | ||
19 | +type SystemDeleteArticleLogic struct { | ||
20 | + logx.Logger | ||
21 | + ctx context.Context | ||
22 | + svcCtx *svc.ServiceContext | ||
23 | + conn transaction.Conn | ||
24 | +} | ||
25 | + | ||
26 | +func NewSystemDeleteArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteArticleLogic { | ||
27 | + return &SystemDeleteArticleLogic{ | ||
28 | + Logger: logx.WithContext(ctx), | ||
29 | + ctx: ctx, | ||
30 | + svcCtx: svcCtx, | ||
31 | + conn: svcCtx.DefaultDBConn(), | ||
32 | + } | ||
33 | +} | ||
34 | + | ||
35 | +func (l *SystemDeleteArticleLogic) SystemDeleteArticle(req *types.SystemArticleDeleteRequest) (resp *types.SystemArticleDeleteResponse, err error) { | ||
36 | + // 文章数据 | ||
37 | + article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, l.conn, req.Id) | ||
38 | + if err != nil { | ||
39 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
40 | + } | ||
41 | + //文章内容 | ||
42 | + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", req.Id) | ||
43 | + _, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, l.conn, queryOption) | ||
44 | + if err != nil { | ||
45 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
46 | + } | ||
47 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
48 | + if userToken.CompanyId != article.CompanyId { | ||
49 | + return nil, xerr.NewErrMsg("您没有权限") | ||
50 | + } | ||
51 | + // 获取当前用户信息 | ||
52 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
53 | + if err != nil { | ||
54 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
55 | + } | ||
56 | + operator := domain.UserSimple{ | ||
57 | + Id: userToken.UserId, | ||
58 | + Name: userMe.User.NickName, | ||
59 | + Avatar: userMe.User.Avatar, | ||
60 | + CompanyId: userToken.CompanyId, | ||
61 | + Company: userMe.CurrentCompany.Name, | ||
62 | + } | ||
63 | + article.DeletedType = domain.ArticleDeletedTypeOperator | ||
64 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
65 | + //更新删除类型 | ||
66 | + _, err = l.svcCtx.ArticleRepository.Update(l.ctx, conn, article) | ||
67 | + if err != nil { | ||
68 | + return err | ||
69 | + } | ||
70 | + _, err = l.svcCtx.ArticleRepository.Delete(l.ctx, conn, article) | ||
71 | + if err != nil { | ||
72 | + return err | ||
73 | + } | ||
74 | + var backup domain.ArticleBackup | ||
75 | + backup.MakeBackup(operator, article, sectionList, "删除") | ||
76 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, conn, &backup) | ||
77 | + if err != nil { | ||
78 | + return xerr.NewErrMsgErr("保存文章内容失败", err) | ||
79 | + } | ||
80 | + //消息通知 | ||
81 | + messageLogic := message.NewMiniSystemLogic(l.ctx, l.svcCtx) | ||
82 | + mTime := time.Unix(article.CreatedAt, 0).Format("2006-01-02 15:04") | ||
83 | + err = messageLogic.ArticleDeleted(conn, article.CompanyId, article.AuthorId, mTime, article.Title) | ||
84 | + if err != nil { | ||
85 | + return xerr.NewErrMsgErr("删除失败", err) | ||
86 | + } | ||
87 | + return nil | ||
88 | + }, true) | ||
89 | + if err != nil { | ||
90 | + return nil, xerr.NewErrMsgErr("删除失败", err) | ||
91 | + } | ||
92 | + resp = &types.SystemArticleDeleteResponse{ | ||
93 | + Id: article.Id, | ||
94 | + Title: article.Title, | ||
95 | + AuthorId: article.AuthorId, | ||
96 | + } | ||
97 | + return | ||
98 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/samber/lo" | ||
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/domain" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
13 | + | ||
14 | + "github.com/zeromicro/go-zero/core/logx" | ||
15 | +) | ||
16 | + | ||
17 | +type SystemGetArticleDraftLogic struct { | ||
18 | + logx.Logger | ||
19 | + ctx context.Context | ||
20 | + svcCtx *svc.ServiceContext | ||
21 | + conn transaction.Conn | ||
22 | +} | ||
23 | + | ||
24 | +func NewSystemGetArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetArticleDraftLogic { | ||
25 | + return &SystemGetArticleDraftLogic{ | ||
26 | + Logger: logx.WithContext(ctx), | ||
27 | + ctx: ctx, | ||
28 | + svcCtx: svcCtx, | ||
29 | + conn: svcCtx.DefaultDBConn(), | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +func (l *SystemGetArticleDraftLogic) SystemGetArticleDraft(req *types.SystemArticleDraftGetRequest) (resp *types.SystemArticleDraftGetResponse, err error) { | ||
34 | + // 草稿数据 | ||
35 | + articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id) | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsg("草稿不存在") | ||
38 | + } | ||
39 | + //操作人 | ||
40 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
41 | + //不同公司不能获取数据 | ||
42 | + if userToken.CompanyId != articleDraft.CompanyId { | ||
43 | + return nil, xerr.NewErrMsg("您没有权限查看该数据") | ||
44 | + } | ||
45 | + //图片 | ||
46 | + images := make([]string, 0) | ||
47 | + lo.ForEach(articleDraft.Images, func(img domain.Image, n int) { | ||
48 | + images = append(images, img.Url) | ||
49 | + }) | ||
50 | + //视频 | ||
51 | + videos := make([]types.Video, 0) | ||
52 | + lo.ForEach(articleDraft.Videos, func(video domain.Video, n int) { | ||
53 | + videos = append(videos, types.Video{ | ||
54 | + Url: video.Url, | ||
55 | + Cover: video.Cover, | ||
56 | + Width: video.Width, | ||
57 | + Height: video.Height, | ||
58 | + }) | ||
59 | + }) | ||
60 | + resp = &types.SystemArticleDraftGetResponse{ | ||
61 | + Id: articleDraft.Id, | ||
62 | + Title: articleDraft.Title, | ||
63 | + Content: articleDraft.Content, | ||
64 | + AuthorId: articleDraft.AuthorId, | ||
65 | + Images: images, | ||
66 | + Videos: videos, | ||
67 | + TargetUser: int(articleDraft.TargetUser), | ||
68 | + WhoRead: articleDraft.WhoRead, | ||
69 | + WhoReadInfo: make([]types.UserShowName, 0), | ||
70 | + WhoReview: articleDraft.WhoReview, | ||
71 | + WhoReviewInfo: make([]types.UserShowName, 0), | ||
72 | + MatchUrl: articleDraft.MatchUrl, | ||
73 | + Tags: articleDraft.Tags, | ||
74 | + } | ||
75 | + userIds := lo.Union(resp.WhoRead, resp.WhoReview) | ||
76 | + if len(userIds) > 0 { | ||
77 | + _, users, err := l.svcCtx.UserRepository.Find(l.ctx, l.conn, domain.NewQueryOptions().WithKV("ids", userIds)) | ||
78 | + if err != nil { | ||
79 | + return nil, xerr.NewErrMsgErr("获取帖子异常", err) | ||
80 | + } | ||
81 | + userSlices := make(map[int64]types.UserShowName) | ||
82 | + lo.ForEach(users, func(user *domain.User, index int) { | ||
83 | + userSlices[user.Id] = types.UserShowName{ | ||
84 | + Id: int(user.Id), | ||
85 | + Name: user.Name, | ||
86 | + } | ||
87 | + }) | ||
88 | + lo.ForEach(resp.WhoRead, func(userId int64, index int) { | ||
89 | + if value, ok := userSlices[userId]; ok { | ||
90 | + resp.WhoReadInfo = append(resp.WhoReadInfo, value) | ||
91 | + } | ||
92 | + }) | ||
93 | + lo.ForEach(resp.WhoReview, func(userId int64, index int) { | ||
94 | + if value, ok := userSlices[userId]; ok { | ||
95 | + resp.WhoReviewInfo = append(resp.WhoReviewInfo, value) | ||
96 | + } | ||
97 | + }) | ||
98 | + } | ||
99 | + return | ||
100 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
13 | + | ||
14 | + "github.com/zeromicro/go-zero/core/logx" | ||
15 | +) | ||
16 | + | ||
17 | +type SystemRestoreArticleDeletedLogic struct { | ||
18 | + logx.Logger | ||
19 | + ctx context.Context | ||
20 | + svcCtx *svc.ServiceContext | ||
21 | + conn transaction.Conn | ||
22 | +} | ||
23 | + | ||
24 | +func NewSystemRestoreArticleDeletedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemRestoreArticleDeletedLogic { | ||
25 | + return &SystemRestoreArticleDeletedLogic{ | ||
26 | + Logger: logx.WithContext(ctx), | ||
27 | + ctx: ctx, | ||
28 | + svcCtx: svcCtx, | ||
29 | + conn: svcCtx.DefaultDBConn(), | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +func (l *SystemRestoreArticleDeletedLogic) SystemRestoreArticleDeleted(req *types.SystemArticleDeletedRestoreRequest) (resp *types.SystemArticleDeletedRestoreResponse, err error) { | ||
34 | + // 文章数据 | ||
35 | + article, err := l.svcCtx.ArticleRepository.FindOneWithUnscoped(l.ctx, l.conn, req.Id) | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
38 | + } | ||
39 | + if article.IsDel != 1 { | ||
40 | + return nil, xerr.NewErrMsg("帖子已恢复") | ||
41 | + } | ||
42 | + //文章内容 | ||
43 | + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", req.Id) | ||
44 | + _, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, l.conn, queryOption) | ||
45 | + if err != nil { | ||
46 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
47 | + } | ||
48 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
49 | + if userToken.CompanyId != article.CompanyId { | ||
50 | + return nil, xerr.NewErrMsg("您没有权限") | ||
51 | + } | ||
52 | + // 获取当前用户信息 | ||
53 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
54 | + if err != nil { | ||
55 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
56 | + } | ||
57 | + operator := domain.UserSimple{ | ||
58 | + Id: userToken.UserId, | ||
59 | + Name: userMe.User.NickName, | ||
60 | + Avatar: userMe.User.Avatar, | ||
61 | + CompanyId: userToken.CompanyId, | ||
62 | + Company: userMe.CurrentCompany.Name, | ||
63 | + } | ||
64 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
65 | + //恢复帖子 | ||
66 | + _, err = l.svcCtx.ArticleRepository.Restore(ctx, conn, article) | ||
67 | + if err != nil { | ||
68 | + return err | ||
69 | + } | ||
70 | + //备份 | ||
71 | + var backup domain.ArticleBackup | ||
72 | + backup.MakeBackup(operator, article, sectionList, "恢复") | ||
73 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, conn, &backup) | ||
74 | + if err != nil { | ||
75 | + return xerr.NewErrMsgErr("恢复帖子失败", err) | ||
76 | + } | ||
77 | + return nil | ||
78 | + }, true) | ||
79 | + if err != nil { | ||
80 | + return nil, xerr.NewErrMsg("恢复帖子失败") | ||
81 | + } | ||
82 | + resp = &types.SystemArticleDeletedRestoreResponse{ | ||
83 | + Id: article.Id, | ||
84 | + Title: article.Title, | ||
85 | + AuthorId: article.AuthorId, | ||
86 | + } | ||
87 | + return | ||
88 | +} |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/samber/lo" | ||
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/domain" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
9 | + | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
12 | + | ||
13 | + "github.com/zeromicro/go-zero/core/logx" | ||
14 | +) | ||
15 | + | ||
16 | +type SystemSearchArticleDraftLogic struct { | ||
17 | + logx.Logger | ||
18 | + ctx context.Context | ||
19 | + svcCtx *svc.ServiceContext | ||
20 | + conn transaction.Conn | ||
21 | +} | ||
22 | + | ||
23 | +func NewSystemSearchArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemSearchArticleDraftLogic { | ||
24 | + return &SystemSearchArticleDraftLogic{ | ||
25 | + Logger: logx.WithContext(ctx), | ||
26 | + ctx: ctx, | ||
27 | + svcCtx: svcCtx, | ||
28 | + conn: svcCtx.DefaultDBConn(), | ||
29 | + } | ||
30 | +} | ||
31 | + | ||
32 | +func (l *SystemSearchArticleDraftLogic) SystemSearchArticleDraft(req *types.SystemArticleDraftSearchRequest) (resp *types.SystemArticleDraftSearchResponse, err error) { | ||
33 | + queryOptions := domain.NewQueryOptions(). | ||
34 | + WithOffsetLimit(req.Page, req.Size). | ||
35 | + WithKV("companyId", req.CompanyId). | ||
36 | + WithKV("title", req.Title). | ||
37 | + WithKV("operator", req.Operator). | ||
38 | + WithKV("beginTime", req.BeginTime). | ||
39 | + WithKV("endTime", req.EndTime) | ||
40 | + total, articleDrafts, err := l.svcCtx.ArticleDraftOperationRepository.Find(l.ctx, l.conn, queryOptions) | ||
41 | + if err != nil { | ||
42 | + return nil, xerr.NewErrMsgErr("搜索草稿异常", err) | ||
43 | + } | ||
44 | + resp = &types.SystemArticleDraftSearchResponse{ | ||
45 | + Total: int(total), | ||
46 | + List: make([]types.SystemArticleDraftSearch, 0), | ||
47 | + } | ||
48 | + authorIds := make([]int64, 0) | ||
49 | + lo.ForEach(articleDrafts, func(item *domain.ArticleDraftOperation, index int) { | ||
50 | + authorIds = append(authorIds, item.AuthorId) | ||
51 | + }) | ||
52 | + //查询用户数据,重新赋值更新用户名称 | ||
53 | + _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, l.conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds)) | ||
54 | + lo.ForEach(articleDrafts, func(item *domain.ArticleDraftOperation, index int) { | ||
55 | + //图片 | ||
56 | + images := make([]string, 0) | ||
57 | + lo.ForEach(item.Images, func(img domain.Image, n int) { | ||
58 | + images = append(images, img.Url) | ||
59 | + }) | ||
60 | + //发布人 | ||
61 | + author := "" | ||
62 | + for _, user := range users { | ||
63 | + if user.Id == item.AuthorId { | ||
64 | + author = user.Name | ||
65 | + } | ||
66 | + } | ||
67 | + resp.List = append(resp.List, types.SystemArticleDraftSearch{ | ||
68 | + Id: item.Id, | ||
69 | + Title: item.Title, | ||
70 | + Images: images, | ||
71 | + Operator: item.Operator.Name, | ||
72 | + AuthorId: item.AuthorId, | ||
73 | + Author: author, | ||
74 | + UpdatedAt: item.UpdatedAt, | ||
75 | + }) | ||
76 | + }) | ||
77 | + return | ||
78 | +} |
@@ -82,11 +82,17 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | @@ -82,11 +82,17 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | ||
82 | Author: author, | 82 | Author: author, |
83 | Images: images, | 83 | Images: images, |
84 | CreatedAt: item.CreatedAt, | 84 | CreatedAt: item.CreatedAt, |
85 | + UpdatedAt: item.UpdatedAt, | ||
85 | CountLove: item.CountLove, | 86 | CountLove: item.CountLove, |
86 | CountComment: item.CountComment, | 87 | CountComment: item.CountComment, |
87 | Show: int(item.Show), | 88 | Show: int(item.Show), |
88 | Tags: articleTags, | 89 | Tags: articleTags, |
89 | TargetUser: int(item.TargetUser), | 90 | TargetUser: int(item.TargetUser), |
91 | + Source: item.Source, | ||
92 | + Operator: types.Operator{ | ||
93 | + Id: item.Operator.Id, | ||
94 | + Name: item.Operator.Name, | ||
95 | + }, | ||
90 | }) | 96 | }) |
91 | }) | 97 | }) |
92 | return | 98 | return |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
13 | + | ||
14 | + "github.com/zeromicro/go-zero/core/logx" | ||
15 | +) | ||
16 | + | ||
17 | +type SystemUpdateArticleDraftLogic struct { | ||
18 | + logx.Logger | ||
19 | + ctx context.Context | ||
20 | + svcCtx *svc.ServiceContext | ||
21 | + conn transaction.Conn | ||
22 | +} | ||
23 | + | ||
24 | +func NewSystemUpdateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUpdateArticleDraftLogic { | ||
25 | + return &SystemUpdateArticleDraftLogic{ | ||
26 | + Logger: logx.WithContext(ctx), | ||
27 | + ctx: ctx, | ||
28 | + svcCtx: svcCtx, | ||
29 | + conn: svcCtx.DefaultDBConn(), | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +func (l *SystemUpdateArticleDraftLogic) SystemUpdateArticleDraft(req *types.SystemArticleDraftUpdateRequest) (resp *types.SystemArticleDraftUpdateResponse, err error) { | ||
34 | + // 草稿数据 | ||
35 | + articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id) | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsgErr("草稿不存在", err) | ||
38 | + } | ||
39 | + articleDraft.Title = req.Title | ||
40 | + articleDraft.Content = req.Content | ||
41 | + articleDraft.AuthorId = req.AuthorId | ||
42 | + articleDraft.TargetUser = domain.ArticleTarget(req.TargetUser) | ||
43 | + articleDraft.WhoRead = req.WhoRead | ||
44 | + articleDraft.WhoReview = req.WhoReview | ||
45 | + articleDraft.Tags = req.Tags | ||
46 | + articleDraft.Source = domain.ArticleSourceOperator | ||
47 | + articleDraft.MatchUrl = req.MatchUrl | ||
48 | + //图片 | ||
49 | + images, err := getImages(req.Images) | ||
50 | + if err != nil { | ||
51 | + return nil, xerr.NewErrMsg(err.Error()) | ||
52 | + } | ||
53 | + articleDraft.Images = images | ||
54 | + //视频 | ||
55 | + videos, err := getVideos(req.Videos) | ||
56 | + if err != nil { | ||
57 | + return nil, xerr.NewErrMsg(err.Error()) | ||
58 | + } | ||
59 | + articleDraft.Videos = videos | ||
60 | + //操作人 | ||
61 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
62 | + // 获取当前用户信息 | ||
63 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
64 | + if err != nil { | ||
65 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
66 | + } | ||
67 | + articleDraft.Operator = domain.Operator{ | ||
68 | + Id: userToken.UserId, | ||
69 | + Name: userMe.User.NickName, | ||
70 | + } | ||
71 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
72 | + _, err := l.svcCtx.ArticleDraftOperationRepository.Update(ctx, conn, articleDraft) | ||
73 | + if err != nil { | ||
74 | + return err | ||
75 | + } | ||
76 | + return nil | ||
77 | + }, true) | ||
78 | + if err != nil { | ||
79 | + return nil, xerr.NewErrMsg("保存草稿失败") | ||
80 | + } | ||
81 | + resp = &types.SystemArticleDraftUpdateResponse{ | ||
82 | + Id: articleDraft.Id, | ||
83 | + Title: articleDraft.Title, | ||
84 | + Content: articleDraft.Content, | ||
85 | + AuthorId: articleDraft.AuthorId, | ||
86 | + Images: req.Images, | ||
87 | + Videos: req.Videos, | ||
88 | + TargetUser: int(articleDraft.TargetUser), | ||
89 | + WhoRead: articleDraft.WhoRead, | ||
90 | + WhoReview: articleDraft.WhoReview, | ||
91 | + MatchUrl: articleDraft.MatchUrl, | ||
92 | + Tags: articleDraft.Tags, | ||
93 | + } | ||
94 | + return | ||
95 | +} |
@@ -32,7 +32,7 @@ func NewMiniQrcodeInviteLogic(ctx context.Context, svcCtx *svc.ServiceContext) * | @@ -32,7 +32,7 @@ func NewMiniQrcodeInviteLogic(ctx context.Context, svcCtx *svc.ServiceContext) * | ||
32 | 32 | ||
33 | func (l *MiniQrcodeInviteLogic) MiniQrcodeInvite(req *types.MiniQrCodeRequest) (resp interface{}, err error) { | 33 | func (l *MiniQrcodeInviteLogic) MiniQrcodeInvite(req *types.MiniQrCodeRequest) (resp interface{}, err error) { |
34 | var ( | 34 | var ( |
35 | - q = l.svcCtx.MiniProgram.GetQRCode() | 35 | + q = l.svcCtx.GetMiniProgram().GetQRCode() |
36 | cacheData = fmt.Sprintf("%s?%s", req.Page, req.Scene) | 36 | cacheData = fmt.Sprintf("%s?%s", req.Page, req.Scene) |
37 | cacheKey = fmt.Sprintf("%s:qrcode:%s", l.svcCtx.Config.Name, tool.Md5ByString(cacheData)) | 37 | cacheKey = fmt.Sprintf("%s:qrcode:%s", l.svcCtx.Config.Name, tool.Md5ByString(cacheData)) |
38 | ok bool | 38 | ok bool |
@@ -56,7 +56,7 @@ func (l *MiniQrcodeInviteLogic) MiniQrcodeInvite(req *types.MiniQrCodeRequest) ( | @@ -56,7 +56,7 @@ func (l *MiniQrcodeInviteLogic) MiniQrcodeInvite(req *types.MiniQrCodeRequest) ( | ||
56 | Path: req.Page, | 56 | Path: req.Page, |
57 | Scene: req.Scene, | 57 | Scene: req.Scene, |
58 | CheckPath: lo.ToPtr(false), | 58 | CheckPath: lo.ToPtr(false), |
59 | - EnvVersion: "release", | 59 | + EnvVersion: l.svcCtx.Config.Wechat.QrcodeEnv, |
60 | }) | 60 | }) |
61 | if err != nil { | 61 | if err != nil { |
62 | return nil, xerr.NewErr(err) | 62 | return nil, xerr.NewErr(err) |
@@ -91,6 +91,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan | @@ -91,6 +91,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan | ||
91 | if lo.Contains(companyJoiningList, company.Id) { | 91 | if lo.Contains(companyJoiningList, company.Id) { |
92 | company.JoinedFlag = 0 | 92 | company.JoinedFlag = 0 |
93 | } | 93 | } |
94 | + // 过滤掉不可见且未加入的企业。 | ||
95 | + if company.JoinedFlag != 1 && item.Visible == 0 { | ||
96 | + return | ||
97 | + } | ||
94 | resp.List = append(resp.List, company) | 98 | resp.List = append(resp.List, company) |
95 | }) | 99 | }) |
96 | resp.Total = total | 100 | resp.Total = total |
@@ -38,6 +38,7 @@ func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchReque | @@ -38,6 +38,7 @@ func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchReque | ||
38 | if req.Code != "" { | 38 | if req.Code != "" { |
39 | queryOptions.WithKV("code", req.Code) | 39 | queryOptions.WithKV("code", req.Code) |
40 | } | 40 | } |
41 | + queryOptions.MustWithKV("visible", 1) | ||
41 | total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions) | 42 | total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions) |
42 | if err != nil { | 43 | if err != nil { |
43 | return nil, xerr.NewErrMsgErr("公司列表获取失败", err) | 44 | return nil, xerr.NewErrMsgErr("公司列表获取失败", err) |
1 | +package company | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/samber/lo" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
9 | + | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
12 | + | ||
13 | + "github.com/zeromicro/go-zero/core/logx" | ||
14 | +) | ||
15 | + | ||
16 | +type SystemCompanyVisibleSwitchLogic struct { | ||
17 | + logx.Logger | ||
18 | + ctx context.Context | ||
19 | + svcCtx *svc.ServiceContext | ||
20 | +} | ||
21 | + | ||
22 | +func NewSystemCompanyVisibleSwitchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCompanyVisibleSwitchLogic { | ||
23 | + return &SystemCompanyVisibleSwitchLogic{ | ||
24 | + Logger: logx.WithContext(ctx), | ||
25 | + ctx: ctx, | ||
26 | + svcCtx: svcCtx, | ||
27 | + } | ||
28 | +} | ||
29 | + | ||
30 | +func (l *SystemCompanyVisibleSwitchLogic) SystemCompanyVisibleSwitch(req *types.CompanyVisibleSwitchRequest) (resp *types.CompanyVisibleSwitchResponse, err error) { | ||
31 | + var ( | ||
32 | + conn = l.svcCtx.DefaultDBConn() | ||
33 | + company *domain.Company | ||
34 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
35 | + ) | ||
36 | + if company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId); err != nil { | ||
37 | + return nil, xerr.NewErrMsg("设置失败") | ||
38 | + } | ||
39 | + company.Visible = lo.Ternary(req.Visible, 1, 0) | ||
40 | + if company, err = l.svcCtx.CompanyRepository.UpdateWithVersion(l.ctx, conn, company); err != nil { | ||
41 | + return nil, xerr.NewErrMsg("设置失败") | ||
42 | + } | ||
43 | + resp = &types.CompanyVisibleSwitchResponse{} | ||
44 | + return | ||
45 | +} |
@@ -39,6 +39,17 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty | @@ -39,6 +39,17 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty | ||
39 | Total: total, | 39 | Total: total, |
40 | List: make([]types.Department, 0), | 40 | List: make([]types.Department, 0), |
41 | } | 41 | } |
42 | + if req.IncludeRootCompany { | ||
43 | + company, _ := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId) | ||
44 | + if company != nil { | ||
45 | + resp.List = append(resp.List, types.Department{ | ||
46 | + Id: 0, | ||
47 | + CompanyId: company.Id, | ||
48 | + ParentId: -1, | ||
49 | + Name: company.Name, | ||
50 | + }) | ||
51 | + } | ||
52 | + } | ||
42 | for _, item := range list { | 53 | for _, item := range list { |
43 | to := types.Department{ | 54 | to := types.Department{ |
44 | Id: item.Id, | 55 | Id: item.Id, |
@@ -57,6 +57,11 @@ func (l *MiniSystemLogic) ArticleDefined(conn transaction.Conn, companyId, at in | @@ -57,6 +57,11 @@ func (l *MiniSystemLogic) ArticleDefined(conn transaction.Conn, companyId, at in | ||
57 | return l.createMessage(conn, companyId, at, domain.MsgTypeNormal, "帖子已定性", fmt.Sprintf("您的帖子[%s]已被定性,如有疑问,请联系运营管理员了解详情。", item)) | 57 | return l.createMessage(conn, companyId, at, domain.MsgTypeNormal, "帖子已定性", fmt.Sprintf("您的帖子[%s]已被定性,如有疑问,请联系运营管理员了解详情。", item)) |
58 | } | 58 | } |
59 | 59 | ||
60 | +// ArticleDeleted 帖子删除 | ||
61 | +func (l *MiniSystemLogic) ArticleDeleted(conn transaction.Conn, companyId, at int64, createdTime, title string) (err error) { | ||
62 | + return l.createMessage(conn, companyId, at, domain.MsgTypeDeleted, "帖子已删除", fmt.Sprintf("你于%v发布的帖子[%v]已被删除,如有疑问,请联系运营管理员了解详情。", createdTime, title)) | ||
63 | +} | ||
64 | + | ||
60 | //// ArticleAuth 文章权限变更 | 65 | //// ArticleAuth 文章权限变更 |
61 | //func (l *MiniSystemLogic) ArticleAuth(conn transaction.Conn, companyId, at int64, item string) (err error) { | 66 | //func (l *MiniSystemLogic) ArticleAuth(conn transaction.Conn, companyId, at int64, item string) (err error) { |
62 | // return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "权限变更", fmt.Sprintf("您的帖子[%s]可见权限已添加,如有疑问,请联系运营管理员了解详情。", item)) | 67 | // return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "权限变更", fmt.Sprintf("您的帖子[%s]可见权限已添加,如有疑问,请联系运营管理员了解详情。", item)) |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + | ||
6 | + "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" | ||
8 | + | ||
9 | + "github.com/zeromicro/go-zero/core/logx" | ||
10 | +) | ||
11 | + | ||
12 | +type ArticleCategoryDeleteLogic struct { | ||
13 | + logx.Logger | ||
14 | + ctx context.Context | ||
15 | + svcCtx *svc.ServiceContext | ||
16 | +} | ||
17 | + | ||
18 | +func NewArticleCategoryDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryDeleteLogic { | ||
19 | + return &ArticleCategoryDeleteLogic{ | ||
20 | + Logger: logx.WithContext(ctx), | ||
21 | + ctx: ctx, | ||
22 | + svcCtx: svcCtx, | ||
23 | + } | ||
24 | +} | ||
25 | + | ||
26 | +func (l *ArticleCategoryDeleteLogic) ArticleCategoryDelete(req *types.ArticleCategoryDeleteRequest) (resp *types.ArticleCategoryDeleteResponse, err error) { | ||
27 | + // todo: add your logic here and delete this line | ||
28 | + | ||
29 | + return | ||
30 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
7 | + | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | + | ||
11 | + "github.com/zeromicro/go-zero/core/logx" | ||
12 | +) | ||
13 | + | ||
14 | +type ArticleCategoryGetLogic struct { | ||
15 | + logx.Logger | ||
16 | + ctx context.Context | ||
17 | + svcCtx *svc.ServiceContext | ||
18 | +} | ||
19 | + | ||
20 | +func NewArticleCategoryGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryGetLogic { | ||
21 | + return &ArticleCategoryGetLogic{ | ||
22 | + Logger: logx.WithContext(ctx), | ||
23 | + ctx: ctx, | ||
24 | + svcCtx: svcCtx, | ||
25 | + } | ||
26 | +} | ||
27 | + | ||
28 | +func (l *ArticleCategoryGetLogic) ArticleCategoryGet(req *types.ArticleCategoryGetRequest) (resp *types.ArticleCategoryGetResponse, err error) { | ||
29 | + var ( | ||
30 | + conn = l.svcCtx.DefaultDBConn() | ||
31 | + dm *domain.ArticleCategory | ||
32 | + ) | ||
33 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
34 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
35 | + } | ||
36 | + resp = &types.ArticleCategoryGetResponse{ | ||
37 | + ArticleCategory: NewTypesArticleCategory(dm), | ||
38 | + } | ||
39 | + return | ||
40 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + "github.com/zeromicro/go-zero/core/logx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
11 | +) | ||
12 | + | ||
13 | +type ArticleCategoryInitLogic struct { | ||
14 | + logx.Logger | ||
15 | + ctx context.Context | ||
16 | + svcCtx *svc.ServiceContext | ||
17 | +} | ||
18 | + | ||
19 | +func NewArticleCategoryInitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryInitLogic { | ||
20 | + return &ArticleCategoryInitLogic{ | ||
21 | + Logger: logx.WithContext(ctx), | ||
22 | + ctx: ctx, | ||
23 | + svcCtx: svcCtx, | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +func (l *ArticleCategoryInitLogic) ArticleCategoryInit() error { | ||
28 | + var ( | ||
29 | + conn = l.svcCtx.DefaultDBConn() | ||
30 | + companyList []*domain.Company | ||
31 | + categoryList = []*domain.ArticleCategory{ | ||
32 | + { | ||
33 | + Name: "机会风险", | ||
34 | + SortBy: 1, | ||
35 | + Enable: 1, | ||
36 | + Other: "", | ||
37 | + }, | ||
38 | + { | ||
39 | + Name: "紧急重要", | ||
40 | + SortBy: 2, | ||
41 | + Enable: 2, | ||
42 | + Other: "", | ||
43 | + }, | ||
44 | + } | ||
45 | + dm *domain.ArticleCategory | ||
46 | + err error | ||
47 | + ) | ||
48 | + | ||
49 | + _, companyList, _ = l.svcCtx.CompanyRepository.Find(l.ctx, conn, domain.NewQueryOptions()) | ||
50 | + for _, company := range companyList { | ||
51 | + for _, category := range categoryList { | ||
52 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, company.Id, category.Name); err == nil && dm != nil { | ||
53 | + continue | ||
54 | + } | ||
55 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
56 | + articleCategory := &domain.ArticleCategory{ | ||
57 | + Name: category.Name, | ||
58 | + SortBy: category.SortBy, | ||
59 | + Enable: category.Enable, | ||
60 | + Other: category.Other, | ||
61 | + CompanyId: company.Id, | ||
62 | + } | ||
63 | + articleCategory, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, articleCategory) | ||
64 | + if err != nil { | ||
65 | + return err | ||
66 | + } | ||
67 | + _, tagList, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, company.Id, domain.NewQueryOptions().WithKV("category", articleCategory.Name)) | ||
68 | + for _, tag := range tagList { | ||
69 | + if tag.CategoryId != 0 { | ||
70 | + continue | ||
71 | + } | ||
72 | + tag.CategoryId = articleCategory.Id | ||
73 | + if _, err = l.svcCtx.ArticleTagRepository.UpdateWithVersion(l.ctx, conn, tag); err != nil { | ||
74 | + break | ||
75 | + } | ||
76 | + } | ||
77 | + logx.Info(fmt.Sprintf("初始化 公司:%v(%d) 标签分类:%v(%d) 标签数:%v", company.Name, company.Id, articleCategory.Name, articleCategory.Id, len(tagList))) | ||
78 | + return err | ||
79 | + }, true); err != nil { | ||
80 | + return xerr.NewErrMsg("保存失败") | ||
81 | + } | ||
82 | + } | ||
83 | + } | ||
84 | + return nil | ||
85 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
7 | + | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | + | ||
11 | + "github.com/zeromicro/go-zero/core/logx" | ||
12 | +) | ||
13 | + | ||
14 | +type ArticleCategoryOptionsLogic struct { | ||
15 | + logx.Logger | ||
16 | + ctx context.Context | ||
17 | + svcCtx *svc.ServiceContext | ||
18 | +} | ||
19 | + | ||
20 | +func NewArticleCategoryOptionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryOptionsLogic { | ||
21 | + return &ArticleCategoryOptionsLogic{ | ||
22 | + Logger: logx.WithContext(ctx), | ||
23 | + ctx: ctx, | ||
24 | + svcCtx: svcCtx, | ||
25 | + } | ||
26 | +} | ||
27 | + | ||
28 | +func (l *ArticleCategoryOptionsLogic) ArticleCategoryOptions(req *types.CategoryOptionsRequest) (resp *types.CategoryOptionsResponse, err error) { | ||
29 | + var ( | ||
30 | + conn = l.svcCtx.DefaultDBConn() | ||
31 | + dms []*domain.ArticleCategory | ||
32 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
33 | + ) | ||
34 | + | ||
35 | + queryOptions := domain.NewQueryOptions().WithKV("enable", req.Enable) | ||
36 | + | ||
37 | + _, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions) | ||
38 | + list := make([]types.CategoryOptions, 0) | ||
39 | + for _, item := range dms { | ||
40 | + list = append(list, types.CategoryOptions{ | ||
41 | + Label: item.Name, | ||
42 | + Value: item.Id, | ||
43 | + Enable: item.Enable, | ||
44 | + }) | ||
45 | + } | ||
46 | + resp = &types.CategoryOptionsResponse{ | ||
47 | + Options: list, | ||
48 | + } | ||
49 | + return | ||
50 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
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/domain" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
13 | + | ||
14 | + "github.com/zeromicro/go-zero/core/logx" | ||
15 | +) | ||
16 | + | ||
17 | +type ArticleCategorySaveLogic struct { | ||
18 | + logx.Logger | ||
19 | + ctx context.Context | ||
20 | + svcCtx *svc.ServiceContext | ||
21 | +} | ||
22 | + | ||
23 | +func NewArticleCategorySaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategorySaveLogic { | ||
24 | + return &ArticleCategorySaveLogic{ | ||
25 | + Logger: logx.WithContext(ctx), | ||
26 | + ctx: ctx, | ||
27 | + svcCtx: svcCtx, | ||
28 | + } | ||
29 | +} | ||
30 | + | ||
31 | +func (l *ArticleCategorySaveLogic) ArticleCategorySave(req *types.ArticleCategorySaveRequest) (resp *types.ArticleCategorySaveResponse, err error) { | ||
32 | + var ( | ||
33 | + conn = l.svcCtx.DefaultDBConn() | ||
34 | + dm *domain.ArticleCategory | ||
35 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
36 | + ) | ||
37 | + // 唯一判断 | ||
38 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, userToken.CompanyId, req.ArticleCategory.Name); err == nil && dm != nil { | ||
39 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在分类`%s`", dm.Name)) | ||
40 | + } | ||
41 | + | ||
42 | + dm = NewDomainArticleCategory(req.ArticleCategory) | ||
43 | + dm.CompanyId = userToken.CompanyId | ||
44 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
45 | + dm, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, dm) | ||
46 | + return err | ||
47 | + }, true); err != nil { | ||
48 | + return nil, xerr.NewErrMsg("保存失败") | ||
49 | + } | ||
50 | + resp = &types.ArticleCategorySaveResponse{} | ||
51 | + return | ||
52 | +} | ||
53 | +func NewDomainArticleCategory(item types.ArticleCategoryItem) *domain.ArticleCategory { | ||
54 | + return &domain.ArticleCategory{ | ||
55 | + Name: item.Name, | ||
56 | + Enable: item.Enable, | ||
57 | + SortBy: item.SortBy, | ||
58 | + Other: item.Other, | ||
59 | + } | ||
60 | +} | ||
61 | + | ||
62 | +func NewTypesArticleCategory(item *domain.ArticleCategory) types.ArticleCategoryItem { | ||
63 | + return types.ArticleCategoryItem{ | ||
64 | + Id: item.Id, | ||
65 | + Name: item.Name, | ||
66 | + Enable: item.Enable, | ||
67 | + SortBy: item.SortBy, | ||
68 | + Other: item.Other, | ||
69 | + } | ||
70 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
7 | + | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | + | ||
11 | + "github.com/zeromicro/go-zero/core/logx" | ||
12 | +) | ||
13 | + | ||
14 | +type ArticleCategorySearchLogic struct { | ||
15 | + logx.Logger | ||
16 | + ctx context.Context | ||
17 | + svcCtx *svc.ServiceContext | ||
18 | +} | ||
19 | + | ||
20 | +func NewArticleCategorySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategorySearchLogic { | ||
21 | + return &ArticleCategorySearchLogic{ | ||
22 | + Logger: logx.WithContext(ctx), | ||
23 | + ctx: ctx, | ||
24 | + svcCtx: svcCtx, | ||
25 | + } | ||
26 | +} | ||
27 | + | ||
28 | +func (l *ArticleCategorySearchLogic) ArticleCategorySearch(req *types.ArticleCategorySearchRequest) (resp *types.ArticleCategorySearchResponse, err error) { | ||
29 | + var ( | ||
30 | + conn = l.svcCtx.DefaultDBConn() | ||
31 | + dms []*domain.ArticleCategory | ||
32 | + total int64 | ||
33 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
34 | + ) | ||
35 | + | ||
36 | + queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) | ||
37 | + | ||
38 | + total, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions) | ||
39 | + list := make([]types.ArticleCategoryItem, 0) | ||
40 | + for _, item := range dms { | ||
41 | + list = append(list, NewTypesArticleCategory(item)) | ||
42 | + } | ||
43 | + resp = &types.ArticleCategorySearchResponse{ | ||
44 | + List: list, | ||
45 | + Total: total, | ||
46 | + } | ||
47 | + return | ||
48 | +} |
1 | +package tags | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
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/domain" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
13 | + | ||
14 | + "github.com/zeromicro/go-zero/core/logx" | ||
15 | +) | ||
16 | + | ||
17 | +type ArticleCategoryUpdateLogic struct { | ||
18 | + logx.Logger | ||
19 | + ctx context.Context | ||
20 | + svcCtx *svc.ServiceContext | ||
21 | +} | ||
22 | + | ||
23 | +func NewArticleCategoryUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryUpdateLogic { | ||
24 | + return &ArticleCategoryUpdateLogic{ | ||
25 | + Logger: logx.WithContext(ctx), | ||
26 | + ctx: ctx, | ||
27 | + svcCtx: svcCtx, | ||
28 | + } | ||
29 | +} | ||
30 | + | ||
31 | +func (l *ArticleCategoryUpdateLogic) ArticleCategoryUpdate(req *types.ArticleCategoryUpdateRequest) (resp *types.ArticleCategoryUpdateResponse, err error) { | ||
32 | + var ( | ||
33 | + conn = l.svcCtx.DefaultDBConn() | ||
34 | + dm *domain.ArticleCategory | ||
35 | + dupDm *domain.ArticleCategory | ||
36 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
37 | + changeName = false | ||
38 | + ) | ||
39 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
40 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
41 | + } | ||
42 | + // 不可编辑判断 | ||
43 | + if dm.Name != req.ArticleCategory.Name { | ||
44 | + if dupDm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, userToken.CompanyId, req.ArticleCategory.Name); err == nil && dupDm != nil { | ||
45 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在分类`%s`", dupDm.Name)) | ||
46 | + } | ||
47 | + changeName = true | ||
48 | + } | ||
49 | + | ||
50 | + // 更新 | ||
51 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
52 | + // 同步标签的分类名称 | ||
53 | + if changeName { | ||
54 | + _, articleTags, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions().MustWithKV("categoryId", dm.Id)) | ||
55 | + for _, articleTag := range articleTags { | ||
56 | + if articleTag.CategoryId != dm.Id { | ||
57 | + continue | ||
58 | + } | ||
59 | + // 新的分类名称 | ||
60 | + articleTag.Category = req.ArticleCategory.Name | ||
61 | + if _, err = l.svcCtx.ArticleTagRepository.UpdateWithVersion(l.ctx, conn, articleTag); err != nil { | ||
62 | + return err | ||
63 | + } | ||
64 | + } | ||
65 | + } | ||
66 | + // 赋值 | ||
67 | + dm.Name = req.ArticleCategory.Name | ||
68 | + dm.SortBy = req.ArticleCategory.SortBy | ||
69 | + dm.Enable = req.ArticleCategory.Enable | ||
70 | + dm.Other = req.ArticleCategory.Other | ||
71 | + dm, err = l.svcCtx.ArticleCategoryRepository.UpdateWithVersion(l.ctx, conn, dm) | ||
72 | + return err | ||
73 | + }, true); err != nil { | ||
74 | + return nil, xerr.NewErrMsg("更新失败") | ||
75 | + } | ||
76 | + resp = &types.ArticleCategoryUpdateResponse{} | ||
77 | + return | ||
78 | +} |
@@ -30,18 +30,24 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT | @@ -30,18 +30,24 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT | ||
30 | 30 | ||
31 | // 创建标签 | 31 | // 创建标签 |
32 | func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) { | 32 | func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) { |
33 | - var conn = l.svcCtx.DefaultDBConn() | 33 | + var ( |
34 | + conn = l.svcCtx.DefaultDBConn() | ||
35 | + articleCategory *domain.ArticleCategory | ||
36 | + ) | ||
37 | + if articleCategory, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.CategoryId); err != nil { | ||
38 | + return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
39 | + } | ||
34 | //检查重复 | 40 | //检查重复 |
35 | cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{ | 41 | cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{ |
36 | "name": req.Name, | 42 | "name": req.Name, |
37 | - "category": req.Category, | 43 | + "categoryId": req.CategoryId, |
38 | "countOnly": true, | 44 | "countOnly": true, |
39 | }) | 45 | }) |
40 | if err != nil { | 46 | if err != nil { |
41 | return nil, xerr.NewErrMsgErr("添加标签失败", err) | 47 | return nil, xerr.NewErrMsgErr("添加标签失败", err) |
42 | } | 48 | } |
43 | if cnt > 0 { | 49 | if cnt > 0 { |
44 | - return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name)) | 50 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", articleCategory.Name, req.Name)) |
45 | } | 51 | } |
46 | 52 | ||
47 | newTag := &domain.ArticleTag{ | 53 | newTag := &domain.ArticleTag{ |
@@ -53,15 +59,17 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | @@ -53,15 +59,17 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | ||
53 | Version: 0, | 59 | Version: 0, |
54 | Image: domain.Image{}, | 60 | Image: domain.Image{}, |
55 | Name: req.Name, | 61 | Name: req.Name, |
56 | - Category: req.Category, | 62 | + Category: articleCategory.Name, |
63 | + CategoryId: articleCategory.Id, | ||
57 | Remark: req.Remark, | 64 | Remark: req.Remark, |
58 | Other: req.Other, | 65 | Other: req.Other, |
59 | SortBy: int64(req.SortBy), | 66 | SortBy: int64(req.SortBy), |
67 | + DataFrom: 1, | ||
60 | } | 68 | } |
61 | - err = newTag.SetCategory(req.Category) | ||
62 | - if err != nil { | ||
63 | - return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
64 | - } | 69 | + //err = newTag.SetCategory(req.Category) |
70 | + //if err != nil { | ||
71 | + // return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
72 | + //} | ||
65 | if len(req.Image) > 0 { | 73 | if len(req.Image) > 0 { |
66 | //获取图片的尺寸大小 | 74 | //获取图片的尺寸大小 |
67 | fInfo, _ := oss.GetImageInfo(req.Image) | 75 | fInfo, _ := oss.GetImageInfo(req.Image) |
@@ -33,6 +33,9 @@ func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.Tag | @@ -33,6 +33,9 @@ func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.Tag | ||
33 | if oldTag.CompanyId != req.CompanyId { | 33 | if oldTag.CompanyId != req.CompanyId { |
34 | return nil, xerr.NewErrMsg("删除标签失败") | 34 | return nil, xerr.NewErrMsg("删除标签失败") |
35 | } | 35 | } |
36 | + if oldTag.DataFrom == 0 { | ||
37 | + return nil, xerr.NewErrMsg("系统标签不可删除") | ||
38 | + } | ||
36 | _, err = l.svcCtx.ArticleTagRepository.Delete(l.ctx, conn, oldTag) | 39 | _, err = l.svcCtx.ArticleTagRepository.Delete(l.ctx, conn, oldTag) |
37 | if err != nil { | 40 | if err != nil { |
38 | return nil, xerr.NewErrMsg("删除标签失败") | 41 | return nil, xerr.NewErrMsg("删除标签失败") |
@@ -30,21 +30,26 @@ func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLo | @@ -30,21 +30,26 @@ func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLo | ||
30 | 30 | ||
31 | // 编辑标签 | 31 | // 编辑标签 |
32 | func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) { | 32 | func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) { |
33 | - var conn = l.svcCtx.DefaultDBConn() | 33 | + var ( |
34 | + conn = l.svcCtx.DefaultDBConn() | ||
35 | + articleCategory *domain.ArticleCategory | ||
36 | + ) | ||
34 | //检查重复 | 37 | //检查重复 |
35 | queryOptions := domain.NewQueryOptions(). | 38 | queryOptions := domain.NewQueryOptions(). |
36 | WithFindOnly(). | 39 | WithFindOnly(). |
37 | MustWithKV("name", req.Name). | 40 | MustWithKV("name", req.Name). |
38 | - MustWithKV("category", req.Category). | 41 | + MustWithKV("categoryId", req.CategoryId). |
39 | WithOffsetLimit(1, 1) | 42 | WithOffsetLimit(1, 1) |
40 | - | 43 | + if articleCategory, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.CategoryId); err != nil { |
44 | + return nil, xerr.NewErrMsgErr("标签分类不存在失败", err) | ||
45 | + } | ||
41 | _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) | 46 | _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) |
42 | if err != nil { | 47 | if err != nil { |
43 | return nil, xerr.NewErrMsgErr("修改标签失败", err) | 48 | return nil, xerr.NewErrMsgErr("修改标签失败", err) |
44 | } | 49 | } |
45 | if len(tagList) > 0 { | 50 | if len(tagList) > 0 { |
46 | if tagList[0].Id != req.Id { | 51 | if tagList[0].Id != req.Id { |
47 | - return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name)) | 52 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", articleCategory.Name, req.Name)) |
48 | } | 53 | } |
49 | } | 54 | } |
50 | oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) | 55 | oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) |
@@ -66,15 +71,16 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe | @@ -66,15 +71,16 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe | ||
66 | Height: h, | 71 | Height: h, |
67 | } | 72 | } |
68 | } | 73 | } |
69 | - oldTag.Category = req.Category | ||
70 | oldTag.Name = req.Name | 74 | oldTag.Name = req.Name |
71 | oldTag.Remark = req.Remark | 75 | oldTag.Remark = req.Remark |
72 | oldTag.Other = req.Other | 76 | oldTag.Other = req.Other |
73 | oldTag.SortBy = int64(req.SortBy) | 77 | oldTag.SortBy = int64(req.SortBy) |
74 | - err = oldTag.SetCategory(req.Category) | ||
75 | - if err != nil { | ||
76 | - return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
77 | - } | 78 | + oldTag.CategoryId = articleCategory.Id |
79 | + oldTag.Category = articleCategory.Name | ||
80 | + //err = oldTag.SetCategory(req.Category) | ||
81 | + //if err != nil { | ||
82 | + // return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
83 | + //} | ||
78 | oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag) | 84 | oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag) |
79 | if err != nil { | 85 | if err != nil { |
80 | return nil, xerr.NewErrMsgErr("添加标签失败", err) | 86 | return nil, xerr.NewErrMsgErr("添加标签失败", err) |
@@ -39,6 +39,7 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon | @@ -39,6 +39,7 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon | ||
39 | Image: oldTag.Image.Url, | 39 | Image: oldTag.Image.Url, |
40 | Name: oldTag.Name, | 40 | Name: oldTag.Name, |
41 | Category: oldTag.Category, | 41 | Category: oldTag.Category, |
42 | + CategoryId: oldTag.CategoryId, | ||
42 | Remark: oldTag.Remark, | 43 | Remark: oldTag.Remark, |
43 | Other: oldTag.Other, | 44 | Other: oldTag.Other, |
44 | SortBy: int(oldTag.SortBy), | 45 | SortBy: int(oldTag.SortBy), |
@@ -24,11 +24,14 @@ func NewSearchTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchT | @@ -24,11 +24,14 @@ func NewSearchTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchT | ||
24 | } | 24 | } |
25 | 25 | ||
26 | func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagListResponse, err error) { | 26 | func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagListResponse, err error) { |
27 | - var conn = l.svcCtx.DefaultDBConn() | 27 | + var ( |
28 | + conn = l.svcCtx.DefaultDBConn() | ||
29 | + categoryMap = make(map[int64]*domain.ArticleCategory) | ||
30 | + ) | ||
28 | queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) | 31 | queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) |
29 | 32 | ||
30 | - if len(req.Category) > 0 { | ||
31 | - queryOptions = queryOptions.MustWithKV("category", "%"+req.Category+"%") | 33 | + if req.CategoryId > 0 { |
34 | + queryOptions = queryOptions.MustWithKV("categoryId", req.CategoryId) | ||
32 | } | 35 | } |
33 | if len(req.TagName) > 0 { | 36 | if len(req.TagName) > 0 { |
34 | queryOptions = queryOptions.MustWithKV("name", "%"+req.TagName+"%") | 37 | queryOptions = queryOptions.MustWithKV("name", "%"+req.TagName+"%") |
@@ -51,9 +54,14 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi | @@ -51,9 +54,14 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi | ||
51 | Image: tagList[i].Image.Url, | 54 | Image: tagList[i].Image.Url, |
52 | Name: tagList[i].Name, | 55 | Name: tagList[i].Name, |
53 | Category: tagList[i].Category, | 56 | Category: tagList[i].Category, |
57 | + CategoryId: tagList[i].CategoryId, | ||
54 | Remark: tagList[i].Remark, | 58 | Remark: tagList[i].Remark, |
55 | CreatedAt: tagList[i].CreatedAt, | 59 | CreatedAt: tagList[i].CreatedAt, |
56 | SortBy: int(tagList[i].SortBy), | 60 | SortBy: int(tagList[i].SortBy), |
61 | + Removeable: tagList[i].DataFrom != 0, | ||
62 | + } | ||
63 | + if category, _ := domain.LazyLoad(categoryMap, l.ctx, conn, tagList[i].CategoryId, l.svcCtx.ArticleCategoryRepository.FindOne); category != nil { | ||
64 | + resp.List[i].Category = category.Name | ||
57 | } | 65 | } |
58 | } | 66 | } |
59 | return resp, nil | 67 | return resp, nil |
@@ -43,10 +43,15 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) | @@ -43,10 +43,15 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) | ||
43 | onlyUsers = article.WhoRead | 43 | onlyUsers = article.WhoRead |
44 | } | 44 | } |
45 | } | 45 | } |
46 | - if _, users, err = l.svcCtx.UserRepository.FindDepartmentUsers(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions().WithKV("name", req.Keywords).WithFindOnly()); err != nil { | 46 | + queryOptions := domain.NewQueryOptions(). |
47 | + WithKV("name", req.Keywords).WithFindOnly() | ||
48 | + if req.DepartmentId != nil && *req.DepartmentId > 0 { | ||
49 | + queryOptions.WithKV("departmentId", *req.DepartmentId) | ||
50 | + } | ||
51 | + if _, users, err = l.svcCtx.UserRepository.FindDepartmentUsers(l.ctx, conn, userToken.CompanyId, queryOptions); err != nil { | ||
47 | return nil, xerr.NewErrMsgErr("用户列表获取失败", err) | 52 | return nil, xerr.NewErrMsgErr("用户列表获取失败", err) |
48 | } | 53 | } |
49 | - if len(onlyUsers) > 0 { | 54 | + if len(onlyUsers) > 0 || (req.DepartmentId != nil && *req.DepartmentId == 0) { |
50 | onlyUsersMap := lo.KeyBy(onlyUsers, func(item int64) int64 { | 55 | onlyUsersMap := lo.KeyBy(onlyUsers, func(item int64) int64 { |
51 | return item | 56 | return item |
52 | }) | 57 | }) |
@@ -54,6 +59,11 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) | @@ -54,6 +59,11 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) | ||
54 | if _, ok := onlyUsersMap[item.Id]; ok { | 59 | if _, ok := onlyUsersMap[item.Id]; ok { |
55 | return false | 60 | return false |
56 | } | 61 | } |
62 | + if req.DepartmentId != nil && *req.DepartmentId == 0 { | ||
63 | + if len(item.Departments) > 0 { | ||
64 | + return false | ||
65 | + } | ||
66 | + } | ||
57 | return true | 67 | return true |
58 | }) | 68 | }) |
59 | } | 69 | } |
@@ -3,6 +3,7 @@ package user | @@ -3,6 +3,7 @@ package user | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | "fmt" | 5 | "fmt" |
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
6 | "strconv" | 7 | "strconv" |
7 | 8 | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
@@ -97,6 +98,7 @@ func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) ( | @@ -97,6 +98,7 @@ func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) ( | ||
97 | } | 98 | } |
98 | } | 99 | } |
99 | } | 100 | } |
101 | + resp.CompanyVisible = company.Visible == 1 | ||
100 | err = l.initSystemData(companyId) | 102 | err = l.initSystemData(companyId) |
101 | if err != nil { | 103 | if err != nil { |
102 | return nil, err | 104 | return nil, err |
@@ -109,11 +111,23 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | @@ -109,11 +111,23 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | ||
109 | // 初始设置文章标签 | 111 | // 初始设置文章标签 |
110 | queryOption := domain.NewQueryOptions().WithCountOnly() | 112 | queryOption := domain.NewQueryOptions().WithCountOnly() |
111 | conn := l.svcCtx.DefaultDBConn() | 113 | conn := l.svcCtx.DefaultDBConn() |
112 | - cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption) | ||
113 | - if err != nil { | ||
114 | - return xerr.NewErrMsgErr("初始话公司数据失败", err) | 114 | + categoryList := []*domain.ArticleCategory{ |
115 | + { | ||
116 | + Name: "机会风险", | ||
117 | + SortBy: 1, | ||
118 | + Enable: 1, | ||
119 | + Other: "", | ||
120 | + CompanyId: companyId, | ||
121 | + }, | ||
122 | + { | ||
123 | + Name: "紧急重要", | ||
124 | + SortBy: 2, | ||
125 | + Enable: 1, | ||
126 | + Other: "", | ||
127 | + CompanyId: companyId, | ||
128 | + }, | ||
115 | } | 129 | } |
116 | - if cnt == 0 { | 130 | + |
117 | articleTags := []*domain.ArticleTag{ | 131 | articleTags := []*domain.ArticleTag{ |
118 | { | 132 | { |
119 | Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0}, | 133 | Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0}, |
@@ -168,11 +182,37 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | @@ -168,11 +182,37 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | ||
168 | Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13, | 182 | Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13, |
169 | }, | 183 | }, |
170 | } | 184 | } |
185 | + | ||
186 | + cnt, _, err := l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, companyId, queryOption) | ||
187 | + if cnt == 0 { | ||
188 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
189 | + for _, category := range categoryList { | ||
190 | + category, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, category) | ||
191 | + if err != nil { | ||
192 | + return err | ||
193 | + } | ||
194 | + } | ||
195 | + cnt, _, err = l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption) | ||
196 | + if err != nil { | ||
197 | + return xerr.NewErrMsgErr("初始话公司数据失败", err) | ||
198 | + } | ||
199 | + for _, tag := range articleTags { | ||
200 | + for _, category := range categoryList { | ||
201 | + if category.Name == tag.Category { | ||
202 | + tag.CategoryId = category.Id | ||
203 | + } | ||
204 | + } | ||
205 | + } | ||
206 | + if cnt == 0 { | ||
171 | err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags) | 207 | err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags) |
172 | if err != nil { | 208 | if err != nil { |
173 | return xerr.NewErrMsgErr("初始话公司数据失败", err) | 209 | return xerr.NewErrMsgErr("初始话公司数据失败", err) |
174 | } | 210 | } |
175 | } | 211 | } |
176 | - | 212 | + return nil |
213 | + }, true); err != nil { | ||
214 | + return xerr.NewErrMsgErr("初始话公司数据失败", err) | ||
215 | + } | ||
216 | + } | ||
177 | return nil | 217 | return nil |
178 | } | 218 | } |
@@ -33,7 +33,9 @@ type ServiceContext struct { | @@ -33,7 +33,9 @@ type ServiceContext struct { | ||
33 | ArticleRepository domain.ArticleRepository | 33 | ArticleRepository domain.ArticleRepository |
34 | ArticleSectionRepository domain.ArticleSectionRepository | 34 | ArticleSectionRepository domain.ArticleSectionRepository |
35 | ArticleTagRepository domain.ArticleTagRepository | 35 | ArticleTagRepository domain.ArticleTagRepository |
36 | + ArticleCategoryRepository domain.ArticleCategoryRepository | ||
36 | ArticleAndTagRepository domain.ArticleAndTagRepository | 37 | ArticleAndTagRepository domain.ArticleAndTagRepository |
38 | + ArticleDraftOperationRepository domain.ArticleDraftOperationRepository | ||
37 | 39 | ||
38 | CompanyRepository domain.CompanyRepository | 40 | CompanyRepository domain.CompanyRepository |
39 | DepartmentRepository domain.DepartmentRepository | 41 | DepartmentRepository domain.DepartmentRepository |
@@ -87,6 +89,8 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -87,6 +89,8 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
87 | ArticleRepository: repository.NewArticleRepository(cache.NewCachedRepository(mlCache)), | 89 | ArticleRepository: repository.NewArticleRepository(cache.NewCachedRepository(mlCache)), |
88 | ArticleSectionRepository: repository.NewArticleSectionRepository(cache.NewCachedRepository(mlCache)), | 90 | ArticleSectionRepository: repository.NewArticleSectionRepository(cache.NewCachedRepository(mlCache)), |
89 | ArticleAndTagRepository: repository.NewArticleAndTagRepository(cache.NewCachedRepository(mlCache)), | 91 | ArticleAndTagRepository: repository.NewArticleAndTagRepository(cache.NewCachedRepository(mlCache)), |
92 | + ArticleCategoryRepository: repository.NewArticleCategoryRepository(cache.NewCachedRepository(mlCache)), | ||
93 | + ArticleDraftOperationRepository: repository.NewArticleDraftOperationRepository(cache.NewCachedRepository(mlCache)), | ||
90 | 94 | ||
91 | CompanyRepository: repository.NewCompanyRepository(cache.NewCachedRepository(mlCache)), | 95 | CompanyRepository: repository.NewCompanyRepository(cache.NewCachedRepository(mlCache)), |
92 | DepartmentRepository: repository.NewDepartmentRepository(cache.NewCachedRepository(mlCache)), | 96 | DepartmentRepository: repository.NewDepartmentRepository(cache.NewCachedRepository(mlCache)), |
@@ -105,3 +109,13 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -105,3 +109,13 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
105 | func (svc *ServiceContext) DefaultDBConn() transaction.Conn { | 109 | func (svc *ServiceContext) DefaultDBConn() transaction.Conn { |
106 | return transaction.NewTransactionContext(svc.DB) | 110 | return transaction.NewTransactionContext(svc.DB) |
107 | } | 111 | } |
112 | + | ||
113 | +func (svc *ServiceContext) GetMiniProgram() *miniprogram.MiniProgram { | ||
114 | + c := svc.Config | ||
115 | + miniProgram := wechat.NewWechat().GetMiniProgram(&miniConfig.Config{ | ||
116 | + AppID: c.Wechat.AppID, | ||
117 | + AppSecret: c.Wechat.AppSecret, | ||
118 | + Cache: minicache.NewMemory(), | ||
119 | + }) | ||
120 | + return miniProgram | ||
121 | +} |
@@ -351,10 +351,10 @@ type TagCreateRequest struct { | @@ -351,10 +351,10 @@ type TagCreateRequest struct { | ||
351 | CompanyId int64 `json:",optional"` | 351 | CompanyId int64 `json:",optional"` |
352 | Image string `json:"image"` | 352 | Image string `json:"image"` |
353 | Name string `json:"name"` // 标签名称 | 353 | Name string `json:"name"` // 标签名称 |
354 | - Category string `json:"category"` // 标签分类 | ||
355 | Remark string `json:"remark,optional"` // 备注 | 354 | Remark string `json:"remark,optional"` // 备注 |
356 | Other string `json:"other,optional"` | 355 | Other string `json:"other,optional"` |
357 | SortBy int `json:"sortBy,optional"` //排序 | 356 | SortBy int `json:"sortBy,optional"` //排序 |
357 | + CategoryId int64 `json:"categoryId"` // 标签Id | ||
358 | } | 358 | } |
359 | 359 | ||
360 | type TagCreateResponse struct { | 360 | type TagCreateResponse struct { |
@@ -366,7 +366,7 @@ type TagEditRequest struct { | @@ -366,7 +366,7 @@ type TagEditRequest struct { | ||
366 | CompanyId int64 `json:",optional"` | 366 | CompanyId int64 `json:",optional"` |
367 | Image string `json:"image"` | 367 | Image string `json:"image"` |
368 | Name string `json:"name"` // 标签名称 | 368 | Name string `json:"name"` // 标签名称 |
369 | - Category string `json:"category"` // 标签分类 | 369 | + CategoryId int64 `json:"categoryId"` // 标签Id |
370 | Remark string `json:"remark,optional"` // 备注 | 370 | Remark string `json:"remark,optional"` // 备注 |
371 | Other string `json:"other,optional"` | 371 | Other string `json:"other,optional"` |
372 | SortBy int `json:"sortBy,optional"` // 排序 | 372 | SortBy int `json:"sortBy,optional"` // 排序 |
@@ -386,6 +386,7 @@ type TagGetResponse struct { | @@ -386,6 +386,7 @@ type TagGetResponse struct { | ||
386 | Image string `json:"image"` | 386 | Image string `json:"image"` |
387 | Name string `json:"name"` // 标签名称 | 387 | Name string `json:"name"` // 标签名称 |
388 | Category string `json:"category"` // 标签分类 | 388 | Category string `json:"category"` // 标签分类 |
389 | + CategoryId int64 `json:"categoryId"` // 标签分类Id | ||
389 | Remark string `json:"remark"` // 备注 | 390 | Remark string `json:"remark"` // 备注 |
390 | Other string `json:"other"` | 391 | Other string `json:"other"` |
391 | SortBy int `json:"sortBy,optional"` // 排序 | 392 | SortBy int `json:"sortBy,optional"` // 排序 |
@@ -396,7 +397,7 @@ type TagListRequest struct { | @@ -396,7 +397,7 @@ type TagListRequest struct { | ||
396 | Size int `json:"size"` | 397 | Size int `json:"size"` |
397 | CompanyId int64 `json:",optional"` | 398 | CompanyId int64 `json:",optional"` |
398 | TagName string `json:"tagName,optional"` | 399 | TagName string `json:"tagName,optional"` |
399 | - Category string `json:"category,optional"` | 400 | + CategoryId int64 `json:"categoryId,optional"` |
400 | Remark string `json:"remark,optional"` | 401 | Remark string `json:"remark,optional"` |
401 | } | 402 | } |
402 | 403 | ||
@@ -410,9 +411,11 @@ type TagItem struct { | @@ -410,9 +411,11 @@ type TagItem struct { | ||
410 | Image string `json:"image"` | 411 | Image string `json:"image"` |
411 | Name string `json:"name"` // 标签名称 | 412 | Name string `json:"name"` // 标签名称 |
412 | Category string `json:"category"` // 标签分类 | 413 | Category string `json:"category"` // 标签分类 |
414 | + CategoryId int64 `json:"categoryId"` // 标签分类Id | ||
413 | Remark string `json:"remark"` // 备注 | 415 | Remark string `json:"remark"` // 备注 |
414 | CreatedAt int64 `json:"createdAt"` | 416 | CreatedAt int64 `json:"createdAt"` |
415 | SortBy int `json:"sortBy,optional"` // 排序 | 417 | SortBy int `json:"sortBy,optional"` // 排序 |
418 | + Removeable bool `json:"removeable,optional"` // 可删除 | ||
416 | } | 419 | } |
417 | 420 | ||
418 | type TagDeleteRequest struct { | 421 | type TagDeleteRequest struct { |
@@ -433,7 +436,8 @@ type TagOptionsResponse struct { | @@ -433,7 +436,8 @@ type TagOptionsResponse struct { | ||
433 | } | 436 | } |
434 | 437 | ||
435 | type TagOptions struct { | 438 | type TagOptions struct { |
436 | - Label string `json:"label"` // 分组名称 | 439 | + Value int64 `json:"value"` // 分类ID |
440 | + Label string `json:"label"` // 分类名称 | ||
437 | Options []TagOptionValue `json:"options"` | 441 | Options []TagOptionValue `json:"options"` |
438 | } | 442 | } |
439 | 443 | ||
@@ -558,6 +562,7 @@ type MiniUsersListRequest struct { | @@ -558,6 +562,7 @@ type MiniUsersListRequest struct { | ||
558 | ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户) | 562 | ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户) |
559 | RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户 | 563 | RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户 |
560 | Keywords string `json:"keywords,optional"` // 按关键字搜索(名称) | 564 | Keywords string `json:"keywords,optional"` // 按关键字搜索(名称) |
565 | + DepartmentId *int64 `json:"departmentId,optional"` // 按部门过滤 | ||
561 | } | 566 | } |
562 | 567 | ||
563 | type MiniUserNewsRequest struct { | 568 | type MiniUserNewsRequest struct { |
@@ -627,7 +632,7 @@ type Account struct { | @@ -627,7 +632,7 @@ type Account struct { | ||
627 | } | 632 | } |
628 | 633 | ||
629 | type Department struct { | 634 | type Department struct { |
630 | - Id int64 `json:"id,omitempty"` // 部门ID | 635 | + Id int64 `json:"id"` // 部门ID |
631 | CompanyId int64 `json:"companyId"` // 公司ID | 636 | CompanyId int64 `json:"companyId"` // 公司ID |
632 | ParentId int64 `json:"parentId"` // 父级ID | 637 | ParentId int64 `json:"parentId"` // 父级ID |
633 | Name string `json:"name"` // 部门名称 | 638 | Name string `json:"name"` // 部门名称 |
@@ -721,6 +726,7 @@ type SystemUserInfoResponse struct { | @@ -721,6 +726,7 @@ type SystemUserInfoResponse struct { | ||
721 | CompanyId int64 `json:"companyId"` | 726 | CompanyId int64 `json:"companyId"` |
722 | CompanyName string `json:"companyName"` | 727 | CompanyName string `json:"companyName"` |
723 | Code string `json:"code"` | 728 | Code string `json:"code"` |
729 | + CompanyVisible bool `json:"companyVisible"` | ||
724 | } | 730 | } |
725 | 731 | ||
726 | type UserStatisticsRequest struct { | 732 | type UserStatisticsRequest struct { |
@@ -862,6 +868,13 @@ type Company struct { | @@ -862,6 +868,13 @@ type Company struct { | ||
862 | JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) | 868 | JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) |
863 | } | 869 | } |
864 | 870 | ||
871 | +type CompanyVisibleSwitchRequest struct { | ||
872 | + Visible bool `json:"visible"` // 可见性 true:可被搜索 false:不可被搜索 | ||
873 | +} | ||
874 | + | ||
875 | +type CompanyVisibleSwitchResponse struct { | ||
876 | +} | ||
877 | + | ||
865 | type CompanyPositionsSearchRequest struct { | 878 | type CompanyPositionsSearchRequest struct { |
866 | } | 879 | } |
867 | 880 | ||
@@ -895,6 +908,11 @@ type ArticleAuthor struct { | @@ -895,6 +908,11 @@ type ArticleAuthor struct { | ||
895 | Company string `json:"company"` // 公司 | 908 | Company string `json:"company"` // 公司 |
896 | } | 909 | } |
897 | 910 | ||
911 | +type Operator struct { | ||
912 | + Id int64 `json:"id,string"` // 人员id | ||
913 | + Name string `json:"name"` // 人员的名字 | ||
914 | +} | ||
915 | + | ||
898 | type MiniArticleCreateRequest struct { | 916 | type MiniArticleCreateRequest struct { |
899 | Title string `json:"title"` //标题 | 917 | Title string `json:"title"` //标题 |
900 | Section []string `json:"section"` //文章的文本内容 | 918 | Section []string `json:"section"` //文章的文本内容 |
@@ -967,6 +985,10 @@ type ArticleSearchMe struct { | @@ -967,6 +985,10 @@ type ArticleSearchMe struct { | ||
967 | CountComment int `json:"countComment"` //评论数量 | 985 | CountComment int `json:"countComment"` //评论数量 |
968 | CountRead int `json:"countRead"` //浏览数量 | 986 | CountRead int `json:"countRead"` //浏览数量 |
969 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 987 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
988 | + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
989 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
990 | + IsDel int `json:"isDel"` //是否删除 1-删除 0-否 | ||
991 | + DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除 | ||
970 | } | 992 | } |
971 | 993 | ||
972 | type SystemArticleSearchMeRequest struct { | 994 | type SystemArticleSearchMeRequest struct { |
@@ -982,6 +1004,26 @@ type SystemArticleSearchMeResponse struct { | @@ -982,6 +1004,26 @@ type SystemArticleSearchMeResponse struct { | ||
982 | List []ArticleSearchMe `json:"list"` | 1004 | List []ArticleSearchMe `json:"list"` |
983 | } | 1005 | } |
984 | 1006 | ||
1007 | +type MiniArticleSetViewRequest struct { | ||
1008 | + Id int64 `json:"id"` //id | ||
1009 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
1010 | +} | ||
1011 | + | ||
1012 | +type MiniArticleSetViewResponse struct { | ||
1013 | + Id int64 `json:"id"` //id | ||
1014 | + Title string `json:"title"` //标题 | ||
1015 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
1016 | +} | ||
1017 | + | ||
1018 | +type MiniArticleDeleteRequest struct { | ||
1019 | + Id int64 `json:"id"` //id | ||
1020 | +} | ||
1021 | + | ||
1022 | +type MiniArticleDeleteResponse struct { | ||
1023 | + Id int64 `json:"id"` //id | ||
1024 | + Title string `json:"title"` //标题 | ||
1025 | +} | ||
1026 | + | ||
985 | type MiniUserLikeArticleRequest struct { | 1027 | type MiniUserLikeArticleRequest struct { |
986 | ArticleId int64 `json:"articleId"` // 文章id | 1028 | ArticleId int64 `json:"articleId"` // 文章id |
987 | CompanyId int64 `json:",optional"` //公司id | 1029 | CompanyId int64 `json:",optional"` //公司id |
@@ -1263,11 +1305,14 @@ type SystemArticleSearch struct { | @@ -1263,11 +1305,14 @@ type SystemArticleSearch struct { | ||
1263 | Author string `json:"author"` //发布人 | 1305 | Author string `json:"author"` //发布人 |
1264 | Images []string `json:"images"` //图片 | 1306 | Images []string `json:"images"` //图片 |
1265 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 1307 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
1308 | + UpdatedAt int64 `json:"updatedAt"` //文章的编辑日期 | ||
1266 | CountLove int `json:"countLove"` //点赞数量 | 1309 | CountLove int `json:"countLove"` //点赞数量 |
1267 | CountComment int `json:"countComment"` //评论数量 | 1310 | CountComment int `json:"countComment"` //评论数量 |
1268 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 1311 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
1269 | Tags []string `json:"tags"` //标签 | 1312 | Tags []string `json:"tags"` //标签 |
1270 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 1313 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
1314 | + Operator Operator `json:"operator"` //运营操作人 | ||
1315 | + Source int `json:"source"` //来源[1用户发布、2运营发布] | ||
1271 | } | 1316 | } |
1272 | 1317 | ||
1273 | type SystemArticleUpdateRequest struct { | 1318 | type SystemArticleUpdateRequest struct { |
@@ -1299,6 +1344,44 @@ type SystemArticleUpdateResponse struct { | @@ -1299,6 +1344,44 @@ type SystemArticleUpdateResponse struct { | ||
1299 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 1344 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
1300 | } | 1345 | } |
1301 | 1346 | ||
1347 | +type SystemArticleCreateRequest struct { | ||
1348 | + Title string `json:"title"` //标题 | ||
1349 | + Content string `json:"content"` //文章的文本内容 | ||
1350 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1351 | + Images []string `json:"images,optional"` //图片 | ||
1352 | + Videos []Video `json:"video,optional"` // 视频 | ||
1353 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
1354 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
1355 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
1356 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
1357 | + ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID | ||
1358 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
1359 | +} | ||
1360 | + | ||
1361 | +type SystemArticleCreateResponse struct { | ||
1362 | + Id int64 `json:"id"` //id | ||
1363 | + Title string `json:"title"` //标题 | ||
1364 | + Content string `json:"content"` //文章的文本内容 | ||
1365 | + AuthorId int64 `json:"authorId,optional"` //发布人id | ||
1366 | + Images []string `json:"images,optional"` //图片 | ||
1367 | + Videos []Video `json:"video,optional"` // 视频 | ||
1368 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
1369 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
1370 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
1371 | + MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | ||
1372 | +} | ||
1373 | + | ||
1374 | +type SystemArticleDeleteRequest struct { | ||
1375 | + Id int64 `json:"id"` //id | ||
1376 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
1377 | +} | ||
1378 | + | ||
1379 | +type SystemArticleDeleteResponse struct { | ||
1380 | + Id int64 `json:"id"` //id | ||
1381 | + Title string `json:"title"` //标题 | ||
1382 | + AuthorId int64 `json:"authorId,optional"` //发布人id | ||
1383 | +} | ||
1384 | + | ||
1302 | type SystemArticleHistoryRequest struct { | 1385 | type SystemArticleHistoryRequest struct { |
1303 | ArticleId int64 `json:"articleId"` //文章ID | 1386 | ArticleId int64 `json:"articleId"` //文章ID |
1304 | Author string `json:"author,optional"` //发布人 | 1387 | Author string `json:"author,optional"` //发布人 |
@@ -1401,6 +1484,164 @@ type MiniSearchArticleItem struct { | @@ -1401,6 +1484,164 @@ type MiniSearchArticleItem struct { | ||
1401 | MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] | 1484 | MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] |
1402 | } | 1485 | } |
1403 | 1486 | ||
1487 | +type SystemArticleDraftCreateRequest struct { | ||
1488 | + Title string `json:"title"` //标题 | ||
1489 | + Content string `json:"content"` //文章的文本内容 | ||
1490 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1491 | + Images []string `json:"images,optional"` //图片 | ||
1492 | + Videos []Video `json:"video,optional"` // 视频 | ||
1493 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
1494 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
1495 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
1496 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
1497 | + Tags []int64 `json:"tags"` // 标签 | ||
1498 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
1499 | +} | ||
1500 | + | ||
1501 | +type SystemArticleDraftCreateResponse struct { | ||
1502 | + Id int64 `json:"id"` //ID | ||
1503 | + Title string `json:"title"` //标题 | ||
1504 | + Content string `json:"content"` //文章的文本内容 | ||
1505 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1506 | + Images []string `json:"images,optional"` //图片 | ||
1507 | + Videos []Video `json:"video,optional"` // 视频 | ||
1508 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
1509 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
1510 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
1511 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
1512 | + Tags []int64 `json:"tags"` // 标签 | ||
1513 | +} | ||
1514 | + | ||
1515 | +type SystemArticleDraftUpdateRequest struct { | ||
1516 | + Id int64 `json:"id"` // ID | ||
1517 | + Title string `json:"title"` //标题 | ||
1518 | + Content string `json:"content"` //文章的文本内容 | ||
1519 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1520 | + Images []string `json:"images,optional"` //图片 | ||
1521 | + Videos []Video `json:"video,optional"` // 视频 | ||
1522 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
1523 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
1524 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
1525 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
1526 | + Tags []int64 `json:"tags"` // 标签 | ||
1527 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
1528 | +} | ||
1529 | + | ||
1530 | +type SystemArticleDraftUpdateResponse struct { | ||
1531 | + Id int64 `json:"id"` //ID | ||
1532 | + Title string `json:"title"` //标题 | ||
1533 | + Content string `json:"content"` //文章的文本内容 | ||
1534 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1535 | + Images []string `json:"images,optional"` //图片 | ||
1536 | + Videos []Video `json:"video,optional"` // 视频 | ||
1537 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
1538 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
1539 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
1540 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
1541 | + Tags []int64 `json:"tags"` // 标签 | ||
1542 | +} | ||
1543 | + | ||
1544 | +type SystemArticleDraftSearchRequest struct { | ||
1545 | + Page int `json:"page"` //页码 | ||
1546 | + Size int `json:"size"` //每页行数 | ||
1547 | + CompanyId int64 `json:"companyId,optional"` //公司ID(前端不传) | ||
1548 | + Title string `json:"title,optional"` //标题 | ||
1549 | + Operator string `json:"operator,optional"` //编辑人 | ||
1550 | + BeginTime int64 `json:"beginTime,optional"` //开始时间 | ||
1551 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
1552 | +} | ||
1553 | + | ||
1554 | +type SystemArticleDraftSearchResponse struct { | ||
1555 | + Total int `json:"total"` | ||
1556 | + List []SystemArticleDraftSearch `json:"list"` | ||
1557 | +} | ||
1558 | + | ||
1559 | +type SystemArticleDraftSearch struct { | ||
1560 | + Id int64 `json:"id"` //ID | ||
1561 | + Title string `json:"title"` //标题 | ||
1562 | + Images []string `json:"images"` //图片 | ||
1563 | + Operator string `json:"operator"` //操作人 | ||
1564 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1565 | + Author string `json:"author"` //发布人 | ||
1566 | + UpdatedAt int64 `json:"updatedAt"` //编辑时间 | ||
1567 | +} | ||
1568 | + | ||
1569 | +type SystemArticleDraftDeleteRequest struct { | ||
1570 | + Id int64 `json:"id"` //ID | ||
1571 | +} | ||
1572 | + | ||
1573 | +type SystemArticleDraftDeleteResponse struct { | ||
1574 | + Id int64 `json:"id"` //ID | ||
1575 | + Title string `json:"title"` //标题 | ||
1576 | + Content string `json:"content"` //文章的文本内容 | ||
1577 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1578 | + Images []string `json:"images,optional"` //图片 | ||
1579 | + Videos []Video `json:"video,optional"` // 视频 | ||
1580 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
1581 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
1582 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
1583 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
1584 | + Tags []int64 `json:"tags"` // 标签 | ||
1585 | +} | ||
1586 | + | ||
1587 | +type SystemArticleDraftGetRequest struct { | ||
1588 | + Id int64 `path:"id"` //id | ||
1589 | + CompanyId int64 `path:",optional"` //公司ID(前端不传) | ||
1590 | +} | ||
1591 | + | ||
1592 | +type SystemArticleDraftGetResponse struct { | ||
1593 | + Id int64 `json:"id"` //ID | ||
1594 | + Title string `json:"title"` //标题 | ||
1595 | + Content string `json:"content"` //文章的文本内容 | ||
1596 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1597 | + Images []string `json:"images,optional"` //图片 | ||
1598 | + Videos []Video `json:"video,optional"` // 视频 | ||
1599 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
1600 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
1601 | + WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | ||
1602 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
1603 | + WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 | ||
1604 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
1605 | + Tags []int64 `json:"tags"` // 标签 | ||
1606 | +} | ||
1607 | + | ||
1608 | +type SystemArticleSearchDeletedRequest struct { | ||
1609 | + Page int `json:"page"` //页码 | ||
1610 | + Size int `json:"size"` //每页行数 | ||
1611 | + Title string `json:"title,optional"` //标题 | ||
1612 | + Author int64 `json:"author,optional"` //发布人 | ||
1613 | + DeletedType int `json:"deletedType,optional"` //类型 1-运营删除 2-用户删除 | ||
1614 | + BeginTime int64 `json:"beginTime,optional"` //开始时间 | ||
1615 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
1616 | +} | ||
1617 | + | ||
1618 | +type SystemArticleSearchDeletedResponse struct { | ||
1619 | + Total int `json:"total"` | ||
1620 | + List []SystemArticleSearchDeletedItem `json:"list"` | ||
1621 | +} | ||
1622 | + | ||
1623 | +type SystemArticleSearchDeletedItem struct { | ||
1624 | + Id int64 `json:"id"` //ID | ||
1625 | + Title string `json:"title"` //标题 | ||
1626 | + Images []string `json:"images"` //图片 | ||
1627 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1628 | + Author string `json:"author"` //发布人 | ||
1629 | + Source int `json:"source"` //来源 1-用户发布 2-运营发布 | ||
1630 | + DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除 | ||
1631 | + DeletedAt int64 `json:"deletedAt"` //删除时间 | ||
1632 | +} | ||
1633 | + | ||
1634 | +type SystemArticleDeletedRestoreRequest struct { | ||
1635 | + Id int64 `json:"id"` //ID | ||
1636 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
1637 | +} | ||
1638 | + | ||
1639 | +type SystemArticleDeletedRestoreResponse struct { | ||
1640 | + Id int64 `json:"id"` //ID | ||
1641 | + Title string `json:"title"` //标题 | ||
1642 | + AuthorId int64 `json:"authorId"` //发布人id | ||
1643 | +} | ||
1644 | + | ||
1404 | type RoleGetRequest struct { | 1645 | type RoleGetRequest struct { |
1405 | Id int64 `path:"id"` | 1646 | Id int64 `path:"id"` |
1406 | } | 1647 | } |
@@ -1488,9 +1729,78 @@ type DepartmentUpdateRequest struct { | @@ -1488,9 +1729,78 @@ type DepartmentUpdateRequest struct { | ||
1488 | type DepartmentListRequest struct { | 1729 | type DepartmentListRequest struct { |
1489 | Page int `json:"page"` | 1730 | Page int `json:"page"` |
1490 | Size int `json:"size"` | 1731 | Size int `json:"size"` |
1732 | + IncludeRootCompany bool `json:"includeRootCompany,optional"` // 包含公司(把公司当作部门作为顶级节点 部门ID:0) | ||
1491 | } | 1733 | } |
1492 | 1734 | ||
1493 | type DepartmentListResponse struct { | 1735 | type DepartmentListResponse struct { |
1494 | List []Department `json:"list"` | 1736 | List []Department `json:"list"` |
1495 | Total int64 `json:"total"` | 1737 | Total int64 `json:"total"` |
1496 | } | 1738 | } |
1739 | + | ||
1740 | +type ArticleCategoryGetRequest struct { | ||
1741 | + Id int64 `path:"id"` | ||
1742 | +} | ||
1743 | + | ||
1744 | +type ArticleCategoryGetResponse struct { | ||
1745 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
1746 | +} | ||
1747 | + | ||
1748 | +type ArticleCategorySaveRequest struct { | ||
1749 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
1750 | +} | ||
1751 | + | ||
1752 | +type ArticleCategorySaveResponse struct { | ||
1753 | +} | ||
1754 | + | ||
1755 | +type ArticleCategoryDeleteRequest struct { | ||
1756 | + Id int64 `path:"id"` | ||
1757 | +} | ||
1758 | + | ||
1759 | +type ArticleCategoryDeleteResponse struct { | ||
1760 | +} | ||
1761 | + | ||
1762 | +type ArticleCategoryUpdateRequest struct { | ||
1763 | + Id int64 `path:"id"` | ||
1764 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
1765 | +} | ||
1766 | + | ||
1767 | +type ArticleCategoryUpdateResponse struct { | ||
1768 | +} | ||
1769 | + | ||
1770 | +type ArticleCategorySearchRequest struct { | ||
1771 | + Page int `json:"page"` | ||
1772 | + Size int `json:"size"` | ||
1773 | +} | ||
1774 | + | ||
1775 | +type ArticleCategorySearchResponse struct { | ||
1776 | + List []ArticleCategoryItem `json:"list"` | ||
1777 | + Total int64 `json:"total"` | ||
1778 | +} | ||
1779 | + | ||
1780 | +type ArticleCategoryItem struct { | ||
1781 | + Id int64 `json:"id,optional"` // 唯一标识 | ||
1782 | + CompanyId int64 `json:"companyId,optional,omitempty"` | ||
1783 | + Name string `json:"name"` | ||
1784 | + SortBy int `json:"sortBy,optional,omitempty"` // 排序 | ||
1785 | + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 | ||
1786 | + Other string `json:"other,optional,omitempty"` // 其他备注说明 | ||
1787 | +} | ||
1788 | + | ||
1789 | +type CategoryOptionsRequest struct { | ||
1790 | + Enable int `form:"enable,optional"` // 启用状态 1:启用 | ||
1791 | +} | ||
1792 | + | ||
1793 | +type CategoryOptionsResponse struct { | ||
1794 | + Options []CategoryOptions `json:"options"` | ||
1795 | +} | ||
1796 | + | ||
1797 | +type CategoryOptions struct { | ||
1798 | + Value int64 `json:"value"` // 分类ID | ||
1799 | + Label string `json:"label"` // 分组名称 | ||
1800 | + Enable int `json:"enable,optional,omitempty"` // 启用状态 1:启用 | ||
1801 | +} | ||
1802 | + | ||
1803 | +type CategoryOptionValue struct { | ||
1804 | + Label string `json:"label"` // 名称 | ||
1805 | + Value int64 `json:"value"` // 分类ID | ||
1806 | +} |
cmd/discuss/doc/dsl/api/article_category.api
0 → 100644
1 | + | ||
2 | +syntax = "v1" | ||
3 | + | ||
4 | +info( | ||
5 | + title: "xx实例" | ||
6 | + desc: "xx实例" | ||
7 | + author: "author" | ||
8 | + email: "email" | ||
9 | + version: "v1" | ||
10 | +) | ||
11 | + | ||
12 | +@server( | ||
13 | + prefix: article_category/v1 | ||
14 | + group: article_category | ||
15 | + jwt: JwtAuth | ||
16 | +) | ||
17 | +service Core { | ||
18 | + @doc "详情" | ||
19 | + @handler article_categoryGet | ||
20 | + get /article_category/:id (ArticleCategoryGetRequest) returns (ArticleCategoryGetResponse) | ||
21 | + @doc "保存" | ||
22 | + @handler article_categorySave | ||
23 | + post /article_category (ArticleCategorySaveRequest) returns (ArticleCategorySaveResponse) | ||
24 | + @doc "删除" | ||
25 | + @handler article_categoryDelete | ||
26 | + delete /article_category/:id (ArticleCategoryDeleteRequest) returns (ArticleCategoryDeleteResponse) | ||
27 | + @doc "更新" | ||
28 | + @handler article_categoryUpdate | ||
29 | + put /article_category/:id (ArticleCategoryUpdateRequest) returns (ArticleCategoryUpdateResponse) | ||
30 | + @doc "搜索" | ||
31 | + @handler article_categorySearch | ||
32 | + post /article_category/search (ArticleCategorySearchRequest) returns (ArticleCategorySearchResponse) | ||
33 | +} | ||
34 | + | ||
35 | +type ( | ||
36 | + ArticleCategoryGetRequest { | ||
37 | + Id int64 `path:"id"` | ||
38 | + } | ||
39 | + ArticleCategoryGetResponse struct{ | ||
40 | + ArticleCategory ArticleCategoryItem `json:"article_category"` | ||
41 | + } | ||
42 | + | ||
43 | + ArticleCategorySaveRequest struct{ | ||
44 | + ArticleCategory ArticleCategoryItem `json:"article_category"` | ||
45 | + } | ||
46 | + ArticleCategorySaveResponse struct{} | ||
47 | + | ||
48 | + ArticleCategoryDeleteRequest struct{ | ||
49 | + Id int64 `path:"id"` | ||
50 | + } | ||
51 | + ArticleCategoryDeleteResponse struct{} | ||
52 | + | ||
53 | + ArticleCategoryUpdateRequest struct{ | ||
54 | + Id int64 `path:"id"` | ||
55 | + ArticleCategory ArticleCategoryItem `json:"article_category"` | ||
56 | + } | ||
57 | + ArticleCategoryUpdateResponse struct{} | ||
58 | + | ||
59 | + ArticleCategorySearchRequest struct{ | ||
60 | + Page int `json:"page"` | ||
61 | + Size int `json:"size"` | ||
62 | + } | ||
63 | + ArticleCategorySearchResponse{ | ||
64 | + List []ArticleCategoryItem `json:"list"` | ||
65 | + Total int64 `json:"total"` | ||
66 | + } | ||
67 | + ArticleCategoryItem struct{ | ||
68 | + | ||
69 | + } | ||
70 | +) | ||
71 | + | ||
72 | +// logic CRUD | ||
73 | +// Save | ||
74 | + //var ( | ||
75 | + // conn = l.svcCtx.DefaultDBConn() | ||
76 | + // dm *domain.ArticleCategory | ||
77 | + //) | ||
78 | + //// 唯一判断 | ||
79 | + | ||
80 | + //dm = NewDomainArticleCategory(req.ArticleCategory) | ||
81 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
82 | + // dm, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, dm) | ||
83 | + // return err | ||
84 | + //}, true); err != nil { | ||
85 | + // return nil, xerr.NewErrMsg("保存失败") | ||
86 | + //} | ||
87 | + ////resp = &types.ArticleCategorySaveResponse{} | ||
88 | + //return | ||
89 | + | ||
90 | +//func NewDomainArticleCategory(item types.ArticleCategoryItem) *domain.ArticleCategory { | ||
91 | +// return &domain.ArticleCategory{ | ||
92 | + | ||
93 | +// } | ||
94 | +//} | ||
95 | +// | ||
96 | +//func NewTypesArticleCategory(item *domain.ArticleCategory) types.ArticleCategoryItem { | ||
97 | +// return types.ArticleCategoryItem{ | ||
98 | +// Id: item.Id, | ||
99 | +// } | ||
100 | +//} | ||
101 | + | ||
102 | +// Get | ||
103 | + //var ( | ||
104 | + // conn = l.svcCtx.DefaultDBConn() | ||
105 | + // dm *domain.ArticleCategory | ||
106 | + //) | ||
107 | + //// 货号唯一 | ||
108 | + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
109 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
110 | + //} | ||
111 | + //resp = &types.ArticleCategoryGetResponse{ | ||
112 | + // ArticleCategory: NewTypesArticleCategory(dm), | ||
113 | + //} | ||
114 | + //return | ||
115 | + | ||
116 | +// Delete | ||
117 | + //var ( | ||
118 | + // conn = l.svcCtx.DefaultDBConn() | ||
119 | + // dm *domain.ArticleCategory | ||
120 | + //) | ||
121 | + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
122 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
123 | + //} | ||
124 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
125 | + // if dm, err = l.svcCtx.ArticleCategoryRepository.Delete(l.ctx, conn, dm); err != nil { | ||
126 | + // return err | ||
127 | + // } | ||
128 | + // return nil | ||
129 | + //}, true); err != nil { | ||
130 | + // return nil, xerr.NewErrMsgErr("移除失败", err) | ||
131 | + //} | ||
132 | + //return | ||
133 | + | ||
134 | +// Search | ||
135 | + //var ( | ||
136 | + // conn = l.svcCtx.DefaultDBConn() | ||
137 | + // dms []*domain.ArticleCategory | ||
138 | + // total int64 | ||
139 | + //) | ||
140 | + // | ||
141 | + //queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). | ||
142 | + // WithKV("", "") | ||
143 | + | ||
144 | + //total, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, queryOptions) | ||
145 | + //list := make([]types.ArticleCategoryItem, 0) | ||
146 | + //for i := range dms { | ||
147 | + // list = append(list, NewTypesArticleCategory(dms[i])) | ||
148 | + //} | ||
149 | + //resp = &types.ArticleCategorySearchResponse{ | ||
150 | + // List: list, | ||
151 | + // Total: total, | ||
152 | + //} | ||
153 | + //return | ||
154 | + | ||
155 | +// Update | ||
156 | + //var ( | ||
157 | + // conn = l.svcCtx.DefaultDBConn() | ||
158 | + // dm *domain.ArticleCategory | ||
159 | + //) | ||
160 | + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
161 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
162 | + //} | ||
163 | + //// 不可编辑判断 | ||
164 | + | ||
165 | + //// 赋值 | ||
166 | + | ||
167 | + //// 更新 | ||
168 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
169 | + // dm, err = l.svcCtx.ArticleCategoryRepository.UpdateWithVersion(l.ctx, conn, dm) | ||
170 | + // return err | ||
171 | + //}, true); err != nil { | ||
172 | + // return nil, xerr.NewErrMsg("更新失败") | ||
173 | + //} | ||
174 | + //resp = &types.ArticleCategoryUpdateResponse{} | ||
175 | + //return |
1 | + | ||
2 | +syntax = "v1" | ||
3 | + | ||
4 | +info( | ||
5 | + title: "xx实例" | ||
6 | + desc: "xx实例" | ||
7 | + author: "author" | ||
8 | + email: "email" | ||
9 | + version: "v1" | ||
10 | +) | ||
11 | + | ||
12 | +@server( | ||
13 | + prefix: article_draft_operation/v1 | ||
14 | + group: article_draft_operation | ||
15 | + jwt: JwtAuth | ||
16 | +) | ||
17 | +service Core { | ||
18 | + @handler getArticleDraftOperation | ||
19 | + post /article_draft_operation/:id (ArticleDraftOperationGetRequest) returns (ArticleDraftOperationGetResponse) | ||
20 | + @handler saveArticleDraftOperation | ||
21 | + post /article_draft_operation (ArticleDraftOperationSaveRequest) returns (ArticleDraftOperationSaveResponse) | ||
22 | + @handler deleteArticleDraftOperation | ||
23 | + delete /article_draft_operation/:id (ArticleDraftOperationDeleteRequest) returns (ArticleDraftOperationDeleteResponse) | ||
24 | + @handler updateArticleDraftOperation | ||
25 | + put /article_draft_operation/:id (ArticleDraftOperationUpdateRequest) returns (ArticleDraftOperationUpdateResponse) | ||
26 | + @handler searchArticleDraftOperation | ||
27 | + post /article_draft_operation/search (ArticleDraftOperationSearchRequest) returns (ArticleDraftOperationSearchResponse) | ||
28 | +} | ||
29 | + | ||
30 | +type ( | ||
31 | + ArticleDraftOperationGetRequest { | ||
32 | + Id int64 `path:"id"` | ||
33 | + } | ||
34 | + ArticleDraftOperationGetResponse struct{ | ||
35 | + ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"` | ||
36 | + } | ||
37 | + | ||
38 | + ArticleDraftOperationSaveRequest struct{ | ||
39 | + ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"` | ||
40 | + } | ||
41 | + ArticleDraftOperationSaveResponse struct{} | ||
42 | + | ||
43 | + ArticleDraftOperationDeleteRequest struct{ | ||
44 | + Id int64 `path:"id"` | ||
45 | + } | ||
46 | + ArticleDraftOperationDeleteResponse struct{} | ||
47 | + | ||
48 | + ArticleDraftOperationUpdateRequest struct{ | ||
49 | + Id int64 `path:"id"` | ||
50 | + ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"` | ||
51 | + } | ||
52 | + ArticleDraftOperationUpdateResponse struct{} | ||
53 | + | ||
54 | + ArticleDraftOperationSearchRequest struct{ | ||
55 | + Page int `json:"page"` | ||
56 | + Size int `json:"size"` | ||
57 | + } | ||
58 | + ArticleDraftOperationSearchResponse{ | ||
59 | + List []ArticleDraftOperationItem `json:"list"` | ||
60 | + Total int64 `json:"total"` | ||
61 | + } | ||
62 | + ArticleDraftOperationItem struct{ | ||
63 | + | ||
64 | + } | ||
65 | +) |
1 | + | ||
2 | +syntax = "proto3"; | ||
3 | + | ||
4 | +option go_package ="./pb"; | ||
5 | + | ||
6 | +package pb; | ||
7 | + | ||
8 | +message ArticleCategoryGetReq { | ||
9 | + int64 Id = 1; | ||
10 | +} | ||
11 | +message ArticleCategoryGetResp{ | ||
12 | + ArticleCategoryItem User = 1; | ||
13 | +} | ||
14 | + | ||
15 | +message ArticleCategorySaveReq { | ||
16 | + | ||
17 | +} | ||
18 | +message ArticleCategorySaveResp{ | ||
19 | + | ||
20 | +} | ||
21 | + | ||
22 | +message ArticleCategoryDeleteReq { | ||
23 | + int64 Id = 1; | ||
24 | +} | ||
25 | +message ArticleCategoryDeleteResp{ | ||
26 | + | ||
27 | +} | ||
28 | + | ||
29 | +message ArticleCategoryUpdateReq { | ||
30 | + int64 Id = 1; | ||
31 | +} | ||
32 | +message ArticleCategoryUpdateResp{ | ||
33 | + | ||
34 | +} | ||
35 | + | ||
36 | +message ArticleCategorySearchReq { | ||
37 | + int64 PageNumber = 1; | ||
38 | + int64 PageSize = 2; | ||
39 | +} | ||
40 | +message ArticleCategorySearchResp{ | ||
41 | + repeated ArticleCategoryItem List =1; | ||
42 | + int64 Total =2; | ||
43 | +} | ||
44 | +message ArticleCategoryItem { | ||
45 | + | ||
46 | +} | ||
47 | + | ||
48 | +service ArticleCategoryService { | ||
49 | + rpc ArticleCategoryGet(ArticleCategoryGetReq) returns(ArticleCategoryGetResp); | ||
50 | + rpc ArticleCategorySave(ArticleCategorySaveReq) returns(ArticleCategorySaveResp); | ||
51 | + rpc ArticleCategoryDelete(ArticleCategoryDeleteReq) returns(ArticleCategoryDeleteResp); | ||
52 | + rpc ArticleCategoryUpdate(ArticleCategoryUpdateReq) returns(ArticleCategoryUpdateResp); | ||
53 | + rpc ArticleCategorySearch(ArticleCategorySearchReq) returns(ArticleCategorySearchResp); | ||
54 | +} |
1 | + | ||
2 | +syntax = "proto3"; | ||
3 | + | ||
4 | +option go_package ="./pb"; | ||
5 | + | ||
6 | +package pb; | ||
7 | + | ||
8 | +message ArticleDraftOperationGetReq { | ||
9 | + int64 Id = 1; | ||
10 | +} | ||
11 | +message ArticleDraftOperationGetResp{ | ||
12 | + ArticleDraftOperationItem User = 1; | ||
13 | +} | ||
14 | + | ||
15 | +message ArticleDraftOperationSaveReq { | ||
16 | + | ||
17 | +} | ||
18 | +message ArticleDraftOperationSaveResp{ | ||
19 | + | ||
20 | +} | ||
21 | + | ||
22 | +message ArticleDraftOperationDeleteReq { | ||
23 | + int64 Id = 1; | ||
24 | +} | ||
25 | +message ArticleDraftOperationDeleteResp{ | ||
26 | + | ||
27 | +} | ||
28 | + | ||
29 | +message ArticleDraftOperationUpdateReq { | ||
30 | + int64 Id = 1; | ||
31 | +} | ||
32 | +message ArticleDraftOperationUpdateResp{ | ||
33 | + | ||
34 | +} | ||
35 | + | ||
36 | +message ArticleDraftOperationSearchReq { | ||
37 | + int64 PageNumber = 1; | ||
38 | + int64 PageSize = 2; | ||
39 | +} | ||
40 | +message ArticleDraftOperationSearchResp{ | ||
41 | + repeated ArticleDraftOperationItem List =1; | ||
42 | + int64 Total =2; | ||
43 | +} | ||
44 | +message ArticleDraftOperationItem { | ||
45 | + | ||
46 | +} | ||
47 | + | ||
48 | +service ArticleDraftOperationService { | ||
49 | + rpc ArticleDraftOperationGet(ArticleDraftOperationGetReq) returns(ArticleDraftOperationGetResp); | ||
50 | + rpc ArticleDraftOperationSave(ArticleDraftOperationSaveReq) returns(ArticleDraftOperationSaveResp); | ||
51 | + rpc ArticleDraftOperationDelete(ArticleDraftOperationDeleteReq) returns(ArticleDraftOperationDeleteResp); | ||
52 | + rpc ArticleDraftOperationUpdate(ArticleDraftOperationUpdateReq) returns(ArticleDraftOperationUpdateResp); | ||
53 | + rpc ArticleDraftOperationSearch(ArticleDraftOperationSearchReq) returns(ArticleDraftOperationSearchResp); | ||
54 | +} |
@@ -7,23 +7,25 @@ import ( | @@ -7,23 +7,25 @@ import ( | ||
7 | 7 | ||
8 | func Migrate(db *gorm.DB) { | 8 | func Migrate(db *gorm.DB) { |
9 | modelsList := []interface{}{ | 9 | modelsList := []interface{}{ |
10 | - &models.Article{}, | ||
11 | - &models.ArticleSection{}, | ||
12 | - &models.ArticleBackup{}, | ||
13 | - &models.ArticleDraft{}, | ||
14 | - &models.ArticleComment{}, | ||
15 | - &models.ArticleTag{}, | ||
16 | - &models.UserLoveFlag{}, | ||
17 | - &models.UserReadArticle{}, | ||
18 | - &models.User{}, | ||
19 | - &models.UserRole{}, | ||
20 | - &models.Role{}, | ||
21 | - &models.Company{}, | ||
22 | - &models.UserFollow{}, | ||
23 | - &models.MessageSystem{}, | ||
24 | - &models.MessageBusiness{}, | ||
25 | - &models.Department{}, | ||
26 | - &models.ArticleAndTag{}, | 10 | + //&models.Article{}, |
11 | + //&models.ArticleSection{}, | ||
12 | + //&models.ArticleBackup{}, | ||
13 | + //&models.ArticleDraft{}, | ||
14 | + //&models.ArticleComment{}, | ||
15 | + //&models.ArticleTag{}, | ||
16 | + //&models.UserLoveFlag{}, | ||
17 | + //&models.UserReadArticle{}, | ||
18 | + //&models.User{}, | ||
19 | + //&models.UserRole{}, | ||
20 | + //&models.Role{}, | ||
21 | + //&models.Company{}, | ||
22 | + //&models.UserFollow{}, | ||
23 | + //&models.MessageSystem{}, | ||
24 | + //&models.MessageBusiness{}, | ||
25 | + //&models.Department{}, | ||
26 | + //&models.ArticleAndTag{}, | ||
27 | + &models.ArticleDraftOperation{}, | ||
28 | + &models.ArticleCategory{}, | ||
27 | } | 29 | } |
28 | 30 | ||
29 | db.AutoMigrate(modelsList...) | 31 | db.AutoMigrate(modelsList...) |
@@ -2,11 +2,10 @@ package models | @@ -2,11 +2,10 @@ package models | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | - "time" | ||
6 | - | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
8 | "gorm.io/gorm" | 6 | "gorm.io/gorm" |
9 | "gorm.io/plugin/soft_delete" | 7 | "gorm.io/plugin/soft_delete" |
8 | + "time" | ||
10 | ) | 9 | ) |
11 | 10 | ||
12 | type Article struct { | 11 | type Article struct { |
@@ -33,6 +32,9 @@ type Article struct { | @@ -33,6 +32,9 @@ type Article struct { | ||
33 | Show int // 评论的展示状态(1显示、2不显示) | 32 | Show int // 评论的展示状态(1显示、2不显示) |
34 | Summary string // 内容概要 | 33 | Summary string // 内容概要 |
35 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 | 34 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 |
35 | + Source int `gorm:"default:1"` // 来源 1-用户发布 2-运营发布 | ||
36 | + Operator domain.Operator `gorm:"type:jsonb;serializer:json"` // 运营操作人 | ||
37 | + DeletedType int `json:"deletedType"` // 删除类型 1-运营删除 2-用户删除 | ||
36 | } | 38 | } |
37 | 39 | ||
38 | func (m *Article) TableName() string { | 40 | func (m *Article) TableName() string { |
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
6 | + "gorm.io/gorm" | ||
7 | + "gorm.io/plugin/soft_delete" | ||
8 | + "time" | ||
9 | +) | ||
10 | + | ||
11 | +type ArticleCategory struct { | ||
12 | + Id int64 // 唯一标识 | ||
13 | + CompanyId int64 | ||
14 | + Name string | ||
15 | + SortBy int | ||
16 | + Enable int | ||
17 | + Other string | ||
18 | + CreatedAt int64 | ||
19 | + UpdatedAt int64 | ||
20 | + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | ||
21 | + DeletedAt int64 | ||
22 | + Version int | ||
23 | +} | ||
24 | + | ||
25 | +func (m *ArticleCategory) TableName() string { | ||
26 | + return "article_category" | ||
27 | +} | ||
28 | + | ||
29 | +func (m *ArticleCategory) BeforeCreate(tx *gorm.DB) (err error) { | ||
30 | + m.CreatedAt = time.Now().Unix() | ||
31 | + m.UpdatedAt = time.Now().Unix() | ||
32 | + return | ||
33 | +} | ||
34 | + | ||
35 | +func (m *ArticleCategory) BeforeUpdate(tx *gorm.DB) (err error) { | ||
36 | + m.UpdatedAt = time.Now().Unix() | ||
37 | + return | ||
38 | +} | ||
39 | + | ||
40 | +func (m *ArticleCategory) CacheKeyFunc() string { | ||
41 | + if m.Id == 0 { | ||
42 | + return "" | ||
43 | + } | ||
44 | + return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id) | ||
45 | +} | ||
46 | + | ||
47 | +func (m *ArticleCategory) CacheKeyFuncByObject(obj interface{}) string { | ||
48 | + if v, ok := obj.(*ArticleCategory); ok { | ||
49 | + return v.CacheKeyFunc() | ||
50 | + } | ||
51 | + return "" | ||
52 | +} | ||
53 | + | ||
54 | +func (m *ArticleCategory) CachePrimaryKeyFunc() string { | ||
55 | + if len("") == 0 { | ||
56 | + return "" | ||
57 | + } | ||
58 | + return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") | ||
59 | +} |
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
6 | + "gorm.io/gorm" | ||
7 | + "gorm.io/plugin/soft_delete" | ||
8 | + "time" | ||
9 | +) | ||
10 | + | ||
11 | +// ArticleDraftOperation 运营草稿 | ||
12 | +type ArticleDraftOperation struct { | ||
13 | + Id int64 `gorm:"primaryKey"` // 唯一标识 | ||
14 | + CompanyId int64 `gorm:"comment:公司ID"` // 公司ID | ||
15 | + AuthorId int64 `gorm:"comment:发布人ID"` // 发布人 | ||
16 | + Title string `gorm:"comment:标题"` // 文章标题 | ||
17 | + Content string `json:"content"` // 文章内容 | ||
18 | + Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片 | ||
19 | + Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频 | ||
20 | + TargetUser domain.ArticleTarget `gorm:"comment:分发方式 0所有人 1指定人"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
21 | + WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看 | ||
22 | + WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 | ||
23 | + Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签 | ||
24 | + MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 | ||
25 | + Source int `gorm:"default:1"` // 来源 1-用户发布 2-运营发布 | ||
26 | + Operator domain.Operator `gorm:"type:jsonb;serializer:json"` // 运营操作人 | ||
27 | + Version int `gorm:"comment:版本号"` // 版本号 | ||
28 | + CreatedAt int64 `gorm:"comment:创建时间"` // 创建时间 | ||
29 | + UpdatedAt int64 `gorm:"comment:编辑时间"` // 编辑时间 | ||
30 | + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` // 删除标记 | ||
31 | + DeletedAt int64 `gorm:"comment:删除时间"` // 删除时间 | ||
32 | +} | ||
33 | + | ||
34 | +func (m *ArticleDraftOperation) TableName() string { | ||
35 | + return "article_draft_operation" | ||
36 | +} | ||
37 | + | ||
38 | +func (m *ArticleDraftOperation) BeforeCreate(tx *gorm.DB) (err error) { | ||
39 | + nowTime := time.Now().Unix() | ||
40 | + m.CreatedAt = nowTime | ||
41 | + m.UpdatedAt = nowTime | ||
42 | + return | ||
43 | +} | ||
44 | + | ||
45 | +func (m *ArticleDraftOperation) BeforeUpdate(tx *gorm.DB) (err error) { | ||
46 | + m.UpdatedAt = time.Now().Unix() | ||
47 | + m.Version += 1 | ||
48 | + return | ||
49 | +} | ||
50 | + | ||
51 | +func (m *ArticleDraftOperation) CacheKeyFunc() string { | ||
52 | + if m.Id == 0 { | ||
53 | + return "" | ||
54 | + } | ||
55 | + return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id) | ||
56 | +} | ||
57 | + | ||
58 | +func (m *ArticleDraftOperation) CacheKeyFuncByObject(obj interface{}) string { | ||
59 | + if v, ok := obj.(*ArticleDraftOperation); ok { | ||
60 | + return v.CacheKeyFunc() | ||
61 | + } | ||
62 | + return "" | ||
63 | +} | ||
64 | + | ||
65 | +func (m *ArticleDraftOperation) CachePrimaryKeyFunc() string { | ||
66 | + if len("") == 0 { | ||
67 | + return "" | ||
68 | + } | ||
69 | + return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") | ||
70 | +} |
@@ -24,6 +24,8 @@ type ArticleTag struct { | @@ -24,6 +24,8 @@ type ArticleTag struct { | ||
24 | Category string // 标签分类 | 24 | Category string // 标签分类 |
25 | SortBy int64 // 顺序 | 25 | SortBy int64 // 顺序 |
26 | Other string // 其他 | 26 | Other string // 其他 |
27 | + CategoryId int64 // 标签分类ID | ||
28 | + DataFrom int // 来源 0:系统初始化 1:用户自动添加(可删除) | ||
27 | } | 29 | } |
28 | 30 | ||
29 | func (m *ArticleTag) TableName() string { | 31 | func (m *ArticleTag) TableName() string { |
@@ -12,7 +12,7 @@ type Company struct { | @@ -12,7 +12,7 @@ type Company struct { | ||
12 | Name string // 名称 | 12 | Name string // 名称 |
13 | Code string `gorm:"uniqueIndex:idx_company_code"` // 编码(搜索使用,4位字母数字) | 13 | Code string `gorm:"uniqueIndex:idx_company_code"` // 编码(搜索使用,4位字母数字) |
14 | Logo string // 公司LOGO | 14 | Logo string // 公司LOGO |
15 | - | 15 | + Visible int |
16 | CreatedAt int64 | 16 | CreatedAt int64 |
17 | UpdatedAt int64 | 17 | UpdatedAt int64 |
18 | DeletedAt int64 | 18 | DeletedAt int64 |
1 | +package repository | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/jinzhu/copier" | ||
6 | + "github.com/pkg/errors" | ||
7 | + "github.com/tiptok/gocomm/pkg/cache" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
11 | + "gorm.io/gorm" | ||
12 | +) | ||
13 | + | ||
14 | +type ArticleCategoryRepository struct { | ||
15 | + *cache.CachedRepository | ||
16 | +} | ||
17 | + | ||
18 | +func (repository *ArticleCategoryRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) { | ||
19 | + var ( | ||
20 | + err error | ||
21 | + m = &models.ArticleCategory{} | ||
22 | + tx = conn.DB() | ||
23 | + ) | ||
24 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
25 | + return nil, err | ||
26 | + } | ||
27 | + if tx = tx.Model(m).Save(m); tx.Error != nil { | ||
28 | + return nil, tx.Error | ||
29 | + } | ||
30 | + dm.Id = m.Id | ||
31 | + return repository.ModelToDomainModel(m) | ||
32 | + | ||
33 | +} | ||
34 | + | ||
35 | +func (repository *ArticleCategoryRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) { | ||
36 | + var ( | ||
37 | + err error | ||
38 | + m *models.ArticleCategory | ||
39 | + tx = conn.DB() | ||
40 | + ) | ||
41 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
42 | + return nil, err | ||
43 | + } | ||
44 | + queryFunc := func() (interface{}, error) { | ||
45 | + tx = tx.Model(m).Updates(m) | ||
46 | + return nil, tx.Error | ||
47 | + } | ||
48 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
49 | + return nil, err | ||
50 | + } | ||
51 | + return repository.ModelToDomainModel(m) | ||
52 | +} | ||
53 | + | ||
54 | +func (repository *ArticleCategoryRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) { | ||
55 | + var ( | ||
56 | + err error | ||
57 | + m *models.ArticleCategory | ||
58 | + tx = transaction.DB() | ||
59 | + ) | ||
60 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
61 | + return nil, err | ||
62 | + } | ||
63 | + oldVersion := dm.Version | ||
64 | + m.Version += 1 | ||
65 | + queryFunc := func() (interface{}, error) { | ||
66 | + tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m) | ||
67 | + if tx.RowsAffected == 0 { | ||
68 | + return nil, domain.ErrUpdateFail | ||
69 | + } | ||
70 | + return nil, tx.Error | ||
71 | + } | ||
72 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
73 | + return nil, err | ||
74 | + } | ||
75 | + return repository.ModelToDomainModel(m) | ||
76 | +} | ||
77 | + | ||
78 | +func (repository *ArticleCategoryRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) { | ||
79 | + var ( | ||
80 | + tx = conn.DB() | ||
81 | + m = &models.ArticleCategory{Id: dm.Identify().(int64)} | ||
82 | + ) | ||
83 | + queryFunc := func() (interface{}, error) { | ||
84 | + tx = tx.Where("id = ?", m.Id).Delete(m) | ||
85 | + return m, tx.Error | ||
86 | + } | ||
87 | + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
88 | + return dm, err | ||
89 | + } | ||
90 | + return repository.ModelToDomainModel(m) | ||
91 | +} | ||
92 | + | ||
93 | +func (repository *ArticleCategoryRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleCategory, error) { | ||
94 | + var ( | ||
95 | + err error | ||
96 | + tx = conn.DB() | ||
97 | + m = new(models.ArticleCategory) | ||
98 | + ) | ||
99 | + queryFunc := func() (interface{}, error) { | ||
100 | + tx = tx.Model(m).Where("id = ?", id).First(m) | ||
101 | + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { | ||
102 | + return nil, domain.ErrNotFound | ||
103 | + } | ||
104 | + return m, tx.Error | ||
105 | + } | ||
106 | + cacheModel := new(models.ArticleCategory) | ||
107 | + cacheModel.Id = id | ||
108 | + if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil { | ||
109 | + return nil, err | ||
110 | + } | ||
111 | + return repository.ModelToDomainModel(m) | ||
112 | +} | ||
113 | + | ||
114 | +func (repository *ArticleCategoryRepository) FindOneByName(ctx context.Context, conn transaction.Conn, companyId int64, name string) (*domain.ArticleCategory, error) { | ||
115 | + var ( | ||
116 | + err error | ||
117 | + tx = conn.DB() | ||
118 | + m = new(models.ArticleCategory) | ||
119 | + ) | ||
120 | + queryFunc := func() (interface{}, error) { | ||
121 | + tx = tx.Model(m).Where("company_id = ?", companyId).Where("name = ?", name).First(m) | ||
122 | + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { | ||
123 | + return nil, domain.ErrNotFound | ||
124 | + } | ||
125 | + return m, tx.Error | ||
126 | + } | ||
127 | + if _, err = repository.Query(queryFunc); err != nil { | ||
128 | + return nil, err | ||
129 | + } | ||
130 | + return repository.ModelToDomainModel(m) | ||
131 | +} | ||
132 | + | ||
133 | +func (repository *ArticleCategoryRepository) Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.ArticleCategory, error) { | ||
134 | + var ( | ||
135 | + tx = conn.DB() | ||
136 | + ms []*models.ArticleCategory | ||
137 | + dms = make([]*domain.ArticleCategory, 0) | ||
138 | + total int64 | ||
139 | + ) | ||
140 | + queryFunc := func() (interface{}, error) { | ||
141 | + tx = tx.Model(&ms).Where("company_id = ?", companyId) | ||
142 | + if v, ok := queryOptions["enable"]; ok { | ||
143 | + tx.Where("enable = ?", v) | ||
144 | + } | ||
145 | + tx.Order("sort_by asc").Order("id asc") | ||
146 | + if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | ||
147 | + return dms, tx.Error | ||
148 | + } | ||
149 | + return dms, nil | ||
150 | + } | ||
151 | + | ||
152 | + if _, err := repository.Query(queryFunc); err != nil { | ||
153 | + return 0, nil, err | ||
154 | + } | ||
155 | + | ||
156 | + for _, item := range ms { | ||
157 | + if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
158 | + return 0, dms, err | ||
159 | + } else { | ||
160 | + dms = append(dms, dm) | ||
161 | + } | ||
162 | + } | ||
163 | + return total, dms, nil | ||
164 | +} | ||
165 | + | ||
166 | +func (repository *ArticleCategoryRepository) ModelToDomainModel(from *models.ArticleCategory) (*domain.ArticleCategory, error) { | ||
167 | + to := &domain.ArticleCategory{} | ||
168 | + err := copier.Copy(to, from) | ||
169 | + return to, err | ||
170 | +} | ||
171 | + | ||
172 | +func (repository *ArticleCategoryRepository) DomainModelToModel(from *domain.ArticleCategory) (*models.ArticleCategory, error) { | ||
173 | + to := &models.ArticleCategory{} | ||
174 | + err := copier.Copy(to, from) | ||
175 | + return to, err | ||
176 | +} | ||
177 | + | ||
178 | +func NewArticleCategoryRepository(cache *cache.CachedRepository) domain.ArticleCategoryRepository { | ||
179 | + return &ArticleCategoryRepository{CachedRepository: cache} | ||
180 | +} |
-
请 注册 或 登录 后发表评论