Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss into dev
正在显示
25 个修改的文件
包含
937 行增加
和
345 行删除
@@ -723,6 +723,24 @@ | @@ -723,6 +723,24 @@ | ||
723 | ] | 723 | ] |
724 | } | 724 | } |
725 | }, | 725 | }, |
726 | + "v1/mini/show/home_page": { | ||
727 | + "get": { | ||
728 | + "summary": "小程序首页数据展示", | ||
729 | + "operationId": "MiniShowHomePage", | ||
730 | + "responses": { | ||
731 | + "200": { | ||
732 | + "description": "A successful response.", | ||
733 | + "schema": { | ||
734 | + "$ref": "#/definitions/MiniHomePageRespose" | ||
735 | + } | ||
736 | + } | ||
737 | + }, | ||
738 | + "requestBody": {}, | ||
739 | + "tags": [ | ||
740 | + "article" | ||
741 | + ] | ||
742 | + } | ||
743 | + }, | ||
726 | "v1/mini/user/apply-join-company": { | 744 | "v1/mini/user/apply-join-company": { |
727 | "post": { | 745 | "post": { |
728 | "summary": "用户申请加入公司", | 746 | "summary": "用户申请加入公司", |
@@ -1361,6 +1379,34 @@ | @@ -1361,6 +1379,34 @@ | ||
1361 | ] | 1379 | ] |
1362 | } | 1380 | } |
1363 | }, | 1381 | }, |
1382 | + "v1/system/article_comment/search": { | ||
1383 | + "post": { | ||
1384 | + "summary": "管理后台文章评论列表", | ||
1385 | + "operationId": "SystemArticleCommentSearch", | ||
1386 | + "responses": { | ||
1387 | + "200": { | ||
1388 | + "description": "A successful response.", | ||
1389 | + "schema": { | ||
1390 | + "$ref": "#/definitions/SystemArticleCommentSearchResponse" | ||
1391 | + } | ||
1392 | + } | ||
1393 | + }, | ||
1394 | + "parameters": [ | ||
1395 | + { | ||
1396 | + "name": "body", | ||
1397 | + "in": "body", | ||
1398 | + "required": true, | ||
1399 | + "schema": { | ||
1400 | + "$ref": "#/definitions/SystemArticleCommentSearchRequest" | ||
1401 | + } | ||
1402 | + } | ||
1403 | + ], | ||
1404 | + "requestBody": {}, | ||
1405 | + "tags": [ | ||
1406 | + "comment" | ||
1407 | + ] | ||
1408 | + } | ||
1409 | + }, | ||
1364 | "v1/system/article_comment/search/me": { | 1410 | "v1/system/article_comment/search/me": { |
1365 | "post": { | 1411 | "post": { |
1366 | "summary": "小程序获取回复@人可选列表", | 1412 | "summary": "小程序获取回复@人可选列表", |
@@ -1443,6 +1489,24 @@ | @@ -1443,6 +1489,24 @@ | ||
1443 | ] | 1489 | ] |
1444 | } | 1490 | } |
1445 | }, | 1491 | }, |
1492 | + "v1/system/article_tag/options": { | ||
1493 | + "get": { | ||
1494 | + "summary": "后台标签下拉列表", | ||
1495 | + "operationId": "Options", | ||
1496 | + "responses": { | ||
1497 | + "200": { | ||
1498 | + "description": "A successful response.", | ||
1499 | + "schema": { | ||
1500 | + "$ref": "#/definitions/TagOptionsResponse" | ||
1501 | + } | ||
1502 | + } | ||
1503 | + }, | ||
1504 | + "requestBody": {}, | ||
1505 | + "tags": [ | ||
1506 | + "tags" | ||
1507 | + ] | ||
1508 | + } | ||
1509 | + }, | ||
1446 | "v1/system/article_tag/search": { | 1510 | "v1/system/article_tag/search": { |
1447 | "post": { | 1511 | "post": { |
1448 | "summary": "后台搜索标签", | 1512 | "summary": "后台搜索标签", |
@@ -2308,6 +2372,52 @@ | @@ -2308,6 +2372,52 @@ | ||
2308 | "totalComment" | 2372 | "totalComment" |
2309 | ] | 2373 | ] |
2310 | }, | 2374 | }, |
2375 | + "ArticleTagCount": { | ||
2376 | + "type": "object", | ||
2377 | + "properties": { | ||
2378 | + "tagGroup": { | ||
2379 | + "type": "string", | ||
2380 | + "description": " 标签分组" | ||
2381 | + }, | ||
2382 | + "tagId": { | ||
2383 | + "type": "integer", | ||
2384 | + "format": "int64", | ||
2385 | + "description": " 标签id" | ||
2386 | + }, | ||
2387 | + "tagImage": { | ||
2388 | + "type": "string", | ||
2389 | + "description": " 对应的图标" | ||
2390 | + }, | ||
2391 | + "tagName": { | ||
2392 | + "type": "string", | ||
2393 | + "description": " 标签名称" | ||
2394 | + }, | ||
2395 | + "tagRemark": { | ||
2396 | + "type": "string", | ||
2397 | + "description": " 标签备注" | ||
2398 | + }, | ||
2399 | + "totalArticle": { | ||
2400 | + "type": "integer", | ||
2401 | + "format": "int32", | ||
2402 | + "description": " 总的文章数量" | ||
2403 | + }, | ||
2404 | + "readArticle": { | ||
2405 | + "type": "integer", | ||
2406 | + "format": "int32", | ||
2407 | + "description": " 已读的标签数量" | ||
2408 | + } | ||
2409 | + }, | ||
2410 | + "title": "ArticleTagCount", | ||
2411 | + "required": [ | ||
2412 | + "tagGroup", | ||
2413 | + "tagId", | ||
2414 | + "tagImage", | ||
2415 | + "tagName", | ||
2416 | + "tagRemark", | ||
2417 | + "totalArticle", | ||
2418 | + "readArticle" | ||
2419 | + ] | ||
2420 | + }, | ||
2311 | "ArticleTagGroup": { | 2421 | "ArticleTagGroup": { |
2312 | "type": "object", | 2422 | "type": "object", |
2313 | "properties": { | 2423 | "properties": { |
@@ -4033,6 +4143,35 @@ | @@ -4033,6 +4143,35 @@ | ||
4033 | }, | 4143 | }, |
4034 | "title": "MiniGetArticleCommentResponse" | 4144 | "title": "MiniGetArticleCommentResponse" |
4035 | }, | 4145 | }, |
4146 | + "MiniHomePageRequest": { | ||
4147 | + "type": "object", | ||
4148 | + "properties": { | ||
4149 | + "": { | ||
4150 | + "type": "integer", | ||
4151 | + "format": "int64" | ||
4152 | + }, | ||
4153 | + "": { | ||
4154 | + "type": "integer", | ||
4155 | + "format": "int64" | ||
4156 | + } | ||
4157 | + }, | ||
4158 | + "title": "MiniHomePageRequest" | ||
4159 | + }, | ||
4160 | + "MiniHomePageRespose": { | ||
4161 | + "type": "object", | ||
4162 | + "properties": { | ||
4163 | + "tags": { | ||
4164 | + "type": "array", | ||
4165 | + "items": { | ||
4166 | + "$ref": "#/definitions/ArticleTagCount" | ||
4167 | + } | ||
4168 | + } | ||
4169 | + }, | ||
4170 | + "title": "MiniHomePageRespose", | ||
4171 | + "required": [ | ||
4172 | + "tags" | ||
4173 | + ] | ||
4174 | + }, | ||
4036 | "MiniListArticleCommentRequest": { | 4175 | "MiniListArticleCommentRequest": { |
4037 | "type": "object", | 4176 | "type": "object", |
4038 | "properties": { | 4177 | "properties": { |
@@ -4330,21 +4469,6 @@ | @@ -4330,21 +4469,6 @@ | ||
4330 | "$ref": "#/definitions/UserItem", | 4469 | "$ref": "#/definitions/UserItem", |
4331 | "description": " 用户信息" | 4470 | "description": " 用户信息" |
4332 | }, | 4471 | }, |
4333 | - "totalArticle": { | ||
4334 | - "type": "integer", | ||
4335 | - "format": "int64", | ||
4336 | - "description": " 累计信息发布" | ||
4337 | - }, | ||
4338 | - "totalLoved": { | ||
4339 | - "type": "integer", | ||
4340 | - "format": "int64", | ||
4341 | - "description": " 累计收到的赞" | ||
4342 | - }, | ||
4343 | - "totalAccepted": { | ||
4344 | - "type": "integer", | ||
4345 | - "format": "int64", | ||
4346 | - "description": " 累计被采纳" | ||
4347 | - }, | ||
4348 | "accounts": { | 4472 | "accounts": { |
4349 | "type": "array", | 4473 | "type": "array", |
4350 | "items": { | 4474 | "items": { |
@@ -4363,9 +4487,6 @@ | @@ -4363,9 +4487,6 @@ | ||
4363 | "title": "MiniUserInfoResponse", | 4487 | "title": "MiniUserInfoResponse", |
4364 | "required": [ | 4488 | "required": [ |
4365 | "user", | 4489 | "user", |
4366 | - "totalArticle", | ||
4367 | - "totalLoved", | ||
4368 | - "totalAccepted", | ||
4369 | "accounts", | 4490 | "accounts", |
4370 | "auths" | 4491 | "auths" |
4371 | ] | 4492 | ] |
@@ -4891,6 +5012,87 @@ | @@ -4891,6 +5012,87 @@ | ||
4891 | "value" | 5012 | "value" |
4892 | ] | 5013 | ] |
4893 | }, | 5014 | }, |
5015 | + "SystemArticleCommentSearchItem": { | ||
5016 | + "type": "object", | ||
5017 | + "properties": { | ||
5018 | + "id": { | ||
5019 | + "type": "integer", | ||
5020 | + "format": "int64" | ||
5021 | + }, | ||
5022 | + "pid": { | ||
5023 | + "type": "integer", | ||
5024 | + "format": "int64" | ||
5025 | + }, | ||
5026 | + "topId": { | ||
5027 | + "type": "integer", | ||
5028 | + "format": "int64" | ||
5029 | + }, | ||
5030 | + "articleId": { | ||
5031 | + "type": "integer", | ||
5032 | + "format": "int64", | ||
5033 | + "description": " 文章id" | ||
5034 | + }, | ||
5035 | + "sectionId": { | ||
5036 | + "type": "integer", | ||
5037 | + "format": "int64", | ||
5038 | + "description": " 段落id" | ||
5039 | + }, | ||
5040 | + "fromUserId": { | ||
5041 | + "type": "integer", | ||
5042 | + "format": "int64", | ||
5043 | + "description": " 填写评论的人" | ||
5044 | + }, | ||
5045 | + "fromUser": { | ||
5046 | + "$ref": "#/definitions/CommentAuthor", | ||
5047 | + "description": " 填写评论的人" | ||
5048 | + }, | ||
5049 | + "countReply": { | ||
5050 | + "type": "integer", | ||
5051 | + "format": "int32", | ||
5052 | + "description": " 回复数量" | ||
5053 | + }, | ||
5054 | + "countUserLove": { | ||
5055 | + "type": "integer", | ||
5056 | + "format": "int32", | ||
5057 | + "description": " 用户点赞数量" | ||
5058 | + }, | ||
5059 | + "countAdminLove": { | ||
5060 | + "type": "integer", | ||
5061 | + "format": "int32", | ||
5062 | + "description": " 运营点赞数量" | ||
5063 | + }, | ||
5064 | + "createdAt": { | ||
5065 | + "type": "integer", | ||
5066 | + "format": "int64", | ||
5067 | + "description": " 评论时间" | ||
5068 | + }, | ||
5069 | + "content": { | ||
5070 | + "type": "string", | ||
5071 | + "description": " 评论的内容" | ||
5072 | + }, | ||
5073 | + "show": { | ||
5074 | + "type": "integer", | ||
5075 | + "format": "int32", | ||
5076 | + "description": " 显示状态" | ||
5077 | + } | ||
5078 | + }, | ||
5079 | + "title": "SystemArticleCommentSearchItem", | ||
5080 | + "required": [ | ||
5081 | + "id", | ||
5082 | + "pid", | ||
5083 | + "topId", | ||
5084 | + "articleId", | ||
5085 | + "sectionId", | ||
5086 | + "fromUserId", | ||
5087 | + "fromUser", | ||
5088 | + "countReply", | ||
5089 | + "countUserLove", | ||
5090 | + "countAdminLove", | ||
5091 | + "createdAt", | ||
5092 | + "content", | ||
5093 | + "show" | ||
5094 | + ] | ||
5095 | + }, | ||
4894 | "SystemArticleCommentSearchMeRequest": { | 5096 | "SystemArticleCommentSearchMeRequest": { |
4895 | "type": "object", | 5097 | "type": "object", |
4896 | "properties": { | 5098 | "properties": { |
@@ -4945,6 +5147,76 @@ | @@ -4945,6 +5147,76 @@ | ||
4945 | "total" | 5147 | "total" |
4946 | ] | 5148 | ] |
4947 | }, | 5149 | }, |
5150 | + "SystemArticleCommentSearchRequest": { | ||
5151 | + "type": "object", | ||
5152 | + "properties": { | ||
5153 | + "page": { | ||
5154 | + "type": "integer", | ||
5155 | + "format": "int32" | ||
5156 | + }, | ||
5157 | + "size": { | ||
5158 | + "type": "integer", | ||
5159 | + "format": "int32" | ||
5160 | + }, | ||
5161 | + "articleId": { | ||
5162 | + "type": "integer", | ||
5163 | + "format": "int64", | ||
5164 | + "description": " 文章ID" | ||
5165 | + }, | ||
5166 | + "topId": { | ||
5167 | + "type": "integer", | ||
5168 | + "format": "int64", | ||
5169 | + "description": " 文章顶层ID" | ||
5170 | + }, | ||
5171 | + "authorId": { | ||
5172 | + "type": "integer", | ||
5173 | + "format": "int64", | ||
5174 | + "description": " 用户" | ||
5175 | + }, | ||
5176 | + "show": { | ||
5177 | + "type": "integer", | ||
5178 | + "format": "int32", | ||
5179 | + "description": " 显示状态" | ||
5180 | + }, | ||
5181 | + "beginTime": { | ||
5182 | + "type": "integer", | ||
5183 | + "format": "int64", | ||
5184 | + "description": " 开始时间" | ||
5185 | + }, | ||
5186 | + "endTime": { | ||
5187 | + "type": "integer", | ||
5188 | + "format": "int64", | ||
5189 | + "description": " 结束时间" | ||
5190 | + } | ||
5191 | + }, | ||
5192 | + "title": "SystemArticleCommentSearchRequest", | ||
5193 | + "required": [ | ||
5194 | + "page", | ||
5195 | + "size", | ||
5196 | + "articleId", | ||
5197 | + "topId" | ||
5198 | + ] | ||
5199 | + }, | ||
5200 | + "SystemArticleCommentSearchResponse": { | ||
5201 | + "type": "object", | ||
5202 | + "properties": { | ||
5203 | + "total": { | ||
5204 | + "type": "integer", | ||
5205 | + "format": "int64" | ||
5206 | + }, | ||
5207 | + "list": { | ||
5208 | + "type": "array", | ||
5209 | + "items": { | ||
5210 | + "$ref": "#/definitions/SystemArticleCommentSearchItem" | ||
5211 | + } | ||
5212 | + } | ||
5213 | + }, | ||
5214 | + "title": "SystemArticleCommentSearchResponse", | ||
5215 | + "required": [ | ||
5216 | + "total", | ||
5217 | + "list" | ||
5218 | + ] | ||
5219 | + }, | ||
4948 | "SystemArticleGetHistoryRequest": { | 5220 | "SystemArticleGetHistoryRequest": { |
4949 | "type": "object", | 5221 | "type": "object", |
4950 | "properties": { | 5222 | "properties": { |
@@ -5578,14 +5850,10 @@ | @@ -5578,14 +5850,10 @@ | ||
5578 | }, | 5850 | }, |
5579 | "description": " 评论人" | 5851 | "description": " 评论人" |
5580 | }, | 5852 | }, |
5581 | - "location": { | ||
5582 | - "$ref": "#/definitions/Location", | ||
5583 | - "description": " 坐标" | ||
5584 | - }, | ||
5585 | "targetUser": { | 5853 | "targetUser": { |
5586 | "type": "integer", | 5854 | "type": "integer", |
5587 | "format": "int32", | 5855 | "format": "int32", |
5588 | - "description": "分发方式 [0分发给所有人、1分发给指定的人]" | 5856 | + "description": " 分发方式 [0分发给所有人、1分发给指定的人]" |
5589 | }, | 5857 | }, |
5590 | "tags": { | 5858 | "tags": { |
5591 | "type": "array", | 5859 | "type": "array", |
@@ -5594,6 +5862,10 @@ | @@ -5594,6 +5862,10 @@ | ||
5594 | "format": "int64" | 5862 | "format": "int64" |
5595 | }, | 5863 | }, |
5596 | "description": " 标签" | 5864 | "description": " 标签" |
5865 | + }, | ||
5866 | + "AccessToken": { | ||
5867 | + "type": "string", | ||
5868 | + "description": " 授权token" | ||
5597 | } | 5869 | } |
5598 | }, | 5870 | }, |
5599 | "title": "SystemArticleUpdateRequest", | 5871 | "title": "SystemArticleUpdateRequest", |
@@ -5605,9 +5877,9 @@ | @@ -5605,9 +5877,9 @@ | ||
5605 | "images", | 5877 | "images", |
5606 | "whoRead", | 5878 | "whoRead", |
5607 | "whoReview", | 5879 | "whoReview", |
5608 | - "location", | ||
5609 | "targetUser", | 5880 | "targetUser", |
5610 | - "tags" | 5881 | + "tags", |
5882 | + "x-mmm-accesstoken" | ||
5611 | ] | 5883 | ] |
5612 | }, | 5884 | }, |
5613 | "SystemArticleUpdateResponse": { | 5885 | "SystemArticleUpdateResponse": { |
@@ -5643,7 +5915,7 @@ | @@ -5643,7 +5915,7 @@ | ||
5643 | "format": "int32", | 5915 | "format": "int32", |
5644 | "description": "点赞数量" | 5916 | "description": "点赞数量" |
5645 | }, | 5917 | }, |
5646 | - "CountComment": { | 5918 | + "countComment": { |
5647 | "type": "integer", | 5919 | "type": "integer", |
5648 | "format": "int32", | 5920 | "format": "int32", |
5649 | "description": "评论数量" | 5921 | "description": "评论数量" |
@@ -5675,7 +5947,7 @@ | @@ -5675,7 +5947,7 @@ | ||
5675 | "images", | 5947 | "images", |
5676 | "createdAt", | 5948 | "createdAt", |
5677 | "countLove", | 5949 | "countLove", |
5678 | - "CountComment", | 5950 | + "countComment", |
5679 | "show", | 5951 | "show", |
5680 | "tags", | 5952 | "tags", |
5681 | "targetUser" | 5953 | "targetUser" |
@@ -6368,6 +6640,71 @@ | @@ -6368,6 +6640,71 @@ | ||
6368 | "list" | 6640 | "list" |
6369 | ] | 6641 | ] |
6370 | }, | 6642 | }, |
6643 | + "TagOptionValue": { | ||
6644 | + "type": "object", | ||
6645 | + "properties": { | ||
6646 | + "label": { | ||
6647 | + "type": "string", | ||
6648 | + "description": " 名称" | ||
6649 | + }, | ||
6650 | + "value": { | ||
6651 | + "type": "integer", | ||
6652 | + "format": "int64", | ||
6653 | + "description": " 标签ID" | ||
6654 | + } | ||
6655 | + }, | ||
6656 | + "title": "TagOptionValue", | ||
6657 | + "required": [ | ||
6658 | + "label", | ||
6659 | + "value" | ||
6660 | + ] | ||
6661 | + }, | ||
6662 | + "TagOptions": { | ||
6663 | + "type": "object", | ||
6664 | + "properties": { | ||
6665 | + "label": { | ||
6666 | + "type": "string", | ||
6667 | + "description": " 分组名称" | ||
6668 | + }, | ||
6669 | + "options": { | ||
6670 | + "type": "array", | ||
6671 | + "items": { | ||
6672 | + "$ref": "#/definitions/TagOptionValue" | ||
6673 | + } | ||
6674 | + } | ||
6675 | + }, | ||
6676 | + "title": "TagOptions", | ||
6677 | + "required": [ | ||
6678 | + "label", | ||
6679 | + "options" | ||
6680 | + ] | ||
6681 | + }, | ||
6682 | + "TagOptionsRequest": { | ||
6683 | + "type": "object", | ||
6684 | + "properties": { | ||
6685 | + "": { | ||
6686 | + "type": "integer", | ||
6687 | + "format": "int64", | ||
6688 | + "description": " 公司ID" | ||
6689 | + } | ||
6690 | + }, | ||
6691 | + "title": "TagOptionsRequest" | ||
6692 | + }, | ||
6693 | + "TagOptionsResponse": { | ||
6694 | + "type": "object", | ||
6695 | + "properties": { | ||
6696 | + "options": { | ||
6697 | + "type": "array", | ||
6698 | + "items": { | ||
6699 | + "$ref": "#/definitions/TagOptions" | ||
6700 | + } | ||
6701 | + } | ||
6702 | + }, | ||
6703 | + "title": "TagOptionsResponse", | ||
6704 | + "required": [ | ||
6705 | + "options" | ||
6706 | + ] | ||
6707 | + }, | ||
6371 | "UserFollowItem": { | 6708 | "UserFollowItem": { |
6372 | "type": "object", | 6709 | "type": "object", |
6373 | "properties": { | 6710 | "properties": { |
@@ -32,7 +32,11 @@ service Core { | @@ -32,7 +32,11 @@ service Core { | ||
32 | 32 | ||
33 | @doc "后台搜索标签" | 33 | @doc "后台搜索标签" |
34 | @handler SearchTag | 34 | @handler SearchTag |
35 | - post/article_tag/search (TagListRequest) returns (TagListResponse) | 35 | + post /article_tag/search (TagListRequest) returns (TagListResponse) |
36 | + | ||
37 | + @doc "后台标签下拉列表" | ||
38 | + @handler Options | ||
39 | + get /article_tag/options (TagOptionsRequest) returns (TagOptionsResponse) | ||
36 | } | 40 | } |
37 | 41 | ||
38 | // 创建标签 | 42 | // 创建标签 |
@@ -118,3 +122,21 @@ type ( | @@ -118,3 +122,21 @@ type ( | ||
118 | Id int64 `json:"id"` | 122 | Id int64 `json:"id"` |
119 | } | 123 | } |
120 | ) | 124 | ) |
125 | + | ||
126 | +//标签下拉列表 | ||
127 | +type ( | ||
128 | + TagOptionsRequest { | ||
129 | + CompanyId int64 `path:",optional"` // 公司ID | ||
130 | + } | ||
131 | + TagOptionsResponse { | ||
132 | + Options []TagOptions `json:"options"` | ||
133 | + } | ||
134 | + TagOptions { | ||
135 | + Label string `json:"label"` // 分组名称 | ||
136 | + Options []TagOptionValue `json:"options"` | ||
137 | + } | ||
138 | + TagOptionValue { | ||
139 | + Label string `json:"label"` // 名称 | ||
140 | + Value int64 `json:"value"` // 标签ID | ||
141 | + } | ||
142 | +) |
@@ -388,6 +388,9 @@ type ( | @@ -388,6 +388,9 @@ type ( | ||
388 | Tags []string `json:"tags"` //标签 | 388 | Tags []string `json:"tags"` //标签 |
389 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 389 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
390 | } | 390 | } |
391 | +) | ||
392 | +// 管理后台编辑文章 | ||
393 | +type ( | ||
391 | //编辑 | 394 | //编辑 |
392 | SystemArticleUpdateRequest { | 395 | SystemArticleUpdateRequest { |
393 | Id int64 `json:"id"` | 396 | Id int64 `json:"id"` |
@@ -398,7 +401,6 @@ type ( | @@ -398,7 +401,6 @@ type ( | ||
398 | Images []string `json:"images"` // 图片 | 401 | Images []string `json:"images"` // 图片 |
399 | WhoRead []int64 `json:"whoRead"` // 谁可以看 | 402 | WhoRead []int64 `json:"whoRead"` // 谁可以看 |
400 | WhoReview []int64 `json:"whoReview"` // 评论人 | 403 | WhoReview []int64 `json:"whoReview"` // 评论人 |
401 | - Location Location `json:"location"` // 坐标 | ||
402 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | 404 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
403 | Tags []int64 `json:"tags"` // 标签 | 405 | Tags []int64 `json:"tags"` // 标签 |
404 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token | 406 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token |
@@ -415,6 +417,9 @@ type ( | @@ -415,6 +417,9 @@ type ( | ||
415 | Tags []int64 `json:"tags"` //标签 | 417 | Tags []int64 `json:"tags"` //标签 |
416 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 418 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
417 | } | 419 | } |
420 | +) | ||
421 | +// 管理后台编辑历史列表 | ||
422 | +type ( | ||
418 | //历史 | 423 | //历史 |
419 | SystemArticleHistoryRequest { | 424 | SystemArticleHistoryRequest { |
420 | ArticleId int64 `json:"articleId"` //文章ID | 425 | ArticleId int64 `json:"articleId"` //文章ID |
@@ -434,6 +439,9 @@ type ( | @@ -434,6 +439,9 @@ type ( | ||
434 | Action string `json:"action"` //编辑类型 | 439 | Action string `json:"action"` //编辑类型 |
435 | UpdatedAt int64 `json:"updatedAt"` //编辑时间 | 440 | UpdatedAt int64 `json:"updatedAt"` //编辑时间 |
436 | } | 441 | } |
442 | +) | ||
443 | +// 管理后台历史记录详情 | ||
444 | +type ( | ||
437 | SystemArticleGetHistoryRequest { | 445 | SystemArticleGetHistoryRequest { |
438 | Id int64 `path:"id"` //id | 446 | Id int64 `path:"id"` //id |
439 | CompanyId int64 `path:",optional"` | 447 | CompanyId int64 `path:",optional"` |
@@ -453,6 +461,9 @@ type ( | @@ -453,6 +461,9 @@ type ( | ||
453 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | 461 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
454 | Tags []int64 `json:"tags"` // 标签 | 462 | Tags []int64 `json:"tags"` // 标签 |
455 | } | 463 | } |
464 | +) | ||
465 | +// 管理后台文章恢复 | ||
466 | +type ( | ||
456 | SystemArticleRestoreRequest { | 467 | SystemArticleRestoreRequest { |
457 | Id int64 `json:"id"` //ID | 468 | Id int64 `json:"id"` //ID |
458 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token | 469 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token |
@@ -492,10 +503,10 @@ type ( | @@ -492,10 +503,10 @@ type ( | ||
492 | Size int `json:"size"` | 503 | Size int `json:"size"` |
493 | CompanyId int64 `json:",optional"` | 504 | CompanyId int64 `json:",optional"` |
494 | UserId int64 `json:",optional"` | 505 | UserId int64 `json:",optional"` |
495 | - TagGroup string `json:"tagGroup"` | 506 | + TagCategory string `json:"tagCategory"` |
496 | TagId int64 `json:"tagId"` | 507 | TagId int64 `json:"tagId"` |
497 | BeginTime int64 `json:"beginTime"` | 508 | BeginTime int64 `json:"beginTime"` |
498 | - EndTime int `json:"endTime"` | 509 | + EndTime int64 `json:"endTime"` |
499 | SearchWord string `json:"searchWord"` | 510 | SearchWord string `json:"searchWord"` |
500 | } | 511 | } |
501 | // | 512 | // |
@@ -15,7 +15,6 @@ info( | @@ -15,7 +15,6 @@ info( | ||
15 | jwt: MiniAuth | 15 | jwt: MiniAuth |
16 | ) | 16 | ) |
17 | service Core { | 17 | service Core { |
18 | - | ||
19 | @doc "小程序填写文章的评论" | 18 | @doc "小程序填写文章的评论" |
20 | @handler MiniCreateArticleComment | 19 | @handler MiniCreateArticleComment |
21 | post /article_comment (MiniCreateArticleCommentRequest) returns (MiniCreateArticleCommentResponse) | 20 | post /article_comment (MiniCreateArticleCommentRequest) returns (MiniCreateArticleCommentResponse) |
@@ -52,6 +51,11 @@ service Core { | @@ -52,6 +51,11 @@ service Core { | ||
52 | @doc "小程序获取回复@人可选列表" | 51 | @doc "小程序获取回复@人可选列表" |
53 | @handler SystemArticleCommentSearchMe | 52 | @handler SystemArticleCommentSearchMe |
54 | post /article_comment/search/me (SystemArticleCommentSearchMeRequest) returns (SystemArticleCommentSearchMeResponse) | 53 | post /article_comment/search/me (SystemArticleCommentSearchMeRequest) returns (SystemArticleCommentSearchMeResponse) |
54 | + | ||
55 | + @doc "管理后台文章评论列表" | ||
56 | + @handler SystemArticleCommentSearch | ||
57 | + post /article_comment/search (SystemArticleCommentSearchRequest) returns (SystemArticleCommentSearchResponse) | ||
58 | + | ||
55 | } | 59 | } |
56 | 60 | ||
57 | //评论的填写人 | 61 | //评论的填写人 |
@@ -204,3 +208,35 @@ type ( | @@ -204,3 +208,35 @@ type ( | ||
204 | Total int64 `json:"total"` | 208 | Total int64 `json:"total"` |
205 | } | 209 | } |
206 | ) | 210 | ) |
211 | +// 文章里的评论列表 | ||
212 | +type ( | ||
213 | + SystemArticleCommentSearchRequest { | ||
214 | + Page int `json:"page"` | ||
215 | + Size int `json:"size"` | ||
216 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
217 | + TopId int64 `json:"topId"` // 文章顶层ID | ||
218 | + AuthorId int64 `json:"authorId,optional"` // 用户 | ||
219 | + Show int `json:"show,optional"` // 显示状态 | ||
220 | + BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
221 | + EndTime int64 `json:"endTime,optional"` // 结束时间 | ||
222 | + } | ||
223 | + SystemArticleCommentSearchResponse { | ||
224 | + Total int64 `json:"total"` | ||
225 | + List []SystemArticleCommentSearchItem `json:"list"` | ||
226 | + } | ||
227 | + SystemArticleCommentSearchItem { | ||
228 | + Id int64 `json:"id"` | ||
229 | + Pid int64 `json:"pid"` | ||
230 | + TopId int64 `json:"topId"` | ||
231 | + ArtitcleId int64 `json:"articleId"` // 文章id | ||
232 | + SectionId int64 `json:"sectionId"` // 段落id | ||
233 | + FromUserId int64 `json:"fromUserId"` // 填写评论的人 | ||
234 | + FromUser CommentAuthor `json:"fromUser"` // 填写评论的人 | ||
235 | + CountReply int `json:"countReply"` // 回复数量 | ||
236 | + CountUserLove int `json:"countUserLove"` // 用户点赞数量 | ||
237 | + CountAdminLove int `json:"countAdminLove"` // 运营点赞数量 | ||
238 | + CreatedAt int64 `json:"createdAt"` // 评论时间 | ||
239 | + Content string `json:"content"` // 评论的内容 | ||
240 | + Show int `json:"show"` // 显示状态 | ||
241 | + } | ||
242 | +) |
@@ -7,8 +7,11 @@ import ( | @@ -7,8 +7,11 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 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" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
10 | ) | 12 | ) |
11 | 13 | ||
14 | +// 小程序端搜索 | ||
12 | func MiniSearchArticlePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 15 | func MiniSearchArticlePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
13 | return func(w http.ResponseWriter, r *http.Request) { | 16 | return func(w http.ResponseWriter, r *http.Request) { |
14 | var req types.MiniSearchArticleRequest | 17 | var req types.MiniSearchArticleRequest |
@@ -18,11 +21,10 @@ func MiniSearchArticlePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -18,11 +21,10 @@ func MiniSearchArticlePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
18 | } | 21 | } |
19 | 22 | ||
20 | l := article.NewMiniSearchArticlePageLogic(r.Context(), svcCtx) | 23 | l := article.NewMiniSearchArticlePageLogic(r.Context(), svcCtx) |
24 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
25 | + req.UserId = token.UserId | ||
26 | + req.CompanyId = token.CompanyId | ||
21 | resp, err := l.MiniSearchArticlePage(&req) | 27 | resp, err := l.MiniSearchArticlePage(&req) |
22 | - if err != nil { | ||
23 | - httpx.ErrorCtx(r.Context(), w, err) | ||
24 | - } else { | ||
25 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
26 | - } | 28 | + result.HttpResult(r, w, resp, err) |
27 | } | 29 | } |
28 | } | 30 | } |
1 | +package comment | ||
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/comment" | ||
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 SystemArticleCommentSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleCommentSearchRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := comment.NewSystemArticleCommentSearchLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemArticleCommentSearch(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
@@ -64,6 +64,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -64,6 +64,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
64 | Path: "/article_comment/search/me", | 64 | Path: "/article_comment/search/me", |
65 | Handler: comment.SystemArticleCommentSearchMeHandler(serverCtx), | 65 | Handler: comment.SystemArticleCommentSearchMeHandler(serverCtx), |
66 | }, | 66 | }, |
67 | + { | ||
68 | + Method: http.MethodPost, | ||
69 | + Path: "/article_comment/search", | ||
70 | + Handler: comment.SystemArticleCommentSearchHandler(serverCtx), | ||
71 | + }, | ||
67 | }..., | 72 | }..., |
68 | ), | 73 | ), |
69 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 74 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
@@ -114,6 +119,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -114,6 +119,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
114 | Path: "/article_tag/search", | 119 | Path: "/article_tag/search", |
115 | Handler: tags.SearchTagHandler(serverCtx), | 120 | Handler: tags.SearchTagHandler(serverCtx), |
116 | }, | 121 | }, |
122 | + { | ||
123 | + Method: http.MethodGet, | ||
124 | + Path: "/article_tag/options", | ||
125 | + Handler: tags.OptionsHandler(serverCtx), | ||
126 | + }, | ||
117 | }, | 127 | }, |
118 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 128 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
119 | rest.WithPrefix("/v1/system"), | 129 | rest.WithPrefix("/v1/system"), |
1 | +package tags | ||
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/tags" | ||
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 OptionsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.TagOptionsRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := tags.NewOptionsLogic(r.Context(), svcCtx) | ||
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.CompanyId = token.CompanyId | ||
25 | + resp, err := l.Options(&req) | ||
26 | + result.HttpResult(r, w, resp, err) | ||
27 | + } | ||
28 | +} |
@@ -5,6 +5,8 @@ import ( | @@ -5,6 +5,8 @@ import ( | ||
5 | 5 | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 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" | 7 | "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" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
8 | 10 | ||
9 | "github.com/zeromicro/go-zero/core/logx" | 11 | "github.com/zeromicro/go-zero/core/logx" |
10 | ) | 12 | ) |
@@ -23,8 +25,59 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte | @@ -23,8 +25,59 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte | ||
23 | } | 25 | } |
24 | } | 26 | } |
25 | 27 | ||
28 | +// 小程序端搜索展示文章列表 | ||
26 | func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) { | 29 | func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) { |
27 | - // todo: add your logic here and delete this line | ||
28 | 30 | ||
29 | - return | 31 | + var conn = l.svcCtx.DefaultDBConn() |
32 | + | ||
33 | + cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId, | ||
34 | + req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size) | ||
35 | + if err != nil { | ||
36 | + return nil, xerr.NewErrMsgErr("获取文章列表失败", err) | ||
37 | + } | ||
38 | + | ||
39 | + articleIds := []int64{} | ||
40 | + for _, val := range articleList { | ||
41 | + articleIds = append(articleIds, val.Id) | ||
42 | + } | ||
43 | + | ||
44 | + readFlag := map[int64]struct{}{} | ||
45 | + | ||
46 | + if len(articleIds) > 0 { | ||
47 | + queryOption := domain.NewQueryOptions().WithFindOnly(). | ||
48 | + MustWithKV("userId", req.UserId).MustWithKV("articleIds", articleIds) | ||
49 | + _, userReadFlag, err := l.svcCtx.UserReadArticleRepository.Find(l.ctx, conn, queryOption) | ||
50 | + if err != nil { | ||
51 | + return nil, xerr.NewErrMsgErr("获取文章列表失败", err) | ||
52 | + } | ||
53 | + for _, val := range userReadFlag { | ||
54 | + readFlag[val.ArticleId] = struct{}{} | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + resp = &types.MiniSearchArticleResponse{ | ||
59 | + Total: int(cnt), | ||
60 | + List: make([]types.MiniSearchArticleItem, len(articleList)), | ||
61 | + } | ||
62 | + | ||
63 | + for i, val := range articleList { | ||
64 | + | ||
65 | + item := types.MiniSearchArticleItem{ | ||
66 | + ArticleId: val.Id, | ||
67 | + Title: val.Title, | ||
68 | + Author: val.Author.Name, | ||
69 | + Images: []string{}, | ||
70 | + CreatedAt: val.CreatedAt, | ||
71 | + MeReadFlag: 0, | ||
72 | + } | ||
73 | + if _, ok := readFlag[val.Id]; ok { | ||
74 | + item.MeReadFlag = 1 | ||
75 | + } | ||
76 | + for _, img := range val.Images { | ||
77 | + item.Images = append(item.Images, img.Url) | ||
78 | + } | ||
79 | + resp.List[i] = item | ||
80 | + } | ||
81 | + | ||
82 | + return resp, nil | ||
30 | } | 83 | } |
@@ -11,6 +11,7 @@ import ( | @@ -11,6 +11,7 @@ import ( | ||
11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" |
12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" |
13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
14 | + "strings" | ||
14 | 15 | ||
15 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 16 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
16 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 17 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
@@ -39,7 +40,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -39,7 +40,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
39 | if err != nil { | 40 | if err != nil { |
40 | return nil, xerr.NewErrMsgErr("帖子不存在", err) | 41 | return nil, xerr.NewErrMsgErr("帖子不存在", err) |
41 | } | 42 | } |
42 | - //获取图片的尺寸大小 | 43 | + // 获取图片的尺寸大小 |
43 | images := []domain.Image{} | 44 | images := []domain.Image{} |
44 | for _, val := range req.Images { | 45 | for _, val := range req.Images { |
45 | fInfo, _ := oss.GetImageInfo(val) | 46 | fInfo, _ := oss.GetImageInfo(val) |
@@ -51,29 +52,98 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -51,29 +52,98 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
51 | Height: h, | 52 | Height: h, |
52 | }) | 53 | }) |
53 | } | 54 | } |
55 | + //检查文章可被哪些人查看 | ||
56 | + whoRead := []int64{} | ||
57 | + if len(req.WhoRead) > 0 { | ||
58 | + whoRead = lo.Uniq(req.WhoRead) | ||
59 | + var u *domain.User | ||
60 | + for _, val := range whoRead { | ||
61 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, val) | ||
62 | + if err != nil { | ||
63 | + return nil, xerr.NewErrMsgErr("文章可查看人设置错误", err) | ||
64 | + } | ||
65 | + if u.CompanyId != article.CompanyId { | ||
66 | + return nil, xerr.NewErrMsg("文章可查看人设置错误") | ||
67 | + } | ||
68 | + } | ||
69 | + } | ||
70 | + //检查文章可被哪些人评论 | ||
71 | + whoReview := []int64{} | ||
72 | + if len(req.WhoReview) > 0 { | ||
73 | + whoReview = lo.Uniq(req.WhoReview) | ||
74 | + } | ||
75 | + //有指定可查看人的情况 | ||
76 | + if len(whoRead) > 0 { | ||
77 | + if len(whoReview) > 0 { | ||
78 | + // 检查 whoRead 是否 完全包含 whoReview | ||
79 | + ok := lo.Every(whoRead, whoReview) | ||
80 | + if !ok { | ||
81 | + return nil, xerr.NewErrMsg("文章可评论人设置错误") | ||
82 | + } | ||
83 | + } | ||
84 | + if len(whoReview) == 0 { | ||
85 | + //有指定可查看人 ,但未指定可评论人 | ||
86 | + return nil, xerr.NewErrMsg("文章可评论人设置错误") | ||
87 | + } | ||
88 | + } | ||
89 | + //没有指定可查看人的情况 | ||
90 | + if len(whoRead) == 0 { | ||
91 | + if len(whoReview) > 0 { | ||
92 | + // 未指定可查看人(全员可看),有指定可评论人, | ||
93 | + var u *domain.User | ||
94 | + for _, val := range whoReview { | ||
95 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, val) | ||
96 | + if err != nil { | ||
97 | + return nil, xerr.NewErrMsgErr("文章可评论人设置错误", err) | ||
98 | + } | ||
99 | + if u.CompanyId != article.CompanyId { | ||
100 | + return nil, xerr.NewErrMsg("文章可评论人设置错误") | ||
101 | + } | ||
102 | + } | ||
103 | + } | ||
104 | + } | ||
105 | + //验证tag | ||
106 | + if len(req.Tags) > 0 { | ||
107 | + req.Tags = lo.Uniq(req.Tags) | ||
108 | + for _, value := range req.Tags { | ||
109 | + t, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, value) | ||
110 | + if err != nil { | ||
111 | + return nil, xerr.NewErrMsgErr("文章标签设置错误", err) | ||
112 | + } | ||
113 | + if t.CompanyId != article.CompanyId { | ||
114 | + return nil, xerr.NewErrMsgErr("文章标签设置错误", err) | ||
115 | + } | ||
116 | + } | ||
117 | + } | ||
54 | article.Title = req.Title | 118 | article.Title = req.Title |
55 | article.Version = article.Version + 1 | 119 | article.Version = article.Version + 1 |
56 | article.Images = images | 120 | article.Images = images |
57 | - article.WhoRead = req.WhoRead | ||
58 | - article.WhoReview = req.WhoReview | 121 | + article.WhoRead = whoRead |
122 | + article.WhoReview = whoReview | ||
59 | article.TargetUser = domain.ArticleTarget(req.TargetUser) | 123 | article.TargetUser = domain.ArticleTarget(req.TargetUser) |
60 | - article.Location = domain.Location{ | ||
61 | - Longitude: req.Location.Longitude, | ||
62 | - Latitude: req.Location.Latitude, | ||
63 | - Descript: req.Location.Descript, | ||
64 | - } | ||
65 | article.Tags = req.Tags | 124 | article.Tags = req.Tags |
66 | //文章内容 | 125 | //文章内容 |
67 | articleSections := []domain.ArticleSection{} | 126 | articleSections := []domain.ArticleSection{} |
127 | + sortBy := 1 | ||
68 | lo.ForEach(req.Section, func(item types.ArticleSection, index int) { | 128 | lo.ForEach(req.Section, func(item types.ArticleSection, index int) { |
69 | - articleSections = append(articleSections, domain.ArticleSection{ | ||
70 | - Id: item.Id, | 129 | + strList := strings.Split(item.Content, "\n") |
130 | + for key, value := range strList { | ||
131 | + if value == "" { | ||
132 | + continue | ||
133 | + } | ||
134 | + section := domain.ArticleSection{ | ||
71 | CompanyId: article.CompanyId, | 135 | CompanyId: article.CompanyId, |
72 | Version: article.Version, | 136 | Version: article.Version, |
73 | ArticleId: article.Id, | 137 | ArticleId: article.Id, |
74 | - Content: item.Content, | ||
75 | - SortBy: index + 1, | ||
76 | - }) | 138 | + Content: value, |
139 | + SortBy: sortBy, | ||
140 | + } | ||
141 | + if key == 0 { | ||
142 | + section.Id = item.Id | ||
143 | + } | ||
144 | + articleSections = append(articleSections, section) | ||
145 | + sortBy++ | ||
146 | + } | ||
77 | }) | 147 | }) |
78 | //设置内容概要 | 148 | //设置内容概要 |
79 | if len(req.Section) > 0 { | 149 | if len(req.Section) > 0 { |
1 | +package comment | ||
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/xerr" | ||
8 | + | ||
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 | + "github.com/zeromicro/go-zero/core/logx" | ||
13 | +) | ||
14 | + | ||
15 | +type SystemArticleCommentSearchLogic struct { | ||
16 | + logx.Logger | ||
17 | + ctx context.Context | ||
18 | + svcCtx *svc.ServiceContext | ||
19 | +} | ||
20 | + | ||
21 | +func NewSystemArticleCommentSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleCommentSearchLogic { | ||
22 | + return &SystemArticleCommentSearchLogic{ | ||
23 | + Logger: logx.WithContext(ctx), | ||
24 | + ctx: ctx, | ||
25 | + svcCtx: svcCtx, | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types.SystemArticleCommentSearchRequest) (resp *types.SystemArticleCommentSearchResponse, err error) { | ||
30 | + var conn = l.svcCtx.DefaultDBConn() | ||
31 | + queryOptions := domain.NewQueryOptions(). | ||
32 | + WithOffsetLimit(req.Page, req.Size). | ||
33 | + WithKV("articleId", req.ArticleId). | ||
34 | + WithKV("topId", req.TopId). | ||
35 | + WithKV("fromUserId", req.AuthorId). | ||
36 | + WithKV("beginCreatedAt", req.BeginTime). | ||
37 | + WithKV("endCreatedAt", req.EndTime) | ||
38 | + total, comments, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOptions) | ||
39 | + if err != nil { | ||
40 | + return nil, xerr.NewErrMsgErr("获取文章评论失败", err) | ||
41 | + } | ||
42 | + resp = &types.SystemArticleCommentSearchResponse{ | ||
43 | + Total: total, | ||
44 | + List: make([]types.SystemArticleCommentSearchItem, 0), | ||
45 | + } | ||
46 | + lo.ForEach(comments, func(item *domain.ArticleComment, index int) { | ||
47 | + resp.List = append(resp.List, types.SystemArticleCommentSearchItem{ | ||
48 | + Id: item.Id, | ||
49 | + Pid: item.Pid, | ||
50 | + TopId: item.TopId, | ||
51 | + ArtitcleId: item.ArticleId, | ||
52 | + SectionId: item.SectionId, | ||
53 | + FromUserId: item.FromUserId, | ||
54 | + FromUser: types.CommentAuthor{ | ||
55 | + Id: item.FromUser.Id, | ||
56 | + Name: item.FromUser.Name, | ||
57 | + Avatar: item.FromUser.Avatar, | ||
58 | + Company: item.FromUser.Company, | ||
59 | + Position: item.FromUser.Position, | ||
60 | + }, | ||
61 | + CountReply: item.CountReply, | ||
62 | + CountUserLove: item.CountUserLove, | ||
63 | + CountAdminLove: item.CountAdminLove, | ||
64 | + CreatedAt: item.CreatedAt, | ||
65 | + Content: item.Content, | ||
66 | + Show: int(item.Show), | ||
67 | + }) | ||
68 | + }) | ||
69 | + return | ||
70 | +} |
@@ -48,7 +48,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res | @@ -48,7 +48,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res | ||
48 | var companyIdMap = map[int64]*domain.Company{} | 48 | var companyIdMap = map[int64]*domain.Company{} |
49 | var userIdMap = map[int64]*domain.User{} | 49 | var userIdMap = map[int64]*domain.User{} |
50 | var articleIdMap = map[int64]*domain.Article{} | 50 | var articleIdMap = map[int64]*domain.Article{} |
51 | - var commentIdMap = map[int64]*domain.Comment{} | 51 | + var commentIdMap = map[int64]*domain.ArticleComment{} |
52 | //var discussionIdMap = map[int64]int{} | 52 | //var discussionIdMap = map[int64]int{} |
53 | //var discussionOpinionIdMap = map[int64]int{} | 53 | //var discussionOpinionIdMap = map[int64]int{} |
54 | for _, item := range list { | 54 | for _, item := range list { |
@@ -126,7 +126,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res | @@ -126,7 +126,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res | ||
126 | 126 | ||
127 | // 获取评论 | 127 | // 获取评论 |
128 | if len(commentIds) > 0 { | 128 | if len(commentIds) > 0 { |
129 | - _, commentList, err := l.svcCtx.CommentRepository.Find(l.ctx, conn, domain.NewQueryOptions(). | 129 | + _, commentList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, domain.NewQueryOptions(). |
130 | WithFindOnly(). | 130 | WithFindOnly(). |
131 | WithKV("ids", commentIds). | 131 | WithKV("ids", commentIds). |
132 | WithKV("limit", len(commentIds))) | 132 | WithKV("limit", len(commentIds))) |
@@ -192,12 +192,12 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res | @@ -192,12 +192,12 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res | ||
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | - if _, ok := commentIdMap[item.CommentId]; ok { | 195 | + if v, ok := commentIdMap[item.CommentId]; ok { |
196 | to.Comment = &types.SimpleComment{ | 196 | to.Comment = &types.SimpleComment{ |
197 | - //Id: v.Id, | ||
198 | - //Title: v.Title, | ||
199 | - //CountLove: v.CountLove, | ||
200 | - //CountComment: v.CountComment, | 197 | + Id: v.Id, |
198 | + Content: v.Content, | ||
199 | + CountLove: v.CountUserLove, | ||
200 | + CountComment: v.CountReply, | ||
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 |
1 | +package tags | ||
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/xerr" | ||
8 | + | ||
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 | + "github.com/zeromicro/go-zero/core/logx" | ||
13 | +) | ||
14 | + | ||
15 | +type OptionsLogic struct { | ||
16 | + logx.Logger | ||
17 | + ctx context.Context | ||
18 | + svcCtx *svc.ServiceContext | ||
19 | +} | ||
20 | + | ||
21 | +func NewOptionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OptionsLogic { | ||
22 | + return &OptionsLogic{ | ||
23 | + Logger: logx.WithContext(ctx), | ||
24 | + ctx: ctx, | ||
25 | + svcCtx: svcCtx, | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +func (l *OptionsLogic) Options(req *types.TagOptionsRequest) (resp *types.TagOptionsResponse, err error) { | ||
30 | + var conn = l.svcCtx.DefaultDBConn() | ||
31 | + queryOption := domain.NewQueryOptions().WithFindOnly() | ||
32 | + _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption) | ||
33 | + if err != nil { | ||
34 | + return nil, xerr.NewErrMsgErr("获取标签列表失败", err) | ||
35 | + } | ||
36 | + var group []string | ||
37 | + options := make(map[string][]types.TagOptionValue) | ||
38 | + lo.ForEach(tagList, func(tag *domain.ArticleTag, index int) { | ||
39 | + if _, ok := options[tag.Category]; !ok { | ||
40 | + options[tag.Category] = make([]types.TagOptionValue, 0) | ||
41 | + group = append(group, tag.Category) | ||
42 | + } | ||
43 | + options[tag.Category] = append(options[tag.Category], types.TagOptionValue{ | ||
44 | + Label: tag.Name, | ||
45 | + Value: tag.Id, | ||
46 | + }) | ||
47 | + }) | ||
48 | + resp = &types.TagOptionsResponse{Options: []types.TagOptions{}} | ||
49 | + for _, value := range group { | ||
50 | + ops := []types.TagOptionValue{} | ||
51 | + if _, ok := options[value]; ok { | ||
52 | + ops = options[value] | ||
53 | + } | ||
54 | + resp.Options = append(resp.Options, types.TagOptions{ | ||
55 | + Label: value, | ||
56 | + Options: ops, | ||
57 | + }) | ||
58 | + } | ||
59 | + return | ||
60 | +} |
@@ -46,19 +46,19 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types. | @@ -46,19 +46,19 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types. | ||
46 | 46 | ||
47 | var userMap = make(map[int64]*domain.User) | 47 | var userMap = make(map[int64]*domain.User) |
48 | var articleMap = make(map[int64]*domain.Article) | 48 | var articleMap = make(map[int64]*domain.Article) |
49 | - var commentMap = make(map[int64]*domain.Comment) | 49 | + var commentMap = make(map[int64]*domain.ArticleComment) |
50 | 50 | ||
51 | lo.ForEach(list, func(item *domain.UserLoveFlag, index int) { | 51 | lo.ForEach(list, func(item *domain.UserLoveFlag, index int) { |
52 | var ( | 52 | var ( |
53 | user *domain.User | 53 | user *domain.User |
54 | article *domain.Article | 54 | article *domain.Article |
55 | - comment *domain.Comment | 55 | + comment *domain.ArticleComment |
56 | ) | 56 | ) |
57 | 57 | ||
58 | if item.CommentId != 0 { // 点赞评论 | 58 | if item.CommentId != 0 { // 点赞评论 |
59 | user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.CommentAuthor, l.svcCtx.UserRepository.FindOne) | 59 | user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.CommentAuthor, l.svcCtx.UserRepository.FindOne) |
60 | article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) | 60 | article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) |
61 | - comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.CommentRepository.FindOne) | 61 | + comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne) |
62 | } else { | 62 | } else { |
63 | user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.ArticleAuthor, l.svcCtx.UserRepository.FindOne) | 63 | user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.ArticleAuthor, l.svcCtx.UserRepository.FindOne) |
64 | article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) | 64 | article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne) |
@@ -70,7 +70,7 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types. | @@ -70,7 +70,7 @@ func (l *MiniMyLikeLogic) MiniMyLike(req *types.MiniMyLikeRequest) (resp *types. | ||
70 | return | 70 | return |
71 | } | 71 | } |
72 | 72 | ||
73 | -func NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain.Article, comment *domain.Comment) types.MyLikeItem { | 73 | +func NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyLikeItem { |
74 | item := types.MyLikeItem{ | 74 | item := types.MyLikeItem{ |
75 | UserId: love.UserId, | 75 | UserId: love.UserId, |
76 | ArticleId: love.ArticleId, | 76 | ArticleId: love.ArticleId, |
@@ -102,9 +102,10 @@ func NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain | @@ -102,9 +102,10 @@ func NewItemSimple(love *domain.UserLoveFlag, user *domain.User, article *domain | ||
102 | if comment != nil { | 102 | if comment != nil { |
103 | item.Comment = &types.SimpleComment{ | 103 | item.Comment = &types.SimpleComment{ |
104 | Id: comment.Id, | 104 | Id: comment.Id, |
105 | - //Content: comment.Content, | ||
106 | - //CountLove: comment.CountLove, | ||
107 | - //CountComment: comment.CountComment, | 105 | + Content: comment.Content, |
106 | + CountLove: comment.CountUserLove, | ||
107 | + CountComment: comment.CountReply, | ||
108 | + Show: int(comment.Show), | ||
108 | } | 109 | } |
109 | } | 110 | } |
110 | 111 |
@@ -29,7 +29,6 @@ type ServiceContext struct { | @@ -29,7 +29,6 @@ type ServiceContext struct { | ||
29 | ArticleAndTagRepository domain.ArticleAndTagRepository | 29 | ArticleAndTagRepository domain.ArticleAndTagRepository |
30 | 30 | ||
31 | CompanyRepository domain.CompanyRepository | 31 | CompanyRepository domain.CompanyRepository |
32 | - CommentRepository domain.CommentRepository // 待移除 | ||
33 | DepartmentRepository domain.DepartmentRepository | 32 | DepartmentRepository domain.DepartmentRepository |
34 | MessageBusinessRepository domain.MessageBusinessRepository | 33 | MessageBusinessRepository domain.MessageBusinessRepository |
35 | MessageSystemRepository domain.MessageSystemRepository | 34 | MessageSystemRepository domain.MessageSystemRepository |
@@ -60,7 +59,6 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -60,7 +59,6 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
60 | ApiAuthService: apiAuth, | 59 | ApiAuthService: apiAuth, |
61 | LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle, | 60 | LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle, |
62 | 61 | ||
63 | - CommentRepository: repository.NewCommentRepository(cache.NewCachedRepository(mlCache)), | ||
64 | ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), | 62 | ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), |
65 | ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)), | 63 | ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)), |
66 | ArticleDraftRepository: repository.NewArticleDraftRepository(cache.NewCachedRepository(mlCache)), | 64 | ArticleDraftRepository: repository.NewArticleDraftRepository(cache.NewCachedRepository(mlCache)), |
@@ -136,6 +136,38 @@ type SystemArticleCommentSearchMeResponse struct { | @@ -136,6 +136,38 @@ type SystemArticleCommentSearchMeResponse struct { | ||
136 | Total int64 `json:"total"` | 136 | Total int64 `json:"total"` |
137 | } | 137 | } |
138 | 138 | ||
139 | +type SystemArticleCommentSearchRequest struct { | ||
140 | + Page int `json:"page"` | ||
141 | + Size int `json:"size"` | ||
142 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
143 | + TopId int64 `json:"topId"` // 文章顶层ID | ||
144 | + AuthorId int64 `json:"authorId,optional"` // 用户 | ||
145 | + Show int `json:"show,optional"` // 显示状态 | ||
146 | + BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
147 | + EndTime int64 `json:"endTime,optional"` // 结束时间 | ||
148 | +} | ||
149 | + | ||
150 | +type SystemArticleCommentSearchResponse struct { | ||
151 | + Total int64 `json:"total"` | ||
152 | + List []SystemArticleCommentSearchItem `json:"list"` | ||
153 | +} | ||
154 | + | ||
155 | +type SystemArticleCommentSearchItem struct { | ||
156 | + Id int64 `json:"id"` | ||
157 | + Pid int64 `json:"pid"` | ||
158 | + TopId int64 `json:"topId"` | ||
159 | + ArtitcleId int64 `json:"articleId"` // 文章id | ||
160 | + SectionId int64 `json:"sectionId"` // 段落id | ||
161 | + FromUserId int64 `json:"fromUserId"` // 填写评论的人 | ||
162 | + FromUser CommentAuthor `json:"fromUser"` // 填写评论的人 | ||
163 | + CountReply int `json:"countReply"` // 回复数量 | ||
164 | + CountUserLove int `json:"countUserLove"` // 用户点赞数量 | ||
165 | + CountAdminLove int `json:"countAdminLove"` // 运营点赞数量 | ||
166 | + CreatedAt int64 `json:"createdAt"` // 评论时间 | ||
167 | + Content string `json:"content"` // 评论的内容 | ||
168 | + Show int `json:"show"` // 显示状态 | ||
169 | +} | ||
170 | + | ||
139 | type MessageSystemRequest struct { | 171 | type MessageSystemRequest struct { |
140 | Page int `json:"page"` | 172 | Page int `json:"page"` |
141 | Size int `json:"size"` | 173 | Size int `json:"size"` |
@@ -274,6 +306,24 @@ type TagDeleteResponse struct { | @@ -274,6 +306,24 @@ type TagDeleteResponse struct { | ||
274 | Id int64 `json:"id"` | 306 | Id int64 `json:"id"` |
275 | } | 307 | } |
276 | 308 | ||
309 | +type TagOptionsRequest struct { | ||
310 | + CompanyId int64 `path:",optional"` // 公司ID | ||
311 | +} | ||
312 | + | ||
313 | +type TagOptionsResponse struct { | ||
314 | + Options []TagOptions `json:"options"` | ||
315 | +} | ||
316 | + | ||
317 | +type TagOptions struct { | ||
318 | + Label string `json:"label"` // 分组名称 | ||
319 | + Options []TagOptionValue `json:"options"` | ||
320 | +} | ||
321 | + | ||
322 | +type TagOptionValue struct { | ||
323 | + Label string `json:"label"` // 名称 | ||
324 | + Value int64 `json:"value"` // 标签ID | ||
325 | +} | ||
326 | + | ||
277 | type MiniUserLoginRequest struct { | 327 | type MiniUserLoginRequest struct { |
278 | LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login | 328 | LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login |
279 | WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 | 329 | WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 |
@@ -960,7 +1010,6 @@ type SystemArticleUpdateRequest struct { | @@ -960,7 +1010,6 @@ type SystemArticleUpdateRequest struct { | ||
960 | Images []string `json:"images"` // 图片 | 1010 | Images []string `json:"images"` // 图片 |
961 | WhoRead []int64 `json:"whoRead"` // 谁可以看 | 1011 | WhoRead []int64 `json:"whoRead"` // 谁可以看 |
962 | WhoReview []int64 `json:"whoReview"` // 评论人 | 1012 | WhoReview []int64 `json:"whoReview"` // 评论人 |
963 | - Location Location `json:"location"` // 坐标 | ||
964 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | 1013 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
965 | Tags []int64 `json:"tags"` // 标签 | 1014 | Tags []int64 `json:"tags"` // 标签 |
966 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token | 1015 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token |
@@ -1056,10 +1105,10 @@ type MiniSearchArticleRequest struct { | @@ -1056,10 +1105,10 @@ type MiniSearchArticleRequest struct { | ||
1056 | Size int `json:"size"` | 1105 | Size int `json:"size"` |
1057 | CompanyId int64 `json:",optional"` | 1106 | CompanyId int64 `json:",optional"` |
1058 | UserId int64 `json:",optional"` | 1107 | UserId int64 `json:",optional"` |
1059 | - TagGroup string `json:"tagGroup"` | 1108 | + TagCategory string `json:"tagCategory"` |
1060 | TagId int64 `json:"tagId"` | 1109 | TagId int64 `json:"tagId"` |
1061 | BeginTime int64 `json:"beginTime"` | 1110 | BeginTime int64 `json:"beginTime"` |
1062 | - EndTime int `json:"endTime"` | 1111 | + EndTime int64 `json:"endTime"` |
1063 | SearchWord string `json:"searchWord"` | 1112 | SearchWord string `json:"searchWord"` |
1064 | } | 1113 | } |
1065 | 1114 |
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 Comment struct { | ||
12 | - Id int64 // 唯一标识 | ||
13 | - | ||
14 | - CreatedAt int64 `json:",omitempty"` | ||
15 | - UpdatedAt int64 `json:",omitempty"` | ||
16 | - DeletedAt int64 `json:",omitempty"` | ||
17 | - Version int `json:",omitempty"` | ||
18 | - IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | ||
19 | -} | ||
20 | - | ||
21 | -func (m *Comment) TableName() string { | ||
22 | - return "t_comment" | ||
23 | -} | ||
24 | - | ||
25 | -func (m *Comment) BeforeCreate(tx *gorm.DB) (err error) { | ||
26 | - m.CreatedAt = time.Now().Unix() | ||
27 | - m.UpdatedAt = time.Now().Unix() | ||
28 | - return | ||
29 | -} | ||
30 | - | ||
31 | -func (m *Comment) BeforeUpdate(tx *gorm.DB) (err error) { | ||
32 | - m.UpdatedAt = time.Now().Unix() | ||
33 | - return | ||
34 | -} | ||
35 | - | ||
36 | -func (m *Comment) CacheKeyFunc() string { | ||
37 | - if m.Id == 0 { | ||
38 | - return "" | ||
39 | - } | ||
40 | - return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id) | ||
41 | -} | ||
42 | - | ||
43 | -func (m *Comment) CacheKeyFuncByObject(obj interface{}) string { | ||
44 | - if v, ok := obj.(*Comment); ok { | ||
45 | - return v.CacheKeyFunc() | ||
46 | - } | ||
47 | - return "" | ||
48 | -} | ||
49 | - | ||
50 | -func (m *Comment) CachePrimaryKeyFunc() string { | ||
51 | - if len("") == 0 { | ||
52 | - return "" | ||
53 | - } | ||
54 | - return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") | ||
55 | -} |
@@ -133,11 +133,10 @@ func (repository *ArticleAndTagRepository) DomainModelToModel(from *domain.Artic | @@ -133,11 +133,10 @@ func (repository *ArticleAndTagRepository) DomainModelToModel(from *domain.Artic | ||
133 | return to, err | 133 | return to, err |
134 | } | 134 | } |
135 | 135 | ||
136 | -// 以TagId作为分组,统计所有已有标签的文章和人员已读的文章 | 136 | +// 小程序端 以TagId作为分组,统计所有已有标签的文章和人员已读的文章 |
137 | func (repository *ArticleAndTagRepository) CountArticleReadGroupByTag(ctx context.Context, conn transaction.Conn, userId int64, companyId int64) ([]*domain.CountArticleTagRead, error) { | 137 | func (repository *ArticleAndTagRepository) CountArticleReadGroupByTag(ctx context.Context, conn transaction.Conn, userId int64, companyId int64) ([]*domain.CountArticleTagRead, error) { |
138 | 138 | ||
139 | - sqlStr := ` | ||
140 | --- 首页统计数据 | 139 | + sqlStr := `-- 首页统计数据 |
141 | with | 140 | with |
142 | -- 按查看权限查询文章 | 141 | -- 按查看权限查询文章 |
143 | -- 获取有标签的文章 | 142 | -- 获取有标签的文章 |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + "fmt" | ||
5 | 6 | ||
6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -399,27 +400,75 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor | @@ -399,27 +400,75 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor | ||
399 | return &ArticleRepository{CachedRepository: cache} | 400 | return &ArticleRepository{CachedRepository: cache} |
400 | } | 401 | } |
401 | 402 | ||
402 | -// -- 首页统计数据 | ||
403 | -// with | ||
404 | -// -- 按查看权限查询文章 | ||
405 | -// -- 获取有标签的文章 | ||
406 | -// -- 过滤出可展示的文章id | ||
407 | -// t_article_and_tag_2 as ( | ||
408 | -// select article_and_tag.article_id , article_and_tag.tag_id | ||
409 | -// from article_and_tag | ||
410 | -// join article on article_and_tag.article_id = article.id | ||
411 | -// where article.deleted_at=0 | ||
412 | -// and article.company_id =1598224576532189184 | ||
413 | -// and article."show" =0 | ||
414 | -// and (article.target_user =0 or article.who_read @>'[1]') | ||
415 | -// ), | ||
416 | -// -- 查询人员已查看的文章 | ||
417 | -// t_user_read as( | ||
418 | -// select user_read_article.article_id from user_read_article where user_read_article.user_id =1 | ||
419 | -// ) | ||
420 | -// -- 汇总统计 cnt_1符合条件的文章总数,cnt_2 已浏览的数量 | ||
421 | -// select count(t_article_and_tag_2.article_id) as cnt_1 ,count(t_user_read.article_id) as cnt_2, t_article_and_tag_2.tag_id | ||
422 | -// from t_article_and_tag_2 | ||
423 | -// left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id | ||
424 | -// group by t_article_and_tag_2.tag_id | ||
425 | -// ; | 403 | +// 小程序端搜索查询文章 |
404 | +// userId 人员id,谁查看文章 | ||
405 | +// companyId 公司id | ||
406 | +// tagCategory 标签分类 | ||
407 | +// tagId 标签id | ||
408 | +// createdAt 文章的发布时间,按范围查询 [开始时间,结束时间] | ||
409 | +// titleLike 搜索标题 | ||
410 | +func (repository *ArticleRepository) CustomSearchBy(ctx context.Context, conn transaction.Conn, userId int64, companyId int64, | ||
411 | + tagCategory string, tagId int64, createdAt [2]int64, titleLike string, page int, size int) (int64, []*domain.Article, error) { | ||
412 | + var ( | ||
413 | + tx = conn.DB() | ||
414 | + ms []*models.Article | ||
415 | + dms = make([]*domain.Article, 0) | ||
416 | + total int64 | ||
417 | + ) | ||
418 | + tx = tx.Model(&ms). | ||
419 | + Where(`article."show" =?`, domain.ArticleShowEnable). | ||
420 | + Where(`article."deleted_at" = 0`). | ||
421 | + Where(`article."company_id"=?`, companyId). | ||
422 | + Where( | ||
423 | + fmt.Sprintf(`(article.target_user = 0 or article.who_read @> '[%d]' )`, userId), | ||
424 | + ) | ||
425 | + if createdAt[0] > 0 { | ||
426 | + tx = tx.Where("article.created_at >=?", createdAt[0]) | ||
427 | + } | ||
428 | + if createdAt[1] > 0 { | ||
429 | + tx = tx.Where("article.created_at <=?", createdAt[1]) | ||
430 | + } | ||
431 | + if tagId > 0 { | ||
432 | + tx = tx.Joins(`join article_and_tag on article.id = article_and_tag.article_id`) | ||
433 | + tx = tx.Where("article_and_tag.tag_id=?", tagId) | ||
434 | + } else if len(tagCategory) > 0 { | ||
435 | + tx = tx.Joins(`join article_and_tag on article.id = article_and_tag.article_id`) | ||
436 | + tx = tx.Where(`article_and_tag.tag_id =any(select article_tag.id from article_tag where category =%s )`, tagCategory) | ||
437 | + } | ||
438 | + if len(titleLike) > 0 { | ||
439 | + tx = tx.Where("article.title like ?", "%"+titleLike+"%") | ||
440 | + } | ||
441 | + | ||
442 | + result := tx.Count(&total) | ||
443 | + if result.Error != nil { | ||
444 | + return 0, nil, result.Error | ||
445 | + } | ||
446 | + if size <= 0 { | ||
447 | + size = 20 | ||
448 | + | ||
449 | + } | ||
450 | + if page <= 0 { | ||
451 | + page = 1 | ||
452 | + } | ||
453 | + result = tx.Limit(size).Offset((page - 1) * size).Order("id desc").Find(&ms) | ||
454 | + if result.Error != nil { | ||
455 | + return 0, nil, result.Error | ||
456 | + } | ||
457 | + for _, item := range ms { | ||
458 | + if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
459 | + return 0, dms, err | ||
460 | + } else { | ||
461 | + dms = append(dms, dm) | ||
462 | + } | ||
463 | + } | ||
464 | + return total, dms, nil | ||
465 | +} | ||
466 | + | ||
467 | +// select * | ||
468 | +// from article | ||
469 | +// join article_and_tag on article.id = article_and_tag.article_id | ||
470 | +// where article."show" =1 | ||
471 | +// and article_and_tag.tag_id =any(select article_tag.id from article_tag where category ='分组三' ) | ||
472 | +// and article_and_tag.tag_id =0 | ||
473 | +// and article.created_at >=0 and article.created_at <=9000000000 | ||
474 | +// and article.title like '%%' |
@@ -96,7 +96,6 @@ func (repository *ArticleSectionRepository) DeleteBy(ctx context.Context, conn t | @@ -96,7 +96,6 @@ func (repository *ArticleSectionRepository) DeleteBy(ctx context.Context, conn t | ||
96 | m = &models.ArticleSection{} | 96 | m = &models.ArticleSection{} |
97 | ) | 97 | ) |
98 | queryFunc := func() (interface{}, error) { | 98 | queryFunc := func() (interface{}, error) { |
99 | - tx = tx.Where("id = ?", m.Id) | ||
100 | if v, ok := queryOptions["articleId"]; ok { | 99 | if v, ok := queryOptions["articleId"]; ok { |
101 | tx = tx.Where("article_id = ?", v) | 100 | tx = tx.Where("article_id = ?", v) |
102 | } | 101 | } |
@@ -141,7 +140,7 @@ func (repository *ArticleSectionRepository) Find(ctx context.Context, conn trans | @@ -141,7 +140,7 @@ func (repository *ArticleSectionRepository) Find(ctx context.Context, conn trans | ||
141 | total int64 | 140 | total int64 |
142 | ) | 141 | ) |
143 | queryFunc := func() (interface{}, error) { | 142 | queryFunc := func() (interface{}, error) { |
144 | - tx = tx.Model(&ms).Order("id desc") | 143 | + tx = tx.Model(&ms).Order("sort_by") |
145 | 144 | ||
146 | if v, ok := queryOptions["articleId"]; ok { | 145 | if v, ok := queryOptions["articleId"]; ok { |
147 | tx = tx.Where("article_id = ?", v) | 146 | tx = tx.Where("article_id = ?", v) |
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 CommentRepository struct { | ||
15 | - *cache.CachedRepository | ||
16 | -} | ||
17 | - | ||
18 | -func (repository *CommentRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.Comment) (*domain.Comment, error) { | ||
19 | - var ( | ||
20 | - err error | ||
21 | - m = &models.Comment{} | ||
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 *CommentRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.Comment) (*domain.Comment, error) { | ||
36 | - var ( | ||
37 | - err error | ||
38 | - m *models.Comment | ||
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 *CommentRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.Comment) (*domain.Comment, error) { | ||
55 | - var ( | ||
56 | - err error | ||
57 | - m *models.Comment | ||
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 *CommentRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.Comment) (*domain.Comment, error) { | ||
79 | - var ( | ||
80 | - tx = conn.DB() | ||
81 | - m = &models.Comment{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 *CommentRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.Comment, error) { | ||
94 | - var ( | ||
95 | - err error | ||
96 | - tx = conn.DB() | ||
97 | - m = new(models.Comment) | ||
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.Comment) | ||
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 *CommentRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.Comment, error) { | ||
115 | - var ( | ||
116 | - tx = conn.DB() | ||
117 | - ms []*models.Comment | ||
118 | - dms = make([]*domain.Comment, 0) | ||
119 | - total int64 | ||
120 | - ) | ||
121 | - queryFunc := func() (interface{}, error) { | ||
122 | - tx = tx.Model(&ms).Order("id desc") | ||
123 | - if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | ||
124 | - return dms, tx.Error | ||
125 | - } | ||
126 | - return dms, nil | ||
127 | - } | ||
128 | - | ||
129 | - if _, err := repository.Query(queryFunc); err != nil { | ||
130 | - return 0, nil, err | ||
131 | - } | ||
132 | - | ||
133 | - for _, item := range ms { | ||
134 | - if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
135 | - return 0, dms, err | ||
136 | - } else { | ||
137 | - dms = append(dms, dm) | ||
138 | - } | ||
139 | - } | ||
140 | - return total, dms, nil | ||
141 | -} | ||
142 | - | ||
143 | -func (repository *CommentRepository) ModelToDomainModel(from *models.Comment) (*domain.Comment, error) { | ||
144 | - to := &domain.Comment{} | ||
145 | - err := copier.Copy(to, from) | ||
146 | - return to, err | ||
147 | -} | ||
148 | - | ||
149 | -func (repository *CommentRepository) DomainModelToModel(from *domain.Comment) (*models.Comment, error) { | ||
150 | - to := &models.Comment{} | ||
151 | - err := copier.Copy(to, from) | ||
152 | - return to, err | ||
153 | -} | ||
154 | - | ||
155 | -func NewCommentRepository(cache *cache.CachedRepository) domain.CommentRepository { | ||
156 | - return &CommentRepository{CachedRepository: cache} | ||
157 | -} |
@@ -127,6 +127,9 @@ func (repository *UserReadArticleRepository) Find(ctx context.Context, conn tran | @@ -127,6 +127,9 @@ func (repository *UserReadArticleRepository) Find(ctx context.Context, conn tran | ||
127 | if v, ok := queryOptions["articleId"]; ok { | 127 | if v, ok := queryOptions["articleId"]; ok { |
128 | tx = tx.Where("article_id=?", v) | 128 | tx = tx.Where("article_id=?", v) |
129 | } | 129 | } |
130 | + if v, ok := queryOptions["articleIds"]; ok { | ||
131 | + tx = tx.Where("article_id in (?)", v) | ||
132 | + } | ||
130 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 133 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
131 | return dms, tx.Error | 134 | return dms, tx.Error |
132 | } | 135 | } |
@@ -43,6 +43,16 @@ type ArticleRepository interface { | @@ -43,6 +43,16 @@ type ArticleRepository interface { | ||
43 | IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //点赞数量变动 | 43 | IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //点赞数量变动 |
44 | IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //评论数量变动 | 44 | IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //评论数量变动 |
45 | IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //浏览数量变动 | 45 | IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //浏览数量变动 |
46 | + | ||
47 | + // 小程序端搜索查询文章 | ||
48 | + // userId 人员id,谁查看文章 | ||
49 | + // companyId 公司id | ||
50 | + // tagCategory 标签分类 | ||
51 | + // tagId 标签id | ||
52 | + // createdAt 文章的发布时间,按范围查询 [开始时间,结束时间] | ||
53 | + // titleLike 搜索标题 | ||
54 | + CustomSearchBy(ctx context.Context, conn transaction.Conn, userId int64, companyId int64, | ||
55 | + tagCategory string, tagId int64, createdAt [2]int64, titleLike string, page int, size int) (int64, []*Article, error) | ||
46 | } | 56 | } |
47 | 57 | ||
48 | type ArticleTarget int | 58 | type ArticleTarget int |
1 | -package domain | ||
2 | - | ||
3 | -import ( | ||
4 | - "context" | ||
5 | - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
6 | -) | ||
7 | - | ||
8 | -type Comment struct { | ||
9 | - Id int64 // 唯一标识 | ||
10 | - | ||
11 | - CreatedAt int64 `json:",omitempty"` | ||
12 | - UpdatedAt int64 `json:",omitempty"` | ||
13 | - DeletedAt int64 `json:",omitempty"` | ||
14 | - Version int `json:",omitempty"` | ||
15 | -} | ||
16 | - | ||
17 | -type CommentRepository interface { | ||
18 | - Insert(ctx context.Context, conn transaction.Conn, dm *Comment) (*Comment, error) | ||
19 | - Update(ctx context.Context, conn transaction.Conn, dm *Comment) (*Comment, error) | ||
20 | - UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *Comment) (*Comment, error) | ||
21 | - Delete(ctx context.Context, conn transaction.Conn, dm *Comment) (*Comment, error) | ||
22 | - FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Comment, error) | ||
23 | - Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*Comment, error) | ||
24 | -} | ||
25 | - | ||
26 | -func (m *Comment) Identify() interface{} { | ||
27 | - if m.Id == 0 { | ||
28 | - return nil | ||
29 | - } | ||
30 | - return m.Id | ||
31 | -} |
@@ -41,7 +41,7 @@ func GetImageInfo(url string) (info FileInfo, err error) { | @@ -41,7 +41,7 @@ func GetImageInfo(url string) (info FileInfo, err error) { | ||
41 | return info, err | 41 | return info, err |
42 | } | 42 | } |
43 | httpclient := http.Client{ | 43 | httpclient := http.Client{ |
44 | - Timeout: 30 * time.Second, | 44 | + Timeout: 5 * time.Second, |
45 | } | 45 | } |
46 | resp, err := httpclient.Do(req) | 46 | resp, err := httpclient.Do(req) |
47 | if err != nil { | 47 | if err != nil { |
@@ -70,7 +70,10 @@ func GetVideoCover(videoUrl string) (coverUrl string, w int, h int, err error) { | @@ -70,7 +70,10 @@ func GetVideoCover(videoUrl string) (coverUrl string, w int, h int, err error) { | ||
70 | return | 70 | return |
71 | } | 71 | } |
72 | videoUrl = videoUrl + "?x-oss-process=video/snapshot,t_100,f_jpg,m_fast" | 72 | videoUrl = videoUrl + "?x-oss-process=video/snapshot,t_100,f_jpg,m_fast" |
73 | - res, err := http.Get(videoUrl) | 73 | + httpclient := http.Client{ |
74 | + Timeout: 5 * time.Second, | ||
75 | + } | ||
76 | + res, err := httpclient.Get(videoUrl) | ||
74 | if err != nil || res.StatusCode != http.StatusOK { | 77 | if err != nil || res.StatusCode != http.StatusOK { |
75 | return videoUrl, 600, 600, fmt.Errorf("获取图片失败:%s", err) | 78 | return videoUrl, 600, 600, fmt.Errorf("获取图片失败:%s", err) |
76 | } | 79 | } |
-
请 注册 或 登录 后发表评论