合并分支 'dev' 到 'test'
Dev 查看合并请求 !9
正在显示
15 个修改的文件
包含
665 行增加
和
38 行删除
@@ -111,6 +111,34 @@ | @@ -111,6 +111,34 @@ | ||
111 | ] | 111 | ] |
112 | } | 112 | } |
113 | }, | 113 | }, |
114 | + "v1/mini/article/delete": { | ||
115 | + "delete": { | ||
116 | + "summary": "小程序删除我的帖子", | ||
117 | + "operationId": "MiniArticleDelete", | ||
118 | + "responses": { | ||
119 | + "200": { | ||
120 | + "description": "A successful response.", | ||
121 | + "schema": { | ||
122 | + "$ref": "#/definitions/MiniArticleDeleteResponse" | ||
123 | + } | ||
124 | + } | ||
125 | + }, | ||
126 | + "parameters": [ | ||
127 | + { | ||
128 | + "name": "body", | ||
129 | + "in": "body", | ||
130 | + "required": true, | ||
131 | + "schema": { | ||
132 | + "$ref": "#/definitions/MiniArticleDeleteRequest" | ||
133 | + } | ||
134 | + } | ||
135 | + ], | ||
136 | + "requestBody": {}, | ||
137 | + "tags": [ | ||
138 | + "article" | ||
139 | + ] | ||
140 | + } | ||
141 | + }, | ||
114 | "v1/mini/article/mark/list": { | 142 | "v1/mini/article/mark/list": { |
115 | "post": { | 143 | "post": { |
116 | "summary": "小程序获取文章浏览记录", | 144 | "summary": "小程序获取文章浏览记录", |
@@ -223,6 +251,34 @@ | @@ -223,6 +251,34 @@ | ||
223 | ] | 251 | ] |
224 | } | 252 | } |
225 | }, | 253 | }, |
254 | + "v1/mini/article/set_view": { | ||
255 | + "post": { | ||
256 | + "summary": "小程序我的帖子设置可见范围", | ||
257 | + "operationId": "MiniArticleSetView", | ||
258 | + "responses": { | ||
259 | + "200": { | ||
260 | + "description": "A successful response.", | ||
261 | + "schema": { | ||
262 | + "$ref": "#/definitions/MiniArticleSetViewResponse" | ||
263 | + } | ||
264 | + } | ||
265 | + }, | ||
266 | + "parameters": [ | ||
267 | + { | ||
268 | + "name": "body", | ||
269 | + "in": "body", | ||
270 | + "required": true, | ||
271 | + "schema": { | ||
272 | + "$ref": "#/definitions/MiniArticleSetViewRequest" | ||
273 | + } | ||
274 | + } | ||
275 | + ], | ||
276 | + "requestBody": {}, | ||
277 | + "tags": [ | ||
278 | + "article" | ||
279 | + ] | ||
280 | + } | ||
281 | + }, | ||
226 | "v1/mini/article/user_like/list": { | 282 | "v1/mini/article/user_like/list": { |
227 | "post": { | 283 | "post": { |
228 | "summary": "小程序获取文章的点赞人员列表", | 284 | "summary": "小程序获取文章的点赞人员列表", |
@@ -2211,6 +2267,22 @@ | @@ -2211,6 +2267,22 @@ | ||
2211 | ] | 2267 | ] |
2212 | } | 2268 | } |
2213 | }, | 2269 | }, |
2270 | + "v1/system/article_category/init": { | ||
2271 | + "get": { | ||
2272 | + "summary": "标签分类初始化", | ||
2273 | + "operationId": "articleCategoryInit", | ||
2274 | + "responses": { | ||
2275 | + "200": { | ||
2276 | + "description": "A successful response.", | ||
2277 | + "schema": {} | ||
2278 | + } | ||
2279 | + }, | ||
2280 | + "requestBody": {}, | ||
2281 | + "tags": [ | ||
2282 | + "tags" | ||
2283 | + ] | ||
2284 | + } | ||
2285 | + }, | ||
2214 | "v1/system/article_category/options": { | 2286 | "v1/system/article_category/options": { |
2215 | "get": { | 2287 | "get": { |
2216 | "summary": "标签分类下拉列表", | 2288 | "summary": "标签分类下拉列表", |
@@ -2223,6 +2295,16 @@ | @@ -2223,6 +2295,16 @@ | ||
2223 | } | 2295 | } |
2224 | } | 2296 | } |
2225 | }, | 2297 | }, |
2298 | + "parameters": [ | ||
2299 | + { | ||
2300 | + "name": "enable", | ||
2301 | + "description": " 启用状态 1:启用", | ||
2302 | + "in": "query", | ||
2303 | + "required": false, | ||
2304 | + "type": "integer", | ||
2305 | + "format": "int32" | ||
2306 | + } | ||
2307 | + ], | ||
2226 | "requestBody": {}, | 2308 | "requestBody": {}, |
2227 | "tags": [ | 2309 | "tags": [ |
2228 | "tags" | 2310 | "tags" |
@@ -3670,6 +3752,19 @@ | @@ -3670,6 +3752,19 @@ | ||
3670 | "type": "integer", | 3752 | "type": "integer", |
3671 | "format": "int32", | 3753 | "format": "int32", |
3672 | "description": "是否隐藏 [0显示、1不显示]" | 3754 | "description": "是否隐藏 [0显示、1不显示]" |
3755 | + }, | ||
3756 | + "targetUser": { | ||
3757 | + "type": "integer", | ||
3758 | + "format": "int32", | ||
3759 | + "description": "分发方式 [0分发给所有人、1分发给指定的人]" | ||
3760 | + }, | ||
3761 | + "whoRead": { | ||
3762 | + "type": "array", | ||
3763 | + "items": { | ||
3764 | + "type": "integer", | ||
3765 | + "format": "int64" | ||
3766 | + }, | ||
3767 | + "description": "谁可查看" | ||
3673 | } | 3768 | } |
3674 | }, | 3769 | }, |
3675 | "title": "ArticleSearchMe", | 3770 | "title": "ArticleSearchMe", |
@@ -3681,7 +3776,9 @@ | @@ -3681,7 +3776,9 @@ | ||
3681 | "countLove", | 3776 | "countLove", |
3682 | "countComment", | 3777 | "countComment", |
3683 | "countRead", | 3778 | "countRead", |
3684 | - "show" | 3779 | + "show", |
3780 | + "targetUser", | ||
3781 | + "whoRead" | ||
3685 | ] | 3782 | ] |
3686 | }, | 3783 | }, |
3687 | "ArticleSection": { | 3784 | "ArticleSection": { |
@@ -3881,10 +3978,10 @@ | @@ -3881,10 +3978,10 @@ | ||
3881 | "CategoryOptionsRequest": { | 3978 | "CategoryOptionsRequest": { |
3882 | "type": "object", | 3979 | "type": "object", |
3883 | "properties": { | 3980 | "properties": { |
3884 | - "": { | 3981 | + "enable": { |
3885 | "type": "integer", | 3982 | "type": "integer", |
3886 | - "format": "int64", | ||
3887 | - "description": " 公司ID" | 3983 | + "format": "int32", |
3984 | + "description": " 启用状态 1:启用" | ||
3888 | } | 3985 | } |
3889 | }, | 3986 | }, |
3890 | "title": "CategoryOptionsRequest" | 3987 | "title": "CategoryOptionsRequest" |
@@ -4702,6 +4799,39 @@ | @@ -4702,6 +4799,39 @@ | ||
4702 | "id" | 4799 | "id" |
4703 | ] | 4800 | ] |
4704 | }, | 4801 | }, |
4802 | + "MiniArticleDeleteRequest": { | ||
4803 | + "type": "object", | ||
4804 | + "properties": { | ||
4805 | + "id": { | ||
4806 | + "type": "integer", | ||
4807 | + "format": "int64", | ||
4808 | + "description": "id" | ||
4809 | + } | ||
4810 | + }, | ||
4811 | + "title": "MiniArticleDeleteRequest", | ||
4812 | + "required": [ | ||
4813 | + "id" | ||
4814 | + ] | ||
4815 | + }, | ||
4816 | + "MiniArticleDeleteResponse": { | ||
4817 | + "type": "object", | ||
4818 | + "properties": { | ||
4819 | + "id": { | ||
4820 | + "type": "integer", | ||
4821 | + "format": "int64", | ||
4822 | + "description": "id" | ||
4823 | + }, | ||
4824 | + "title": { | ||
4825 | + "type": "string", | ||
4826 | + "description": "标题" | ||
4827 | + } | ||
4828 | + }, | ||
4829 | + "title": "MiniArticleDeleteResponse", | ||
4830 | + "required": [ | ||
4831 | + "id", | ||
4832 | + "title" | ||
4833 | + ] | ||
4834 | + }, | ||
4705 | "MiniArticleDraftCreateRequest": { | 4835 | "MiniArticleDraftCreateRequest": { |
4706 | "type": "object", | 4836 | "type": "object", |
4707 | "properties": { | 4837 | "properties": { |
@@ -5475,6 +5605,57 @@ | @@ -5475,6 +5605,57 @@ | ||
5475 | "id" | 5605 | "id" |
5476 | ] | 5606 | ] |
5477 | }, | 5607 | }, |
5608 | + "MiniArticleSetViewRequest": { | ||
5609 | + "type": "object", | ||
5610 | + "properties": { | ||
5611 | + "id": { | ||
5612 | + "type": "integer", | ||
5613 | + "format": "int64", | ||
5614 | + "description": "id" | ||
5615 | + }, | ||
5616 | + "whoRead": { | ||
5617 | + "type": "array", | ||
5618 | + "items": { | ||
5619 | + "type": "integer", | ||
5620 | + "format": "int64" | ||
5621 | + }, | ||
5622 | + "description": "谁可查看" | ||
5623 | + } | ||
5624 | + }, | ||
5625 | + "title": "MiniArticleSetViewRequest", | ||
5626 | + "required": [ | ||
5627 | + "id", | ||
5628 | + "whoRead" | ||
5629 | + ] | ||
5630 | + }, | ||
5631 | + "MiniArticleSetViewResponse": { | ||
5632 | + "type": "object", | ||
5633 | + "properties": { | ||
5634 | + "id": { | ||
5635 | + "type": "integer", | ||
5636 | + "format": "int64", | ||
5637 | + "description": "id" | ||
5638 | + }, | ||
5639 | + "title": { | ||
5640 | + "type": "string", | ||
5641 | + "description": "标题" | ||
5642 | + }, | ||
5643 | + "whoRead": { | ||
5644 | + "type": "array", | ||
5645 | + "items": { | ||
5646 | + "type": "integer", | ||
5647 | + "format": "int64" | ||
5648 | + }, | ||
5649 | + "description": "谁可查看" | ||
5650 | + } | ||
5651 | + }, | ||
5652 | + "title": "MiniArticleSetViewResponse", | ||
5653 | + "required": [ | ||
5654 | + "id", | ||
5655 | + "title", | ||
5656 | + "whoRead" | ||
5657 | + ] | ||
5658 | + }, | ||
5478 | "MiniBeLikedRequest": { | 5659 | "MiniBeLikedRequest": { |
5479 | "type": "object", | 5660 | "type": "object", |
5480 | "properties": { | 5661 | "properties": { |
@@ -8034,6 +8215,13 @@ | @@ -8034,6 +8215,13 @@ | ||
8034 | }, | 8215 | }, |
8035 | "description": "谁可查看" | 8216 | "description": "谁可查看" |
8036 | }, | 8217 | }, |
8218 | + "whoReadInfo": { | ||
8219 | + "type": "array", | ||
8220 | + "items": { | ||
8221 | + "$ref": "#/definitions/UserShowName" | ||
8222 | + }, | ||
8223 | + "description": " 谁可查看" | ||
8224 | + }, | ||
8037 | "whoReview": { | 8225 | "whoReview": { |
8038 | "type": "array", | 8226 | "type": "array", |
8039 | "items": { | 8227 | "items": { |
@@ -8042,6 +8230,13 @@ | @@ -8042,6 +8230,13 @@ | ||
8042 | }, | 8230 | }, |
8043 | "description": "谁可评论" | 8231 | "description": "谁可评论" |
8044 | }, | 8232 | }, |
8233 | + "whoReviewInfo": { | ||
8234 | + "type": "array", | ||
8235 | + "items": { | ||
8236 | + "$ref": "#/definitions/UserShowName" | ||
8237 | + }, | ||
8238 | + "description": " 谁可评论" | ||
8239 | + }, | ||
8045 | "matchUrl": { | 8240 | "matchUrl": { |
8046 | "type": "object", | 8241 | "type": "object", |
8047 | "description": " 匹配文章内容中的url文本" | 8242 | "description": " 匹配文章内容中的url文本" |
@@ -8062,6 +8257,8 @@ | @@ -8062,6 +8257,8 @@ | ||
8062 | "content", | 8257 | "content", |
8063 | "authorId", | 8258 | "authorId", |
8064 | "targetUser", | 8259 | "targetUser", |
8260 | + "whoReadInfo", | ||
8261 | + "whoReviewInfo", | ||
8065 | "tags" | 8262 | "tags" |
8066 | ] | 8263 | ] |
8067 | }, | 8264 | }, |
@@ -10104,10 +10301,6 @@ | @@ -10104,10 +10301,6 @@ | ||
10104 | "type": "string", | 10301 | "type": "string", |
10105 | "description": " 标签名称" | 10302 | "description": " 标签名称" |
10106 | }, | 10303 | }, |
10107 | - "category": { | ||
10108 | - "type": "string", | ||
10109 | - "description": " 标签分类" | ||
10110 | - }, | ||
10111 | "remark": { | 10304 | "remark": { |
10112 | "type": "string", | 10305 | "type": "string", |
10113 | "description": " 备注" | 10306 | "description": " 备注" |
@@ -10119,13 +10312,18 @@ | @@ -10119,13 +10312,18 @@ | ||
10119 | "type": "integer", | 10312 | "type": "integer", |
10120 | "format": "int32", | 10313 | "format": "int32", |
10121 | "description": "排序" | 10314 | "description": "排序" |
10315 | + }, | ||
10316 | + "categoryId": { | ||
10317 | + "type": "integer", | ||
10318 | + "format": "int64", | ||
10319 | + "description": " 标签Id" | ||
10122 | } | 10320 | } |
10123 | }, | 10321 | }, |
10124 | "title": "TagCreateRequest", | 10322 | "title": "TagCreateRequest", |
10125 | "required": [ | 10323 | "required": [ |
10126 | "image", | 10324 | "image", |
10127 | "name", | 10325 | "name", |
10128 | - "category" | 10326 | + "categoryId" |
10129 | ] | 10327 | ] |
10130 | }, | 10328 | }, |
10131 | "TagCreateResponse": { | 10329 | "TagCreateResponse": { |
@@ -10189,9 +10387,10 @@ | @@ -10189,9 +10387,10 @@ | ||
10189 | "type": "string", | 10387 | "type": "string", |
10190 | "description": " 标签名称" | 10388 | "description": " 标签名称" |
10191 | }, | 10389 | }, |
10192 | - "category": { | ||
10193 | - "type": "string", | ||
10194 | - "description": " 标签分类" | 10390 | + "categoryId": { |
10391 | + "type": "integer", | ||
10392 | + "format": "int64", | ||
10393 | + "description": " 标签Id" | ||
10195 | }, | 10394 | }, |
10196 | "remark": { | 10395 | "remark": { |
10197 | "type": "string", | 10396 | "type": "string", |
@@ -10211,7 +10410,7 @@ | @@ -10211,7 +10410,7 @@ | ||
10211 | "id", | 10410 | "id", |
10212 | "image", | 10411 | "image", |
10213 | "name", | 10412 | "name", |
10214 | - "category" | 10413 | + "categoryId" |
10215 | ] | 10414 | ] |
10216 | }, | 10415 | }, |
10217 | "TagEditResponse": { | 10416 | "TagEditResponse": { |
@@ -10262,6 +10461,11 @@ | @@ -10262,6 +10461,11 @@ | ||
10262 | "type": "string", | 10461 | "type": "string", |
10263 | "description": " 标签分类" | 10462 | "description": " 标签分类" |
10264 | }, | 10463 | }, |
10464 | + "categoryId": { | ||
10465 | + "type": "integer", | ||
10466 | + "format": "int64", | ||
10467 | + "description": " 标签分类Id" | ||
10468 | + }, | ||
10265 | "remark": { | 10469 | "remark": { |
10266 | "type": "string", | 10470 | "type": "string", |
10267 | "description": " 备注" | 10471 | "description": " 备注" |
@@ -10281,6 +10485,7 @@ | @@ -10281,6 +10485,7 @@ | ||
10281 | "image", | 10485 | "image", |
10282 | "name", | 10486 | "name", |
10283 | "category", | 10487 | "category", |
10488 | + "categoryId", | ||
10284 | "remark", | 10489 | "remark", |
10285 | "other" | 10490 | "other" |
10286 | ] | 10491 | ] |
@@ -10303,6 +10508,11 @@ | @@ -10303,6 +10508,11 @@ | ||
10303 | "type": "string", | 10508 | "type": "string", |
10304 | "description": " 标签分类" | 10509 | "description": " 标签分类" |
10305 | }, | 10510 | }, |
10511 | + "categoryId": { | ||
10512 | + "type": "integer", | ||
10513 | + "format": "int64", | ||
10514 | + "description": " 标签分类Id" | ||
10515 | + }, | ||
10306 | "remark": { | 10516 | "remark": { |
10307 | "type": "string", | 10517 | "type": "string", |
10308 | "description": " 备注" | 10518 | "description": " 备注" |
@@ -10315,6 +10525,11 @@ | @@ -10315,6 +10525,11 @@ | ||
10315 | "type": "integer", | 10525 | "type": "integer", |
10316 | "format": "int32", | 10526 | "format": "int32", |
10317 | "description": " 排序" | 10527 | "description": " 排序" |
10528 | + }, | ||
10529 | + "removeable": { | ||
10530 | + "type": "boolean", | ||
10531 | + "format": "boolean", | ||
10532 | + "description": " 可删除" | ||
10318 | } | 10533 | } |
10319 | }, | 10534 | }, |
10320 | "title": "TagItem", | 10535 | "title": "TagItem", |
@@ -10323,6 +10538,7 @@ | @@ -10323,6 +10538,7 @@ | ||
10323 | "image", | 10538 | "image", |
10324 | "name", | 10539 | "name", |
10325 | "category", | 10540 | "category", |
10541 | + "categoryId", | ||
10326 | "remark", | 10542 | "remark", |
10327 | "createdAt" | 10543 | "createdAt" |
10328 | ] | 10544 | ] |
@@ -10345,8 +10561,9 @@ | @@ -10345,8 +10561,9 @@ | ||
10345 | "tagName": { | 10561 | "tagName": { |
10346 | "type": "string" | 10562 | "type": "string" |
10347 | }, | 10563 | }, |
10348 | - "category": { | ||
10349 | - "type": "string" | 10564 | + "categoryId": { |
10565 | + "type": "integer", | ||
10566 | + "format": "int64" | ||
10350 | }, | 10567 | }, |
10351 | "remark": { | 10568 | "remark": { |
10352 | "type": "string" | 10569 | "type": "string" |
@@ -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) |
@@ -107,6 +107,10 @@ type ( | @@ -107,6 +107,10 @@ type ( | ||
107 | CountComment int `json:"countComment"` //评论数量 | 107 | CountComment int `json:"countComment"` //评论数量 |
108 | CountRead int `json:"countRead"` //浏览数量 | 108 | CountRead int `json:"countRead"` //浏览数量 |
109 | 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-用户删除 | ||
110 | } | 114 | } |
111 | 115 | ||
112 | SystemArticleSearchMeRequest { | 116 | SystemArticleSearchMeRequest { |
@@ -122,6 +126,30 @@ type ( | @@ -122,6 +126,30 @@ type ( | ||
122 | } | 126 | } |
123 | ) | 127 | ) |
124 | 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 | + | ||
125 | //小程序端获取文章有哪些人进行了点赞 | 153 | //小程序端获取文章有哪些人进行了点赞 |
126 | type ( | 154 | type ( |
127 | MiniUserLikeArticleRequest { | 155 | MiniUserLikeArticleRequest { |
@@ -509,6 +537,7 @@ type ( | @@ -509,6 +537,7 @@ type ( | ||
509 | type ( | 537 | type ( |
510 | SystemArticleDeleteRequest { | 538 | SystemArticleDeleteRequest { |
511 | Id int64 `json:"id"` //id | 539 | Id int64 `json:"id"` //id |
540 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
512 | } | 541 | } |
513 | SystemArticleDeleteResponse { | 542 | SystemArticleDeleteResponse { |
514 | Id int64 `json:"id"` //id | 543 | Id int64 `json:"id"` //id |
@@ -788,6 +817,7 @@ type ( | @@ -788,6 +817,7 @@ type ( | ||
788 | type ( | 817 | type ( |
789 | SystemArticleDeletedRestoreRequest { | 818 | SystemArticleDeletedRestoreRequest { |
790 | Id int64 `json:"id"` //ID | 819 | Id int64 `json:"id"` //ID |
820 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
791 | } | 821 | } |
792 | SystemArticleDeletedRestoreResponse { | 822 | SystemArticleDeletedRestoreResponse { |
793 | Id int64 `json:"id"` //ID | 823 | Id int64 `json:"id"` //ID |
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 | +} |
@@ -505,6 +505,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -505,6 +505,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
505 | }, | 505 | }, |
506 | { | 506 | { |
507 | 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, | ||
508 | Path: "/article_draft", | 518 | Path: "/article_draft", |
509 | Handler: article.MiniCreateArticleDraftHandler(serverCtx), | 519 | Handler: article.MiniCreateArticleDraftHandler(serverCtx), |
510 | }, | 520 | }, |
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 | +} |
@@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
4 | "context" | 4 | "context" |
5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 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" | 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" | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
9 | 10 | ||
@@ -35,10 +36,28 @@ func (l *SystemDeleteArticleLogic) SystemDeleteArticle(req *types.SystemArticleD | @@ -35,10 +36,28 @@ func (l *SystemDeleteArticleLogic) SystemDeleteArticle(req *types.SystemArticleD | ||
35 | if err != nil { | 36 | if err != nil { |
36 | return nil, xerr.NewErrMsgErr("帖子不存在", err) | 37 | return nil, xerr.NewErrMsgErr("帖子不存在", err) |
37 | } | 38 | } |
39 | + //文章内容 | ||
40 | + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", req.Id) | ||
41 | + _, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, l.conn, queryOption) | ||
42 | + if err != nil { | ||
43 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
44 | + } | ||
38 | userToken := contextdata.GetUserTokenFromCtx(l.ctx) | 45 | userToken := contextdata.GetUserTokenFromCtx(l.ctx) |
39 | if userToken.CompanyId != article.CompanyId { | 46 | if userToken.CompanyId != article.CompanyId { |
40 | return nil, xerr.NewErrMsg("您没有权限") | 47 | return nil, xerr.NewErrMsg("您没有权限") |
41 | } | 48 | } |
49 | + // 获取当前用户信息 | ||
50 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
51 | + if err != nil { | ||
52 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
53 | + } | ||
54 | + operator := domain.UserSimple{ | ||
55 | + Id: userToken.UserId, | ||
56 | + Name: userMe.User.NickName, | ||
57 | + Avatar: userMe.User.Avatar, | ||
58 | + CompanyId: userToken.CompanyId, | ||
59 | + Company: userMe.CurrentCompany.Name, | ||
60 | + } | ||
42 | article.DeletedType = domain.ArticleDeletedTypeOperator | 61 | article.DeletedType = domain.ArticleDeletedTypeOperator |
43 | err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | 62 | err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { |
44 | //更新删除类型 | 63 | //更新删除类型 |
@@ -50,6 +69,12 @@ func (l *SystemDeleteArticleLogic) SystemDeleteArticle(req *types.SystemArticleD | @@ -50,6 +69,12 @@ func (l *SystemDeleteArticleLogic) SystemDeleteArticle(req *types.SystemArticleD | ||
50 | if err != nil { | 69 | if err != nil { |
51 | return err | 70 | return err |
52 | } | 71 | } |
72 | + var backup domain.ArticleBackup | ||
73 | + backup.MakeBackup(operator, article, sectionList, "删除") | ||
74 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, conn, &backup) | ||
75 | + if err != nil { | ||
76 | + return xerr.NewErrMsgErr("保存文章内容失败", err) | ||
77 | + } | ||
53 | return nil | 78 | return nil |
54 | }, true) | 79 | }, true) |
55 | if err != nil { | 80 | if err != nil { |
@@ -3,6 +3,9 @@ package article | @@ -3,6 +3,9 @@ package article | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 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" | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
7 | 10 | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
@@ -33,7 +36,46 @@ func (l *SystemRestoreArticleDeletedLogic) SystemRestoreArticleDeleted(req *type | @@ -33,7 +36,46 @@ func (l *SystemRestoreArticleDeletedLogic) SystemRestoreArticleDeleted(req *type | ||
33 | if err != nil { | 36 | if err != nil { |
34 | return nil, xerr.NewErrMsgErr("帖子不存在", err) | 37 | return nil, xerr.NewErrMsgErr("帖子不存在", err) |
35 | } | 38 | } |
36 | - _, err = l.svcCtx.ArticleRepository.Restore(l.ctx, l.conn, article) | 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) | ||
37 | if err != nil { | 79 | if err != nil { |
38 | return nil, xerr.NewErrMsg("恢复帖子失败") | 80 | return nil, xerr.NewErrMsg("恢复帖子失败") |
39 | } | 81 | } |
@@ -984,6 +984,10 @@ type ArticleSearchMe struct { | @@ -984,6 +984,10 @@ type ArticleSearchMe struct { | ||
984 | CountComment int `json:"countComment"` //评论数量 | 984 | CountComment int `json:"countComment"` //评论数量 |
985 | CountRead int `json:"countRead"` //浏览数量 | 985 | CountRead int `json:"countRead"` //浏览数量 |
986 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 986 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
987 | + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
988 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
989 | + IsDel int `json:"isDel"` //是否删除 1-删除 0-否 | ||
990 | + DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除 | ||
987 | } | 991 | } |
988 | 992 | ||
989 | type SystemArticleSearchMeRequest struct { | 993 | type SystemArticleSearchMeRequest struct { |
@@ -999,6 +1003,26 @@ type SystemArticleSearchMeResponse struct { | @@ -999,6 +1003,26 @@ type SystemArticleSearchMeResponse struct { | ||
999 | List []ArticleSearchMe `json:"list"` | 1003 | List []ArticleSearchMe `json:"list"` |
1000 | } | 1004 | } |
1001 | 1005 | ||
1006 | +type MiniArticleSetViewRequest struct { | ||
1007 | + Id int64 `json:"id"` //id | ||
1008 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
1009 | +} | ||
1010 | + | ||
1011 | +type MiniArticleSetViewResponse struct { | ||
1012 | + Id int64 `json:"id"` //id | ||
1013 | + Title string `json:"title"` //标题 | ||
1014 | + WhoRead []int64 `json:"whoRead"` //谁可查看 | ||
1015 | +} | ||
1016 | + | ||
1017 | +type MiniArticleDeleteRequest struct { | ||
1018 | + Id int64 `json:"id"` //id | ||
1019 | +} | ||
1020 | + | ||
1021 | +type MiniArticleDeleteResponse struct { | ||
1022 | + Id int64 `json:"id"` //id | ||
1023 | + Title string `json:"title"` //标题 | ||
1024 | +} | ||
1025 | + | ||
1002 | type MiniUserLikeArticleRequest struct { | 1026 | type MiniUserLikeArticleRequest struct { |
1003 | ArticleId int64 `json:"articleId"` // 文章id | 1027 | ArticleId int64 `json:"articleId"` // 文章id |
1004 | CompanyId int64 `json:",optional"` //公司id | 1028 | CompanyId int64 `json:",optional"` //公司id |
@@ -1347,7 +1371,8 @@ type SystemArticleCreateResponse struct { | @@ -1347,7 +1371,8 @@ type SystemArticleCreateResponse struct { | ||
1347 | } | 1371 | } |
1348 | 1372 | ||
1349 | type SystemArticleDeleteRequest struct { | 1373 | type SystemArticleDeleteRequest struct { |
1350 | - Id int64 `json:"id"` //id | 1374 | + Id int64 `json:"id"` //id |
1375 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
1351 | } | 1376 | } |
1352 | 1377 | ||
1353 | type SystemArticleDeleteResponse struct { | 1378 | type SystemArticleDeleteResponse struct { |
@@ -1606,7 +1631,8 @@ type SystemArticleSearchDeletedItem struct { | @@ -1606,7 +1631,8 @@ type SystemArticleSearchDeletedItem struct { | ||
1606 | } | 1631 | } |
1607 | 1632 | ||
1608 | type SystemArticleDeletedRestoreRequest struct { | 1633 | type SystemArticleDeletedRestoreRequest struct { |
1609 | - Id int64 `json:"id"` //ID | 1634 | + Id int64 `json:"id"` //ID |
1635 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
1610 | } | 1636 | } |
1611 | 1637 | ||
1612 | type SystemArticleDeletedRestoreResponse struct { | 1638 | type SystemArticleDeletedRestoreResponse struct { |
@@ -207,6 +207,9 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -207,6 +207,9 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
207 | if v, ok := queryOptions["isDel"]; ok { | 207 | if v, ok := queryOptions["isDel"]; ok { |
208 | tx = tx.Unscoped().Where("is_del = ?", v) | 208 | tx = tx.Unscoped().Where("is_del = ?", v) |
209 | } | 209 | } |
210 | + if _, ok := queryOptions["showDel"]; ok { | ||
211 | + tx = tx.Unscoped() | ||
212 | + } | ||
210 | //删除时间 | 213 | //删除时间 |
211 | if v, ok := queryOptions["beginDeletedAt"]; ok { | 214 | if v, ok := queryOptions["beginDeletedAt"]; ok { |
212 | tx = tx.Where("deleted_at >= ?", v) | 215 | tx = tx.Where("deleted_at >= ?", v) |
@@ -447,6 +450,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | @@ -447,6 +450,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | ||
447 | Source: from.Source, | 450 | Source: from.Source, |
448 | Operator: from.Operator, | 451 | Operator: from.Operator, |
449 | DeletedType: from.DeletedType, | 452 | DeletedType: from.DeletedType, |
453 | + IsDel: int(from.IsDel), | ||
450 | } | 454 | } |
451 | return to, nil | 455 | return to, nil |
452 | } | 456 | } |
@@ -14,6 +14,7 @@ type Article struct { | @@ -14,6 +14,7 @@ type Article struct { | ||
14 | CreatedAt int64 `json:"createdAt,omitempty"` | 14 | CreatedAt int64 `json:"createdAt,omitempty"` |
15 | UpdatedAt int64 `json:"updatedAt,omitempty"` | 15 | UpdatedAt int64 `json:"updatedAt,omitempty"` |
16 | DeletedAt int64 `json:"deletedAt,omitempty"` | 16 | DeletedAt int64 `json:"deletedAt,omitempty"` |
17 | + IsDel int `json:"isDel,omitempty"` | ||
17 | Version int `json:"version,omitempty"` | 18 | Version int `json:"version,omitempty"` |
18 | AuthorId int64 `json:"authorId"` // 发布人 | 19 | AuthorId int64 `json:"authorId"` // 发布人 |
19 | Author UserSimple `json:"author"` // 发布人 | 20 | Author UserSimple `json:"author"` // 发布人 |
@@ -147,26 +147,27 @@ func (bk *ArticleBackup) MakeBackup(operator UserSimple, article *Article, secti | @@ -147,26 +147,27 @@ func (bk *ArticleBackup) MakeBackup(operator UserSimple, article *Article, secti | ||
147 | sectionBackup[i] = *section[i] | 147 | sectionBackup[i] = *section[i] |
148 | } | 148 | } |
149 | b := ArticleBackup{ | 149 | b := ArticleBackup{ |
150 | - Id: 0, | ||
151 | - CompanyId: article.CompanyId, | ||
152 | - CreatedAt: 0, | ||
153 | - UpdatedAt: 0, | ||
154 | - DeletedAt: 0, | ||
155 | - Version: article.Version, | ||
156 | - Operator: operator, | ||
157 | - ArticleId: article.Id, | ||
158 | - Title: article.Title, | ||
159 | - Section: sectionBackup, | ||
160 | - Images: make([]Image, len(article.Images)), | ||
161 | - Videos: make([]Video, len(article.Videos)), | ||
162 | - Action: action, | ||
163 | - TargetUser: article.TargetUser, | ||
164 | - WhoRead: article.WhoRead, | ||
165 | - WhoReview: article.WhoReview, | ||
166 | - Tags: article.Tags, | ||
167 | - MatchUrl: map[string]string{}, | ||
168 | - Show: article.Show, | ||
169 | - Location: article.Location, | 150 | + Id: 0, |
151 | + CompanyId: article.CompanyId, | ||
152 | + CreatedAt: 0, | ||
153 | + UpdatedAt: 0, | ||
154 | + DeletedAt: 0, | ||
155 | + Version: article.Version, | ||
156 | + Operator: operator, | ||
157 | + ArticleId: article.Id, | ||
158 | + Title: article.Title, | ||
159 | + Section: sectionBackup, | ||
160 | + Images: make([]Image, len(article.Images)), | ||
161 | + Videos: make([]Video, len(article.Videos)), | ||
162 | + Action: action, | ||
163 | + TargetUser: article.TargetUser, | ||
164 | + WhoRead: article.WhoRead, | ||
165 | + WhoReview: article.WhoReview, | ||
166 | + Tags: article.Tags, | ||
167 | + MatchUrl: map[string]string{}, | ||
168 | + Show: article.Show, | ||
169 | + Location: article.Location, | ||
170 | + ChangeField: []string{}, | ||
170 | } | 171 | } |
171 | if action == "原始版本" { | 172 | if action == "原始版本" { |
172 | b.ChangeField = append(b.ChangeField, "Section") | 173 | b.ChangeField = append(b.ChangeField, "Section") |
-
请 注册 或 登录 后发表评论