作者 庄敏学

解决冲突

正在显示 58 个修改的文件 包含 3195 行增加374 行删除

要显示太多修改。

为保证性能只显示 58 of 58+ 个文件。

@@ -127,6 +127,34 @@ @@ -127,6 +127,34 @@
127 ] 127 ]
128 } 128 }
129 }, 129 },
  130 + "v1/mini/article/set_tag": {
  131 + "post": {
  132 + "summary": "小程序设置文章的定性标签",
  133 + "operationId": "MiniArticleSetTag",
  134 + "responses": {
  135 + "200": {
  136 + "description": "A successful response.",
  137 + "schema": {
  138 + "$ref": "#/definitions/MiniArticleSetTagResponse"
  139 + }
  140 + }
  141 + },
  142 + "parameters": [
  143 + {
  144 + "name": "body",
  145 + "in": "body",
  146 + "required": true,
  147 + "schema": {
  148 + "$ref": "#/definitions/MiniArticleSetTagRequest"
  149 + }
  150 + }
  151 + ],
  152 + "requestBody": {},
  153 + "tags": [
  154 + "article"
  155 + ]
  156 + }
  157 + },
130 "v1/mini/article/user_like/list": { 158 "v1/mini/article/user_like/list": {
131 "post": { 159 "post": {
132 "summary": "小程序获取文章的点赞人员列表", 160 "summary": "小程序获取文章的点赞人员列表",
@@ -293,6 +321,151 @@ @@ -293,6 +321,151 @@
293 ] 321 ]
294 } 322 }
295 }, 323 },
  324 +<<<<<<< HEAD
  325 +=======
  326 + "v1/mini/article_comment/at_who/list": {
  327 + "post": {
  328 + "summary": "小程序展示评论时@人可选列表",
  329 + "operationId": "MiniArticleCommentAtWho",
  330 + "responses": {
  331 + "200": {
  332 + "description": "A successful response.",
  333 + "schema": {
  334 + "$ref": "#/definitions/MiniArticleCommentAtWhoResponse"
  335 + }
  336 + }
  337 + },
  338 + "parameters": [
  339 + {
  340 + "name": "body",
  341 + "in": "body",
  342 + "required": true,
  343 + "schema": {
  344 + "$ref": "#/definitions/MiniArticleCommentAtWhoRequest"
  345 + }
  346 + }
  347 + ],
  348 + "requestBody": {},
  349 + "tags": [
  350 + "comment"
  351 + ]
  352 + }
  353 + },
  354 + "v1/mini/article_comment/list": {
  355 + "post": {
  356 + "summary": "小程序展示文章的评论列表",
  357 + "operationId": "MiniListArticleComment",
  358 + "responses": {
  359 + "200": {
  360 + "description": "A successful response.",
  361 + "schema": {
  362 + "$ref": "#/definitions/MiniListArticleCommentResponse"
  363 + }
  364 + }
  365 + },
  366 + "parameters": [
  367 + {
  368 + "name": "body",
  369 + "in": "body",
  370 + "required": true,
  371 + "schema": {
  372 + "$ref": "#/definitions/MiniListArticleCommentRequest"
  373 + }
  374 + }
  375 + ],
  376 + "requestBody": {},
  377 + "tags": [
  378 + "comment"
  379 + ]
  380 + }
  381 + },
  382 + "v1/mini/article_comment/top5": {
  383 + "post": {
  384 + "summary": "小程序展示文章的评论列表TOP5",
  385 + "operationId": "MiniTop5ArticleComment",
  386 + "responses": {
  387 + "200": {
  388 + "description": "A successful response.",
  389 + "schema": {
  390 + "$ref": "#/definitions/MiniTop5ArticleCommentResponse"
  391 + }
  392 + }
  393 + },
  394 + "parameters": [
  395 + {
  396 + "name": "body",
  397 + "in": "body",
  398 + "required": true,
  399 + "schema": {
  400 + "$ref": "#/definitions/MiniTop5ArticleCommentRequest"
  401 + }
  402 + }
  403 + ],
  404 + "requestBody": {},
  405 + "tags": [
  406 + "comment"
  407 + ]
  408 + }
  409 + },
  410 + "v1/mini/article_comment/{id}": {
  411 + "get": {
  412 + "summary": "小程序展示单个文章的评论",
  413 + "operationId": "MiniGetArticleComment",
  414 + "responses": {
  415 + "200": {
  416 + "description": "A successful response.",
  417 + "schema": {
  418 + "$ref": "#/definitions/MiniGetArticleCommentResponse"
  419 + }
  420 + }
  421 + },
  422 + "parameters": [
  423 + {
  424 + "name": "id",
  425 + "in": "path",
  426 + "required": true,
  427 + "type": "string"
  428 + }
  429 + ],
  430 + "requestBody": {},
  431 + "tags": [
  432 + "comment"
  433 + ]
  434 + },
  435 + "delete": {
  436 + "summary": "小程序展示删除文章评论",
  437 + "operationId": "MiniDeleteArticleComment",
  438 + "responses": {
  439 + "200": {
  440 + "description": "A successful response.",
  441 + "schema": {
  442 + "$ref": "#/definitions/MiniDeleteArticleCommentResponse"
  443 + }
  444 + }
  445 + },
  446 + "parameters": [
  447 + {
  448 + "name": "id",
  449 + "in": "path",
  450 + "required": true,
  451 + "type": "string"
  452 + },
  453 + {
  454 + "name": "body",
  455 + "in": "body",
  456 + "required": true,
  457 + "schema": {
  458 + "$ref": "#/definitions/MiniDeleteArticleCommentRequest"
  459 + }
  460 + }
  461 + ],
  462 + "requestBody": {},
  463 + "tags": [
  464 + "comment"
  465 + ]
  466 + }
  467 + },
  468 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
296 "v1/mini/article_draft": { 469 "v1/mini/article_draft": {
297 "post": { 470 "post": {
298 "summary": "小程序创建文章进草稿箱", 471 "summary": "小程序创建文章进草稿箱",
@@ -430,6 +603,61 @@ @@ -430,6 +603,61 @@
430 "requestBody": {}, 603 "requestBody": {},
431 "tags": [ 604 "tags": [
432 "article" 605 "article"
  606 +<<<<<<< HEAD
  607 +=======
  608 + ]
  609 + }
  610 + },
  611 + "v1/mini/article_tag/list/all": {
  612 + "get": {
  613 + "summary": "小程序所有的定性标签",
  614 + "operationId": "MiniAllArticleTag",
  615 + "responses": {
  616 + "200": {
  617 + "description": "A successful response.",
  618 + "schema": {
  619 + "$ref": "#/definitions/MiniAllArticleTagResponse"
  620 + }
  621 + }
  622 + },
  623 + "parameters": [
  624 + {
  625 + "name": "",
  626 + "description": " 公司id",
  627 + "in": "query",
  628 + "required": false,
  629 + "type": "integer",
  630 + "format": "int64"
  631 + },
  632 + {
  633 + "name": "",
  634 + "description": " 公司id",
  635 + "in": "query",
  636 + "required": false,
  637 + "type": "integer",
  638 + "format": "int64"
  639 + },
  640 + {
  641 + "name": "articleId",
  642 + "description": " 文章id",
  643 + "in": "query",
  644 + "required": true,
  645 + "type": "integer",
  646 + "format": "int64"
  647 + },
  648 + {
  649 + "name": "tagId",
  650 + "description": " 标签id",
  651 + "in": "query",
  652 + "required": true,
  653 + "type": "integer",
  654 + "format": "int64"
  655 + }
  656 + ],
  657 + "requestBody": {},
  658 + "tags": [
  659 + "article"
  660 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
433 ] 661 ]
434 } 662 }
435 }, 663 },
@@ -1075,6 +1303,34 @@ @@ -1075,6 +1303,34 @@
1075 ] 1303 ]
1076 } 1304 }
1077 }, 1305 },
  1306 + "v1/system/article/search/me": {
  1307 + "post": {
  1308 + "summary": "管理后台获取我发布的文章",
  1309 + "operationId": "SystemArticleSearchMe",
  1310 + "responses": {
  1311 + "200": {
  1312 + "description": "A successful response.",
  1313 + "schema": {
  1314 + "$ref": "#/definitions/SystemArticleSearchMeResponse"
  1315 + }
  1316 + }
  1317 + },
  1318 + "parameters": [
  1319 + {
  1320 + "name": "body",
  1321 + "in": "body",
  1322 + "required": true,
  1323 + "schema": {
  1324 + "$ref": "#/definitions/SystemArticleSearchMeRequest"
  1325 + }
  1326 + }
  1327 + ],
  1328 + "requestBody": {},
  1329 + "tags": [
  1330 + "article"
  1331 + ]
  1332 + }
  1333 + },
1078 "v1/system/article/{id}": { 1334 "v1/system/article/{id}": {
1079 "get": { 1335 "get": {
1080 "summary": "管理后台获取文章内容详情", 1336 "summary": "管理后台获取文章内容详情",
@@ -1101,6 +1357,34 @@ @@ -1101,6 +1357,34 @@
1101 ] 1357 ]
1102 } 1358 }
1103 }, 1359 },
  1360 + "v1/system/article_comment/search/me": {
  1361 + "post": {
  1362 + "summary": "小程序获取回复@人可选列表",
  1363 + "operationId": "SystemArticleCommentSearchMe",
  1364 + "responses": {
  1365 + "200": {
  1366 + "description": "A successful response.",
  1367 + "schema": {
  1368 + "$ref": "#/definitions/SystemArticleCommentSearchMeResponse"
  1369 + }
  1370 + }
  1371 + },
  1372 + "parameters": [
  1373 + {
  1374 + "name": "body",
  1375 + "in": "body",
  1376 + "required": true,
  1377 + "schema": {
  1378 + "$ref": "#/definitions/SystemArticleCommentSearchMeRequest"
  1379 + }
  1380 + }
  1381 + ],
  1382 + "requestBody": {},
  1383 + "tags": [
  1384 + "comment"
  1385 + ]
  1386 + }
  1387 + },
1104 "v1/system/article_tag": { 1388 "v1/system/article_tag": {
1105 "post": { 1389 "post": {
1106 "summary": "后台创建文章标签", 1390 "summary": "后台创建文章标签",
@@ -1350,6 +1634,41 @@ @@ -1350,6 +1634,41 @@
1350 "department" 1634 "department"
1351 ] 1635 ]
1352 }, 1636 },
  1637 +<<<<<<< HEAD
  1638 +=======
  1639 + "delete": {
  1640 + "summary": "部门-删除",
  1641 + "operationId": "systemDelete",
  1642 + "responses": {
  1643 + "200": {
  1644 + "description": "A successful response.",
  1645 + "schema": {
  1646 + "$ref": "#/definitions/DepartmentGetResponse"
  1647 + }
  1648 + }
  1649 + },
  1650 + "parameters": [
  1651 + {
  1652 + "name": "id",
  1653 + "in": "path",
  1654 + "required": true,
  1655 + "type": "string"
  1656 + },
  1657 + {
  1658 + "name": "body",
  1659 + "in": "body",
  1660 + "required": true,
  1661 + "schema": {
  1662 + "$ref": "#/definitions/DepartmentGetRequest"
  1663 + }
  1664 + }
  1665 + ],
  1666 + "requestBody": {},
  1667 + "tags": [
  1668 + "department"
  1669 + ]
  1670 + },
  1671 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
1353 "put": { 1672 "put": {
1354 "summary": "部门-更新", 1673 "summary": "部门-更新",
1355 "operationId": "systemUpdate", 1674 "operationId": "systemUpdate",
@@ -1385,6 +1704,7 @@ @@ -1385,6 +1704,7 @@
1385 }, 1704 },
1386 "v1/system/role": { 1705 "v1/system/role": {
1387 "post": { 1706 "post": {
  1707 + "summary": "角色新增",
1388 "operationId": "systemSaveRole", 1708 "operationId": "systemSaveRole",
1389 "responses": { 1709 "responses": {
1390 "200": { 1710 "200": {
@@ -1412,6 +1732,7 @@ @@ -1412,6 +1732,7 @@
1412 }, 1732 },
1413 "v1/system/role/search": { 1733 "v1/system/role/search": {
1414 "post": { 1734 "post": {
  1735 + "summary": "角色列表搜索",
1415 "operationId": "systemSearchRole", 1736 "operationId": "systemSearchRole",
1416 "responses": { 1737 "responses": {
1417 "200": { 1738 "200": {
@@ -1439,6 +1760,7 @@ @@ -1439,6 +1760,7 @@
1439 }, 1760 },
1440 "v1/system/role/{id}": { 1761 "v1/system/role/{id}": {
1441 "get": { 1762 "get": {
  1763 + "summary": "角色详情",
1442 "operationId": "systemGetRole", 1764 "operationId": "systemGetRole",
1443 "responses": { 1765 "responses": {
1444 "200": { 1766 "200": {
@@ -1462,6 +1784,7 @@ @@ -1462,6 +1784,7 @@
1462 ] 1784 ]
1463 }, 1785 },
1464 "delete": { 1786 "delete": {
  1787 + "summary": "角色删除",
1465 "operationId": "systemDeleteRole", 1788 "operationId": "systemDeleteRole",
1466 "responses": { 1789 "responses": {
1467 "200": { 1790 "200": {
@@ -1493,6 +1816,7 @@ @@ -1493,6 +1816,7 @@
1493 ] 1816 ]
1494 }, 1817 },
1495 "put": { 1818 "put": {
  1819 + "summary": "角色更新",
1496 "operationId": "systemUpdateRole", 1820 "operationId": "systemUpdateRole",
1497 "responses": { 1821 "responses": {
1498 "200": { 1822 "200": {
@@ -1770,12 +2094,146 @@ @@ -1770,12 +2094,146 @@
1770 "company" 2094 "company"
1771 ] 2095 ]
1772 }, 2096 },
1773 - "ArticleSearchMe": { 2097 +<<<<<<< HEAD
  2098 +=======
  2099 + "ArticleCommentAndReply": {
1774 "type": "object", 2100 "type": "object",
1775 "properties": { 2101 "properties": {
1776 - "id": {  
1777 - "type": "integer",  
1778 - "format": "int64", 2102 + "comment": {
  2103 + "$ref": "#/definitions/ArticleCommentItem",
  2104 + "description": "评论"
  2105 + },
  2106 + "reply": {
  2107 + "type": "array",
  2108 + "items": {
  2109 + "$ref": "#/definitions/ArticleCommentItem"
  2110 + },
  2111 + "description": "回复的评论"
  2112 + },
  2113 + "totalReply": {
  2114 + "type": "integer",
  2115 + "format": "int64",
  2116 + "description": "回复的评论数量"
  2117 + }
  2118 + },
  2119 + "title": "ArticleCommentAndReply",
  2120 + "required": [
  2121 + "comment",
  2122 + "reply",
  2123 + "totalReply"
  2124 + ]
  2125 + },
  2126 + "ArticleCommentItem": {
  2127 + "type": "object",
  2128 + "properties": {
  2129 + "id": {
  2130 + "type": "integer",
  2131 + "format": "int64"
  2132 + },
  2133 + "pid": {
  2134 + "type": "integer",
  2135 + "format": "int64"
  2136 + },
  2137 + "topId": {
  2138 + "type": "integer",
  2139 + "format": "int64"
  2140 + },
  2141 + "articleId": {
  2142 + "type": "integer",
  2143 + "format": "int64",
  2144 + "description": " 文章id"
  2145 + },
  2146 + "sectionId": {
  2147 + "type": "integer",
  2148 + "format": "int64",
  2149 + "description": " 段落id"
  2150 + },
  2151 + "fromUserId": {
  2152 + "type": "integer",
  2153 + "format": "int64",
  2154 + "description": " 填写评论的人"
  2155 + },
  2156 + "fromUser": {
  2157 + "$ref": "#/definitions/CommentAuthor",
  2158 + "description": " 填写评论的人"
  2159 + },
  2160 + "toUserId": {
  2161 + "type": "integer",
  2162 + "format": "int64",
  2163 + "description": " 回复哪个人"
  2164 + },
  2165 + "toUser": {
  2166 + "$ref": "#/definitions/CommentAuthor",
  2167 + "description": " 回复哪个人"
  2168 + },
  2169 + "sectionContent": {
  2170 + "type": "string",
  2171 + "description": " 引用的文章内容文本"
  2172 + },
  2173 + "countReply": {
  2174 + "type": "integer",
  2175 + "format": "int32",
  2176 + "description": " 回复数量"
  2177 + },
  2178 + "countUserLove": {
  2179 + "type": "integer",
  2180 + "format": "int32",
  2181 + "description": " 用户点赞数量"
  2182 + },
  2183 + "countAdminLove": {
  2184 + "type": "integer",
  2185 + "format": "int32",
  2186 + "description": " 运营点赞数量"
  2187 + },
  2188 + "atWho": {
  2189 + "type": "array",
  2190 + "items": {
  2191 + "$ref": "#/definitions/CommentAtWho"
  2192 + },
  2193 + "description": " 填写评论时@的人"
  2194 + },
  2195 + "createdAt": {
  2196 + "type": "integer",
  2197 + "format": "int64"
  2198 + },
  2199 + "meLoveFlag": {
  2200 + "type": "integer",
  2201 + "format": "int32",
  2202 + "description": "当前人员对评论的点赞标识 (0 没有点赞 1有点赞)"
  2203 + },
  2204 + "content": {
  2205 + "type": "string",
  2206 + "description": " 评论的内容"
  2207 + }
  2208 + },
  2209 + "title": "ArticleCommentItem",
  2210 + "required": [
  2211 + "id",
  2212 + "pid",
  2213 + "topId",
  2214 + "articleId",
  2215 + "sectionId",
  2216 + "fromUserId",
  2217 + "fromUser",
  2218 + "toUserId",
  2219 + "toUser",
  2220 + "sectionContent",
  2221 + "countReply",
  2222 + "countUserLove",
  2223 + "countAdminLove",
  2224 + "atWho",
  2225 + "createdAt",
  2226 + "meLoveFlag",
  2227 + "content"
  2228 + ]
  2229 + },
  2230 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
  2231 + "ArticleSearchMe": {
  2232 + "type": "object",
  2233 + "properties": {
  2234 + "id": {
  2235 + "type": "integer",
  2236 + "format": "int64",
1779 "description": "id" 2237 "description": "id"
1780 }, 2238 },
1781 "title": { 2239 "title": {
@@ -1852,6 +2310,27 @@ @@ -1852,6 +2310,27 @@
1852 "totalComment" 2310 "totalComment"
1853 ] 2311 ]
1854 }, 2312 },
  2313 + "ArticleTagItem": {
  2314 + "type": "object",
  2315 + "properties": {
  2316 + "id": {
  2317 + "type": "integer",
  2318 + "format": "int64"
  2319 + },
  2320 + "group": {
  2321 + "type": "string"
  2322 + },
  2323 + "name": {
  2324 + "type": "string"
  2325 + }
  2326 + },
  2327 + "title": "ArticleTagItem",
  2328 + "required": [
  2329 + "id",
  2330 + "group",
  2331 + "name"
  2332 + ]
  2333 + },
1855 "Auth": { 2334 "Auth": {
1856 "type": "object", 2335 "type": "object",
1857 "properties": { 2336 "properties": {
@@ -1876,6 +2355,25 @@ @@ -1876,6 +2355,25 @@
1876 "code" 2355 "code"
1877 ] 2356 ]
1878 }, 2357 },
  2358 +<<<<<<< HEAD
  2359 +=======
  2360 + "CommentAtWho": {
  2361 + "type": "object",
  2362 + "properties": {
  2363 + "id": {
  2364 + "type": "integer",
  2365 + "format": "int64"
  2366 + },
  2367 + "name": {
  2368 + "type": "string"
  2369 + }
  2370 + },
  2371 + "title": "CommentAtWho",
  2372 + "required": [
  2373 + "id"
  2374 + ]
  2375 + },
  2376 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
1879 "CommentAuthor": { 2377 "CommentAuthor": {
1880 "type": "object", 2378 "type": "object",
1881 "properties": { 2379 "properties": {
@@ -1904,10 +2402,14 @@ @@ -1904,10 +2402,14 @@
1904 "title": "CommentAuthor", 2402 "title": "CommentAuthor",
1905 "required": [ 2403 "required": [
1906 "id", 2404 "id",
  2405 +<<<<<<< HEAD
1907 "name", 2406 "name",
1908 "avatar", 2407 "avatar",
1909 "position", 2408 "position",
1910 "company" 2409 "company"
  2410 +=======
  2411 + "name"
  2412 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
1911 ] 2413 ]
1912 }, 2414 },
1913 "Company": { 2415 "Company": {
@@ -2112,12 +2614,28 @@ @@ -2112,12 +2614,28 @@
2112 }, 2614 },
2113 "name": { 2615 "name": {
2114 "type": "string" 2616 "type": "string"
  2617 +<<<<<<< HEAD
  2618 +=======
  2619 + },
  2620 + "ids": {
  2621 + "type": "array",
  2622 + "items": {
  2623 + "type": "integer",
  2624 + "format": "int64"
  2625 + },
  2626 + "description": " 用户ID"
  2627 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
2115 } 2628 }
2116 }, 2629 },
2117 "title": "DepartmentUpdateRequest", 2630 "title": "DepartmentUpdateRequest",
2118 "required": [ 2631 "required": [
2119 "id", 2632 "id",
  2633 +<<<<<<< HEAD
2120 "name" 2634 "name"
  2635 +=======
  2636 + "name",
  2637 + "ids"
  2638 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
2121 ] 2639 ]
2122 }, 2640 },
2123 "FollowRequest": { 2641 "FollowRequest": {
@@ -2363,6 +2881,58 @@ @@ -2363,6 +2881,58 @@
2363 "total" 2881 "total"
2364 ] 2882 ]
2365 }, 2883 },
  2884 + "MiniAllArticleTagRequest": {
  2885 + "type": "object",
  2886 + "properties": {
  2887 + "": {
  2888 + "type": "integer",
  2889 + "format": "int64",
  2890 + "description": " 公司id"
  2891 + },
  2892 + "": {
  2893 + "type": "integer",
  2894 + "format": "int64",
  2895 + "description": " 公司id"
  2896 + },
  2897 + "articleId": {
  2898 + "type": "integer",
  2899 + "format": "int64",
  2900 + "description": " 文章id"
  2901 + },
  2902 + "tagId": {
  2903 + "type": "integer",
  2904 + "format": "int64",
  2905 + "description": " 标签id"
  2906 + }
  2907 + },
  2908 + "title": "MiniAllArticleTagRequest",
  2909 + "required": [
  2910 + "articleId",
  2911 + "tagId"
  2912 + ]
  2913 + },
  2914 + "MiniAllArticleTagResponse": {
  2915 + "type": "object",
  2916 + "properties": {
  2917 + "tagGroup": {
  2918 + "type": "array",
  2919 + "items": {
  2920 + "type": "string"
  2921 + }
  2922 + },
  2923 + "tags": {
  2924 + "type": "array",
  2925 + "items": {
  2926 + "$ref": "#/definitions/ArticleTagItem"
  2927 + }
  2928 + }
  2929 + },
  2930 + "title": "MiniAllArticleTagResponse",
  2931 + "required": [
  2932 + "tagGroup",
  2933 + "tags"
  2934 + ]
  2935 + },
2366 "MiniArticleBackupItem": { 2936 "MiniArticleBackupItem": {
2367 "type": "object", 2937 "type": "object",
2368 "properties": { 2938 "properties": {
@@ -2465,6 +3035,45 @@ @@ -2465,6 +3035,45 @@
2465 "type": "object", 3035 "type": "object",
2466 "title": "MiniArticleCommentAtUserResponse" 3036 "title": "MiniArticleCommentAtUserResponse"
2467 }, 3037 },
  3038 +<<<<<<< HEAD
  3039 +=======
  3040 + "MiniArticleCommentAtWhoRequest": {
  3041 + "type": "object",
  3042 + "properties": {
  3043 + "": {
  3044 + "type": "integer",
  3045 + "format": "int64"
  3046 + },
  3047 + "": {
  3048 + "type": "integer",
  3049 + "format": "int64"
  3050 + },
  3051 + "articleId": {
  3052 + "type": "integer",
  3053 + "format": "int64"
  3054 + }
  3055 + },
  3056 + "title": "MiniArticleCommentAtWhoRequest",
  3057 + "required": [
  3058 + "articleId"
  3059 + ]
  3060 + },
  3061 + "MiniArticleCommentAtWhoResponse": {
  3062 + "type": "object",
  3063 + "properties": {
  3064 + "list": {
  3065 + "type": "array",
  3066 + "items": {
  3067 + "$ref": "#/definitions/CommentAtWho"
  3068 + }
  3069 + }
  3070 + },
  3071 + "title": "MiniArticleCommentAtWhoResponse",
  3072 + "required": [
  3073 + "list"
  3074 + ]
  3075 + },
  3076 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
2468 "MiniArticleCreateRequest": { 3077 "MiniArticleCreateRequest": {
2469 "type": "object", 3078 "type": "object",
2470 "properties": { 3079 "properties": {
@@ -3023,7 +3632,11 @@ @@ -3023,7 +3632,11 @@
3023 "meLoveFlag": { 3632 "meLoveFlag": {
3024 "type": "integer", 3633 "type": "integer",
3025 "format": "int32", 3634 "format": "int32",
  3635 +<<<<<<< HEAD
3026 "description": "当前人员对文章的点赞标识" 3636 "description": "当前人员对文章的点赞标识"
  3637 +=======
  3638 + "description": " 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)"
  3639 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
3027 } 3640 }
3028 }, 3641 },
3029 "title": "MiniArticleGetResponse", 3642 "title": "MiniArticleGetResponse",
@@ -3209,6 +3822,52 @@ @@ -3209,6 +3822,52 @@
3209 "list" 3822 "list"
3210 ] 3823 ]
3211 }, 3824 },
  3825 +<<<<<<< HEAD
  3826 +=======
  3827 + "MiniArticleSetTagRequest": {
  3828 + "type": "object",
  3829 + "properties": {
  3830 + "": {
  3831 + "type": "integer",
  3832 + "format": "int64",
  3833 + "description": " 公司id"
  3834 + },
  3835 + "": {
  3836 + "type": "integer",
  3837 + "format": "int64",
  3838 + "description": " 公司id"
  3839 + },
  3840 + "articleId": {
  3841 + "type": "integer",
  3842 + "format": "int64",
  3843 + "description": " 文章id"
  3844 + },
  3845 + "tagId": {
  3846 + "type": "integer",
  3847 + "format": "int64",
  3848 + "description": " 标签id"
  3849 + }
  3850 + },
  3851 + "title": "MiniArticleSetTagRequest",
  3852 + "required": [
  3853 + "articleId",
  3854 + "tagId"
  3855 + ]
  3856 + },
  3857 + "MiniArticleSetTagResponse": {
  3858 + "type": "object",
  3859 + "properties": {
  3860 + "id": {
  3861 + "type": "integer",
  3862 + "format": "int64"
  3863 + }
  3864 + },
  3865 + "title": "MiniArticleSetTagResponse",
  3866 + "required": [
  3867 + "id"
  3868 + ]
  3869 + },
  3870 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
3212 "MiniCreateArticleCommentRequest": { 3871 "MiniCreateArticleCommentRequest": {
3213 "type": "object", 3872 "type": "object",
3214 "properties": { 3873 "properties": {
@@ -3232,7 +3891,11 @@ @@ -3232,7 +3891,11 @@
3232 "format": "int64", 3891 "format": "int64",
3233 "description": " 服务端自动获取" 3892 "description": " 服务端自动获取"
3234 }, 3893 },
  3894 +<<<<<<< HEAD
3235 "commnet": { 3895 "commnet": {
  3896 +=======
  3897 + "pid": {
  3898 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
3236 "type": "integer", 3899 "type": "integer",
3237 "format": "int64", 3900 "format": "int64",
3238 "description": " 回复那个评论的id" 3901 "description": " 回复那个评论的id"
@@ -3244,8 +3907,12 @@ @@ -3244,8 +3907,12 @@
3244 "atWho": { 3907 "atWho": {
3245 "type": "array", 3908 "type": "array",
3246 "items": { 3909 "items": {
  3910 +<<<<<<< HEAD
3247 "type": "integer", 3911 "type": "integer",
3248 "format": "int64" 3912 "format": "int64"
  3913 +=======
  3914 + "$ref": "#/definitions/CommentAtWho"
  3915 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
3249 }, 3916 },
3250 "description": " 填写评论时@的人" 3917 "description": " 填写评论时@的人"
3251 } 3918 }
@@ -3254,97 +3921,235 @@ @@ -3254,97 +3921,235 @@
3254 "required": [ 3921 "required": [
3255 "articleId", 3922 "articleId",
3256 "sectionId", 3923 "sectionId",
  3924 +<<<<<<< HEAD
3257 "commnet", 3925 "commnet",
  3926 +=======
  3927 + "pid",
  3928 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
3258 "content", 3929 "content",
3259 "atWho" 3930 "atWho"
3260 ] 3931 ]
3261 }, 3932 },
3262 - "MiniCreateArticleCommentResponse": { 3933 + "MiniCreateArticleCommentResponse": {
  3934 + "type": "object",
  3935 + "properties": {
  3936 + "id": {
  3937 + "type": "integer",
  3938 + "format": "int64"
  3939 + },
  3940 + "pid": {
  3941 + "type": "integer",
  3942 + "format": "int64"
  3943 + },
  3944 + "topId": {
  3945 + "type": "integer",
  3946 + "format": "int64"
  3947 + },
  3948 + "articleId": {
  3949 + "type": "integer",
  3950 + "format": "int64",
  3951 + "description": " 文章id"
  3952 + },
  3953 + "sectionId": {
  3954 + "type": "integer",
  3955 + "format": "int64",
  3956 + "description": " 段落id"
  3957 + },
  3958 + "fromUserId": {
  3959 + "type": "integer",
  3960 + "format": "int64",
  3961 + "description": " 填写评论的人"
  3962 + },
  3963 + "fromUser": {
  3964 + "$ref": "#/definitions/CommentAuthor",
  3965 + "description": " 填写评论的人"
  3966 + },
  3967 + "toUserId": {
  3968 + "type": "integer",
  3969 + "format": "int64",
  3970 + "description": " 回复哪个人"
  3971 + },
  3972 + "toUser": {
  3973 + "$ref": "#/definitions/CommentAuthor",
  3974 + "description": " 回复哪个人"
  3975 + },
  3976 + "sectionContent": {
  3977 + "type": "string",
  3978 + "description": " 引用的文章内容文本"
  3979 + },
  3980 + "countReply": {
  3981 + "type": "integer",
  3982 + "format": "int32",
  3983 + "description": " 回复数量"
  3984 + },
  3985 + "countUserLove": {
  3986 + "type": "integer",
  3987 + "format": "int32",
  3988 + "description": " 用户点赞数量"
  3989 + },
  3990 + "countAdminLove": {
  3991 + "type": "integer",
  3992 + "format": "int32",
  3993 + "description": " 运营点赞数量"
  3994 + },
  3995 + "atWho": {
  3996 + "type": "array",
  3997 + "items": {
  3998 +<<<<<<< HEAD
  3999 + "$ref": "#/definitions/CommentAuthor"
  4000 + },
  4001 + "description": " 填写评论时@的人"
  4002 +=======
  4003 + "$ref": "#/definitions/CommentAtWho"
  4004 + },
  4005 + "description": " 填写评论时@的人"
  4006 + },
  4007 + "createdAt": {
  4008 + "type": "integer",
  4009 + "format": "int64"
  4010 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
  4011 + }
  4012 + },
  4013 + "title": "MiniCreateArticleCommentResponse",
  4014 + "required": [
  4015 + "id",
  4016 + "pid",
  4017 + "topId",
  4018 + "articleId",
  4019 + "sectionId",
  4020 + "fromUserId",
  4021 + "fromUser",
  4022 + "toUserId",
  4023 + "toUser",
  4024 + "sectionContent",
  4025 + "countReply",
  4026 + "countUserLove",
  4027 + "countAdminLove",
  4028 +<<<<<<< HEAD
  4029 + "atWho"
  4030 +=======
  4031 + "atWho",
  4032 + "createdAt"
  4033 + ]
  4034 + },
  4035 + "MiniDeleteArticleCommentRequest": {
  4036 + "type": "object",
  4037 + "properties": {
  4038 + "id": {
  4039 + "type": "integer",
  4040 + "format": "int64"
  4041 + },
  4042 + "": {
  4043 + "type": "integer",
  4044 + "format": "int64"
  4045 + },
  4046 + "": {
  4047 + "type": "integer",
  4048 + "format": "int64"
  4049 + }
  4050 + },
  4051 + "title": "MiniDeleteArticleCommentRequest",
  4052 + "required": [
  4053 + "id"
  4054 + ]
  4055 + },
  4056 + "MiniDeleteArticleCommentResponse": {
  4057 + "type": "object",
  4058 + "properties": {
  4059 + "id": {
  4060 + "type": "integer",
  4061 + "format": "int64"
  4062 + }
  4063 + },
  4064 + "title": "MiniDeleteArticleCommentResponse",
  4065 + "required": [
  4066 + "id"
  4067 + ]
  4068 + },
  4069 + "MiniGetArticleCommentRequest": {
3263 "type": "object", 4070 "type": "object",
3264 "properties": { 4071 "properties": {
3265 "id": { 4072 "id": {
3266 "type": "integer", 4073 "type": "integer",
3267 "format": "int64" 4074 "format": "int64"
3268 }, 4075 },
3269 - "pid": { 4076 + "": {
3270 "type": "integer", 4077 "type": "integer",
3271 "format": "int64" 4078 "format": "int64"
3272 }, 4079 },
3273 - "topId": { 4080 + "": {
3274 "type": "integer", 4081 "type": "integer",
3275 "format": "int64" 4082 "format": "int64"
3276 - },  
3277 - "articleId": { 4083 + }
  4084 + },
  4085 + "title": "MiniGetArticleCommentRequest",
  4086 + "required": [
  4087 + "id"
  4088 + ]
  4089 + },
  4090 + "MiniGetArticleCommentResponse": {
  4091 + "type": "object",
  4092 + "properties": {
  4093 + "": {
  4094 + "$ref": "#/definitions/ArticleCommentAndReply"
  4095 + }
  4096 + },
  4097 + "title": "MiniGetArticleCommentResponse"
  4098 + },
  4099 + "MiniListArticleCommentRequest": {
  4100 + "type": "object",
  4101 + "properties": {
  4102 + "page": {
3278 "type": "integer", 4103 "type": "integer",
3279 - "format": "int64",  
3280 - "description": " 文章id" 4104 + "format": "int32"
3281 }, 4105 },
3282 - "sectionId": { 4106 + "size": {
3283 "type": "integer", 4107 "type": "integer",
3284 - "format": "int64",  
3285 - "description": " 段落id" 4108 + "format": "int32"
3286 }, 4109 },
3287 - "fromUserId": { 4110 + "": {
3288 "type": "integer", 4111 "type": "integer",
3289 - "format": "int64",  
3290 - "description": " 填写评论的人"  
3291 - },  
3292 - "fromUser": {  
3293 - "$ref": "#/definitions/CommentAuthor",  
3294 - "description": " 填写评论的人" 4112 + "format": "int64"
3295 }, 4113 },
3296 - "toUserId": { 4114 + "": {
3297 "type": "integer", 4115 "type": "integer",
3298 - "format": "int64",  
3299 - "description": " 回复哪个人"  
3300 - },  
3301 - "toUser": {  
3302 - "$ref": "#/definitions/CommentAuthor",  
3303 - "description": " 回复哪个人"  
3304 - },  
3305 - "sectionContent": {  
3306 - "type": "string",  
3307 - "description": " 引用的文章内容文本" 4116 + "format": "int64"
3308 }, 4117 },
3309 - "countReply": { 4118 + "articleId": {
3310 "type": "integer", 4119 "type": "integer",
3311 - "format": "int32",  
3312 - "description": " 回复数量" 4120 + "format": "int64"
3313 }, 4121 },
3314 - "countUserLove": { 4122 + "sectionId": {
3315 "type": "integer", 4123 "type": "integer",
3316 - "format": "int32",  
3317 - "description": " 用户点赞数量"  
3318 - },  
3319 - "countAdminLove": { 4124 + "format": "int64"
  4125 + }
  4126 + },
  4127 + "title": "MiniListArticleCommentRequest",
  4128 + "required": [
  4129 + "page",
  4130 + "size",
  4131 + "articleId"
  4132 + ]
  4133 + },
  4134 + "MiniListArticleCommentResponse": {
  4135 + "type": "object",
  4136 + "properties": {
  4137 + "total": {
3320 "type": "integer", 4138 "type": "integer",
3321 - "format": "int32",  
3322 - "description": " 运营点赞数量" 4139 + "format": "int64"
3323 }, 4140 },
3324 - "atWho": { 4141 + "list": {
3325 "type": "array", 4142 "type": "array",
3326 "items": { 4143 "items": {
3327 - "$ref": "#/definitions/CommentAuthor"  
3328 - },  
3329 - "description": " 填写评论时@的人" 4144 + "$ref": "#/definitions/ArticleCommentAndReply"
  4145 + }
3330 } 4146 }
3331 }, 4147 },
3332 - "title": "MiniCreateArticleCommentResponse", 4148 + "title": "MiniListArticleCommentResponse",
3333 "required": [ 4149 "required": [
3334 - "id",  
3335 - "pid",  
3336 - "topId",  
3337 - "articleId",  
3338 - "sectionId",  
3339 - "fromUserId",  
3340 - "fromUser",  
3341 - "toUserId",  
3342 - "toUser",  
3343 - "sectionContent",  
3344 - "countReply",  
3345 - "countUserLove",  
3346 - "countAdminLove",  
3347 - "atWho" 4150 + "total",
  4151 + "list"
  4152 +>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
3348 ] 4153 ]
3349 }, 4154 },
3350 "MiniMyLikeRequest": { 4155 "MiniMyLikeRequest": {
@@ -3442,6 +4247,42 @@ @@ -3442,6 +4247,42 @@
3442 "count" 4247 "count"
3443 ] 4248 ]
3444 }, 4249 },
  4250 + "MiniTop5ArticleCommentRequest": {
  4251 + "type": "object",
  4252 + "properties": {
  4253 + "": {
  4254 + "type": "integer",
  4255 + "format": "int64"
  4256 + },
  4257 + "": {
  4258 + "type": "integer",
  4259 + "format": "int64"
  4260 + },
  4261 + "articleId": {
  4262 + "type": "integer",
  4263 + "format": "int64"
  4264 + }
  4265 + },
  4266 + "title": "MiniTop5ArticleCommentRequest",
  4267 + "required": [
  4268 + "articleId"
  4269 + ]
  4270 + },
  4271 + "MiniTop5ArticleCommentResponse": {
  4272 + "type": "object",
  4273 + "properties": {
  4274 + "list": {
  4275 + "type": "array",
  4276 + "items": {
  4277 + "$ref": "#/definitions/ArticleCommentItem"
  4278 + }
  4279 + }
  4280 + },
  4281 + "title": "MiniTop5ArticleCommentResponse",
  4282 + "required": [
  4283 + "list"
  4284 + ]
  4285 + },
3445 "MiniUserApplyJoinCompanyRequest": { 4286 "MiniUserApplyJoinCompanyRequest": {
3446 "type": "object", 4287 "type": "object",
3447 "properties": { 4288 "properties": {
@@ -4114,6 +4955,60 @@ @@ -4114,6 +4955,60 @@
4114 "value" 4955 "value"
4115 ] 4956 ]
4116 }, 4957 },
  4958 + "SystemArticleCommentSearchMeRequest": {
  4959 + "type": "object",
  4960 + "properties": {
  4961 + "page": {
  4962 + "type": "integer",
  4963 + "format": "int32"
  4964 + },
  4965 + "size": {
  4966 + "type": "integer",
  4967 + "format": "int32"
  4968 + },
  4969 + "authorId": {
  4970 + "type": "integer",
  4971 + "format": "int64",
  4972 + "description": " 用户"
  4973 + },
  4974 + "beginTime": {
  4975 + "type": "integer",
  4976 + "format": "int64",
  4977 + "description": " 开始时间"
  4978 + },
  4979 + "endTime": {
  4980 + "type": "integer",
  4981 + "format": "int64",
  4982 + "description": " 结束时间"
  4983 + }
  4984 + },
  4985 + "title": "SystemArticleCommentSearchMeRequest",
  4986 + "required": [
  4987 + "page",
  4988 + "size",
  4989 + "authorId"
  4990 + ]
  4991 + },
  4992 + "SystemArticleCommentSearchMeResponse": {
  4993 + "type": "object",
  4994 + "properties": {
  4995 + "list": {
  4996 + "type": "array",
  4997 + "items": {
  4998 + "$ref": "#/definitions/ArticleCommentItem"
  4999 + }
  5000 + },
  5001 + "total": {
  5002 + "type": "integer",
  5003 + "format": "int64"
  5004 + }
  5005 + },
  5006 + "title": "SystemArticleCommentSearchMeResponse",
  5007 + "required": [
  5008 + "list",
  5009 + "total"
  5010 + ]
  5011 + },
4117 "SystemArticleGetRequest": { 5012 "SystemArticleGetRequest": {
4118 "type": "object", 5013 "type": "object",
4119 "properties": { 5014 "properties": {
@@ -4368,6 +5263,60 @@ @@ -4368,6 +5263,60 @@
4368 "targetUser" 5263 "targetUser"
4369 ] 5264 ]
4370 }, 5265 },
  5266 + "SystemArticleSearchMeRequest": {
  5267 + "type": "object",
  5268 + "properties": {
  5269 + "page": {
  5270 + "type": "integer",
  5271 + "format": "int32"
  5272 + },
  5273 + "size": {
  5274 + "type": "integer",
  5275 + "format": "int32"
  5276 + },
  5277 + "authorId": {
  5278 + "type": "integer",
  5279 + "format": "int64",
  5280 + "description": " 用户"
  5281 + },
  5282 + "beginTime": {
  5283 + "type": "integer",
  5284 + "format": "int64",
  5285 + "description": " 开始时间"
  5286 + },
  5287 + "endTime": {
  5288 + "type": "integer",
  5289 + "format": "int64",
  5290 + "description": " 结束时间"
  5291 + }
  5292 + },
  5293 + "title": "SystemArticleSearchMeRequest",
  5294 + "required": [
  5295 + "page",
  5296 + "size",
  5297 + "authorId"
  5298 + ]
  5299 + },
  5300 + "SystemArticleSearchMeResponse": {
  5301 + "type": "object",
  5302 + "properties": {
  5303 + "total": {
  5304 + "type": "integer",
  5305 + "format": "int32"
  5306 + },
  5307 + "list": {
  5308 + "type": "array",
  5309 + "items": {
  5310 + "$ref": "#/definitions/ArticleSearchMe"
  5311 + }
  5312 + }
  5313 + },
  5314 + "title": "SystemArticleSearchMeResponse",
  5315 + "required": [
  5316 + "total",
  5317 + "list"
  5318 + ]
  5319 + },
4371 "SystemArticleSearchRequest": { 5320 "SystemArticleSearchRequest": {
4372 "type": "object", 5321 "type": "object",
4373 "properties": { 5322 "properties": {
@@ -4848,7 +5797,15 @@ @@ -4848,7 +5797,15 @@
4848 }, 5797 },
4849 "SystemUserInfoRequest": { 5798 "SystemUserInfoRequest": {
4850 "type": "object", 5799 "type": "object",
4851 - "title": "SystemUserInfoRequest" 5800 + "properties": {
  5801 + "Token": {
  5802 + "type": "string"
  5803 + }
  5804 + },
  5805 + "title": "SystemUserInfoRequest",
  5806 + "required": [
  5807 + "x-mmm-accesstoken"
  5808 + ]
4852 }, 5809 },
4853 "SystemUserInfoResponse": { 5810 "SystemUserInfoResponse": {
4854 "type": "object", 5811 "type": "object",
@@ -4869,6 +5826,9 @@ @@ -4869,6 +5826,9 @@
4869 }, 5826 },
4870 "companyName": { 5827 "companyName": {
4871 "type": "string" 5828 "type": "string"
  5829 + },
  5830 + "code": {
  5831 + "type": "string"
4872 } 5832 }
4873 }, 5833 },
4874 "title": "SystemUserInfoResponse", 5834 "title": "SystemUserInfoResponse",
@@ -4877,7 +5837,8 @@ @@ -4877,7 +5837,8 @@
4877 "userName", 5837 "userName",
4878 "avatar", 5838 "avatar",
4879 "companyId", 5839 "companyId",
4880 - "companyName" 5840 + "companyName",
  5841 + "code"
4881 ] 5842 ]
4882 }, 5843 },
4883 "SystemUserSearchRequest": { 5844 "SystemUserSearchRequest": {
@@ -5443,28 +6404,35 @@ @@ -5443,28 +6404,35 @@
5443 "itemFlag": { 6404 "itemFlag": {
5444 "type": "integer", 6405 "type": "integer",
5445 "format": "int32", 6406 "format": "int32",
5446 - "description": " 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳" 6407 + "description": "0:默认查询所有 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳"
5447 } 6408 }
5448 }, 6409 },
5449 "title": "UserStatisticsRequest", 6410 "title": "UserStatisticsRequest",
5450 "required": [ 6411 "required": [
5451 - "userId",  
5452 "itemFlag" 6412 "itemFlag"
5453 ] 6413 ]
5454 }, 6414 },
5455 "UserStatisticsResponse": { 6415 "UserStatisticsResponse": {
5456 "type": "object", 6416 "type": "object",
5457 "properties": { 6417 "properties": {
5458 - "list": {  
5459 - "type": "array",  
5460 - "items": {  
5461 - "$ref": "#/definitions/StatisticsItem"  
5462 - } 6418 + "totalArticle": {
  6419 + "type": "integer",
  6420 + "format": "int32"
  6421 + },
  6422 + "totalComment": {
  6423 + "type": "integer",
  6424 + "format": "int32"
  6425 + },
  6426 + "totalLoved": {
  6427 + "type": "integer",
  6428 + "format": "int32"
5463 } 6429 }
5464 }, 6430 },
5465 "title": "UserStatisticsResponse", 6431 "title": "UserStatisticsResponse",
5466 "required": [ 6432 "required": [
5467 - "list" 6433 + "totalArticle",
  6434 + "totalComment",
  6435 + "totalLoved"
5468 ] 6436 ]
5469 }, 6437 },
5470 "WhichUserLikeArticle": { 6438 "WhichUserLikeArticle": {
@@ -63,6 +63,15 @@ service Core { @@ -63,6 +63,15 @@ service Core {
63 @doc "小程序获取文章的编辑记录" 63 @doc "小程序获取文章的编辑记录"
64 @handler MiniArticleBackupSearch 64 @handler MiniArticleBackupSearch
65 post /article_backup/search (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse) 65 post /article_backup/search (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse)
  66 +
  67 +
  68 + @doc "小程序设置文章的定性标签"
  69 + @handler MiniArticleSetTag
  70 + post /article/set_tag (MiniArticleSetTagRequest) returns (MiniArticleSetTagResponse)
  71 +
  72 + @doc "小程序所有的定性标签"
  73 + @handler MiniAllArticleTag
  74 + get /article_tag/list/all (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse)
66 } 75 }
67 76
68 // 管理后台接口 77 // 管理后台接口
@@ -87,4 +96,9 @@ service Core { @@ -87,4 +96,9 @@ service Core {
87 @doc "管理后台编辑历史" 96 @doc "管理后台编辑历史"
88 @handler SystemHistoryArticle 97 @handler SystemHistoryArticle
89 post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse) 98 post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse)
  99 +
  100 + @doc "管理后台获取我发布的文章"
  101 + @handler SystemArticleSearchMe
  102 + post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse)
  103 +
90 } 104 }
@@ -8,14 +8,42 @@ info( @@ -8,14 +8,42 @@ info(
8 version: "v1" 8 version: "v1"
9 ) 9 )
10 10
  11 +@server(
  12 + prefix: v1/system
  13 + group: tags
  14 + jwt: SystemAuth
  15 +)
  16 +service Core {
  17 + @doc "后台创建文章标签"
  18 + @handler CreateTag
  19 + post /article_tag (TagCreateRequest) returns (TagCreateResponse)
  20 +
  21 + @doc "后台编辑文章标签"
  22 + @handler EditTag
  23 + put /article_tag (TagEditRequest) returns (TagEditResponse)
  24 +
  25 + @doc "后台获取文章标签"
  26 + @handler GetTag
  27 + get /article_tag/:id (TagGetRequest) returns (TagGetResponse)
  28 +
  29 + @doc "后台删除文章标签"
  30 + @handler DeleteTag
  31 + delete /article_tag/:id (TagDeleteRequest) returns (TagDeleteResponse)
  32 +
  33 + @doc "后台搜索标签"
  34 + @handler SearchTag
  35 + post/article_tag/search (TagListRequest) returns (TagListResponse)
  36 +}
  37 +
11 // 创建标签 38 // 创建标签
12 type ( 39 type (
13 TagCreateRequest { 40 TagCreateRequest {
14 - CompanyId int64 `json:"companyId"` 41 + CompanyId int64 `json:",optional"`
15 Image string `json:"image"` 42 Image string `json:"image"`
16 Name string `json:"name"` // 标签名称 43 Name string `json:"name"` // 标签名称
17 - Group string `json:"group"` // 标签分类 44 + Category string `json:"category"` // 标签分类
18 Remark string `json:"remark,optional"` // 备注 45 Remark string `json:"remark,optional"` // 备注
  46 + Other string `json:"other"`
19 } 47 }
20 48
21 TagCreateResponse { 49 TagCreateResponse {
@@ -27,11 +55,12 @@ type ( @@ -27,11 +55,12 @@ type (
27 type ( 55 type (
28 TagEditRequest { 56 TagEditRequest {
29 Id int64 `json:"id"` 57 Id int64 `json:"id"`
30 - CompanyId int64 `json:"-"` 58 + CompanyId int64 `json:",optional"`
31 Image string `json:"image"` 59 Image string `json:"image"`
32 Name string `json:"name"` // 标签名称 60 Name string `json:"name"` // 标签名称
33 - Group string `json:"group"` // 标签分类 61 + Category string `json:"category"` // 标签分类
34 Remark string `json:"remark,optional"` // 备注 62 Remark string `json:"remark,optional"` // 备注
  63 + Other string `json:"other"`
35 } 64 }
36 65
37 TagEditResponse { 66 TagEditResponse {
@@ -43,14 +72,15 @@ type ( @@ -43,14 +72,15 @@ type (
43 type ( 72 type (
44 TagGetRequest { 73 TagGetRequest {
45 Id int64 `path:"id"` 74 Id int64 `path:"id"`
46 - CompanyId int64 `path:"-"` 75 + CompanyId int64 `path:",optional"`
47 } 76 }
48 TagGetResponse { 77 TagGetResponse {
49 - Id int64 `json:"id"`  
50 - Image string `json:"image"`  
51 - Name string `json:"name"` // 标签名称  
52 - Group string `json:"group"` // 标签分类  
53 - Remark string `json:"remark"` // 备注 78 + Id int64 `json:"id"`
  79 + Image string `json:"image"`
  80 + Name string `json:"name"` // 标签名称
  81 + Category string `json:"category"` // 标签分类
  82 + Remark string `json:"remark"` // 备注
  83 + Other string `json:"other"`
54 } 84 }
55 ) 85 )
56 86
@@ -59,9 +89,9 @@ type ( @@ -59,9 +89,9 @@ type (
59 TagListRequest { 89 TagListRequest {
60 Page int `json:"page"` 90 Page int `json:"page"`
61 Size int `json:"size"` 91 Size int `json:"size"`
62 - CompanyId int64 `json:"-"` 92 + CompanyId int64 `json:",optional"`
63 TagName string `json:"tagName,optional"` 93 TagName string `json:"tagName,optional"`
64 - Group string `json:"group,optional"` 94 + Category string `json:"category,optional"`
65 Remark string `json:"remark,optional"` 95 Remark string `json:"remark,optional"`
66 } 96 }
67 TagListResponse { 97 TagListResponse {
@@ -71,9 +101,9 @@ type ( @@ -71,9 +101,9 @@ type (
71 TagItem { 101 TagItem {
72 Id int64 `json:"id"` 102 Id int64 `json:"id"`
73 Image string `json:"image"` 103 Image string `json:"image"`
74 - Name string `json:"name"` // 标签名称  
75 - Group string `json:"group"` // 标签分类  
76 - Remark string `json:"remark"` // 备注 104 + Name string `json:"name"` // 标签名称
  105 + Category string `json:"category"` // 标签分类
  106 + Remark string `json:"remark"` // 备注
77 CreatedAt int64 `json:"createdAt"` 107 CreatedAt int64 `json:"createdAt"`
78 } 108 }
79 ) 109 )
@@ -82,36 +112,9 @@ type ( @@ -82,36 +112,9 @@ type (
82 type ( 112 type (
83 TagDeleteRequest { 113 TagDeleteRequest {
84 Id int64 `path:"id"` 114 Id int64 `path:"id"`
85 - CompanyId int64 `path:"-"` 115 + CompanyId int64 `path:",optional"`
86 } 116 }
87 TagDeleteResponse { 117 TagDeleteResponse {
88 Id int64 `json:"id"` 118 Id int64 `json:"id"`
89 } 119 }
90 -)  
91 -  
92 -@server(  
93 - prefix: v1/system  
94 - group: tags  
95 - jwt: MiniAuth  
96 -)  
97 -service Core {  
98 - @doc "后台创建文章标签"  
99 - @handler CreateTag  
100 - post /article_tag (TagCreateRequest) returns (TagCreateResponse)  
101 -  
102 - @doc "后台编辑文章标签"  
103 - @handler EditTag  
104 - put /article_tag (TagEditRequest) returns (TagEditResponse)  
105 -  
106 - @doc "后台获取文章标签"  
107 - @handler GetTag  
108 - get /article_tag/:id (TagGetRequest) returns (TagGetResponse)  
109 -  
110 - @doc "后台删除文章标签"  
111 - @handler DeleteTag  
112 - delete /article_tag/:id (TagDeleteRequest) returns (TagDeleteResponse)  
113 -  
114 - @doc "后台搜索标签"  
115 - @handler SearchTag  
116 - post/article_tag/search (TagListRequest) returns (TagListResponse)  
117 -}  
  120 +)
@@ -55,7 +55,7 @@ type ( @@ -55,7 +55,7 @@ type (
55 CountRead int `json:"countRead"` // 浏览数量 55 CountRead int `json:"countRead"` // 浏览数量
56 Show int `json:"show"` // 评论的展示状态(0显示、1不显示) 56 Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
57 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) 57 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
58 - MeLoveFlag int `json:"meLoveFlag"` //当前人员对文章的点赞标识 58 + MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
59 } 59 }
60 ArticleSection { 60 ArticleSection {
61 Id int64 `json:"id"` //段落id 61 Id int64 `json:"id"` //段落id
@@ -88,6 +88,18 @@ type ( @@ -88,6 +88,18 @@ type (
88 CountComment int `json:"CountComment"` //评论数量 88 CountComment int `json:"CountComment"` //评论数量
89 Show int `json:"show"` //是否隐藏 [0显示、1不显示] 89 Show int `json:"show"` //是否隐藏 [0显示、1不显示]
90 } 90 }
  91 +
  92 + SystemArticleSearchMeRequest {
  93 + Page int `json:"page"`
  94 + Size int `json:"size"`
  95 + AuthorId int64 `json:"authorId"` // 用户
  96 + BeginTime int64 `json:"beginTime,optional"` // 开始时间
  97 + EndTime int64 `json:"endTime,optional"` // 结束时间
  98 + }
  99 + SystemArticleSearchMeResponse {
  100 + Total int `json:"total"`
  101 + List []ArticleSearchMe `json:"list"`
  102 + }
91 ) 103 )
92 104
93 //小程序端获取文章有哪些人进行了点赞 105 //小程序端获取文章有哪些人进行了点赞
@@ -107,6 +119,7 @@ type ( @@ -107,6 +119,7 @@ type (
107 UserId int64 `json:"userId"` // 人员id 119 UserId int64 `json:"userId"` // 人员id
108 Name string `json:"name"` // 人员名称 120 Name string `json:"name"` // 人员名称
109 Avatar string `json:"avatar"` // 人员头像 121 Avatar string `json:"avatar"` // 人员头像
  122 + Position string `json:"position"` // 职位
110 CreatedAt int64 `json:"createdAt"` // 点赞记录的时间 123 CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
111 } 124 }
112 ) 125 )
@@ -278,6 +291,40 @@ type ( @@ -278,6 +291,40 @@ type (
278 } 291 }
279 ) 292 )
280 293
  294 +//小程序端设置文章的定性标签
  295 +type (
  296 + MiniArticleSetTagRequest{
  297 + CompanyId int64 `json:",optional"` // 公司id
  298 + UserId int64 `json:",optional"` // 公司id
  299 + ArticleId int64 `json:"articleId"` // 文章id
  300 + TagId int64 `json:"tagId"` // 标签id
  301 + }
  302 + MiniArticleSetTagResponse{
  303 + Id int64 `json:"id"`
  304 + }
  305 +)
  306 +
  307 +
  308 +//小程序端获取所有的定性标签
  309 +type (
  310 + MiniAllArticleTagRequest{
  311 + CompanyId int64 `json:",optional"` // 公司id
  312 + UserId int64 `json:",optional"` // 公司id
  313 + }
  314 + MiniAllArticleTagResponse{
  315 + TagGroup []ArticleTagGroup `json:"tagGroup"`
  316 + }
  317 + ArticleTagGroup {
  318 + Group string `json:"group"`
  319 + Tags []ArticleTagItem `json:"tags"`
  320 + }
  321 + ArticleTagItem {
  322 + Id int64 `json:"id"`
  323 + Group string `json:"group"`
  324 + Name string `json:"name"`
  325 + Image string `json:"image"`
  326 + }
  327 +)
281 328
282 329
283 330
@@ -23,6 +23,39 @@ service Core { @@ -23,6 +23,39 @@ service Core {
23 @doc "小程序填写文章的评论" 23 @doc "小程序填写文章的评论"
24 @handler MiniCreateArticleComment 24 @handler MiniCreateArticleComment
25 post /article_comment (MiniCreateArticleCommentRequest) returns (MiniCreateArticleCommentResponse) 25 post /article_comment (MiniCreateArticleCommentRequest) returns (MiniCreateArticleCommentResponse)
  26 +
  27 + @doc "小程序展示文章的评论列表"
  28 + @handler MiniListArticleComment
  29 + post /article_comment/list (MiniListArticleCommentRequest) returns (MiniListArticleCommentResponse)
  30 +
  31 + @doc "小程序展示文章的评论列表TOP5"
  32 + @handler MiniTop5ArticleComment
  33 + post /article_comment/top5 (MiniTop5ArticleCommentRequest) returns (MiniTop5ArticleCommentResponse)
  34 +
  35 + @doc "小程序展示单个文章的评论"
  36 + @handler MiniGetArticleComment
  37 + get /article_comment/:id (MiniGetArticleCommentRequest) returns (MiniGetArticleCommentResponse)
  38 +
  39 + @doc "小程序展示删除文章评论"
  40 + @handler MiniDeleteArticleComment
  41 + delete /article_comment/:id (MiniDeleteArticleCommentRequest) returns (MiniDeleteArticleCommentResponse)
  42 +
  43 + @doc "小程序展示评论时@人可选列表"
  44 + @handler MiniArticleCommentAtWho
  45 + post /article_comment/at_who/list (MiniArticleCommentAtWhoRequest) returns (MiniArticleCommentAtWhoResponse)
  46 +}
  47 +
  48 +// 后台接口
  49 +@server(
  50 + prefix: v1/system
  51 + group: comment
  52 + middleware: LoginStatusCheck
  53 + jwt: SystemAuth
  54 +)
  55 +service Core {
  56 + @doc "小程序获取回复@人可选列表"
  57 + @handler SystemArticleCommentSearchMe
  58 + post /article_comment/search/me (SystemArticleCommentSearchMeRequest) returns (SystemArticleCommentSearchMeResponse)
26 } 59 }
27 60
28 // 61 //
@@ -38,39 +71,151 @@ type ( @@ -38,39 +71,151 @@ type (
38 71
39 //评论的填写人 72 //评论的填写人
40 type CommentAuthor { 73 type CommentAuthor {
41 - Id int64 `json:"id"` // 人员id  
42 - Name string `json:"name"` // 人员的名字  
43 - Avatar string `json:"avatar"` // 人员头像URL  
44 - Position string `json:"position"` // 职位  
45 - Company string `json:"company"` // 公司 74 + Id int64 `json:"id"` // 人员id
  75 + Name string `json:"name"` // 人员的名字
  76 + Avatar string `json:"avatar,optional"` // 人员头像URL
  77 + Position string `json:"position,optional"` // 职位
  78 + Company string `json:"company,optional"` // 公司
46 } 79 }
47 80
48 // 小程序填写文章的评论 81 // 小程序填写文章的评论
49 type ( 82 type (
50 MiniCreateArticleCommentRequest { 83 MiniCreateArticleCommentRequest {
51 - ArtitcleId int64 `json:"articleId"` // 文章id  
52 - SectionId int64 `json:"sectionId"` // 段落id  
53 - FromUserId int64 `json:",optional"` // 填写文章的人,服务端自动获取  
54 - CompanyId int64 `json:",optional"` // 服务端自动获取  
55 - Pid int64 `json:"commnet"` // 回复那个评论的id  
56 - Content string `json:"content"` // 评论的内容  
57 - AtWho []int64 `json:"atWho"` // 填写评论时@的人 84 + ArtitcleId int64 `json:"articleId"` // 文章id
  85 + SectionId int64 `json:"sectionId"` // 段落id
  86 + FromUserId int64 `json:",optional"` // 填写文章的人,服务端自动获取
  87 + CompanyId int64 `json:",optional"` // 服务端自动获取
  88 + Pid int64 `json:"pid"` // 回复那个评论的id
  89 + Content string `json:"content"` // 评论的内容
  90 + AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
58 } 91 }
59 92
  93 + CommentAtWho {
  94 + Id int64 `json:"id"`
  95 + Name string `json:"name,optional"`
  96 + FirstLetter string `json:"firstLetter,optional"`
  97 + }
60 MiniCreateArticleCommentResponse { 98 MiniCreateArticleCommentResponse {
61 - Id int64 `json:"id"`  
62 - Pid int64 `json:"pid"`  
63 - TopId int64 `json:"topId"`  
64 - ArtitcleId int64 `json:"articleId"` // 文章id  
65 - SectionId int64 `json:"sectionId"` // 段落id  
66 - FromUserId int64 `json:"fromUserId"` // 填写评论的人  
67 - FromUser CommentAuthor `json:"fromUser"` // 填写评论的人  
68 - ToUserId int64 `json:"toUserId"` // 回复哪个人  
69 - ToUser CommentAuthor `json:"toUser"` // 回复哪个人  
70 - SectionContent string `json:"sectionContent"` // 引用的文章内容文本  
71 - CountReply int `json:"countReply"` // 回复数量  
72 - CountUserLove int `json:"countUserLove"` // 用户点赞数量  
73 - CountAdminLove int `json:"countAdminLove"` // 运营点赞数量  
74 - AtWho []CommentAuthor `json:"atWho"` // 填写评论时@的人 99 + Id int64 `json:"id"`
  100 + Pid int64 `json:"pid"`
  101 + TopId int64 `json:"topId"`
  102 + ArtitcleId int64 `json:"articleId"` // 文章id
  103 + SectionId int64 `json:"sectionId"` // 段落id
  104 + FromUserId int64 `json:"fromUserId"` // 填写评论的人
  105 + FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
  106 + ToUserId int64 `json:"toUserId"` // 回复哪个人
  107 + ToUser CommentAuthor `json:"toUser"` // 回复哪个人
  108 + SectionContent string `json:"sectionContent"` // 引用的文章内容文本
  109 + CountReply int `json:"countReply"` // 回复数量
  110 + CountUserLove int `json:"countUserLove"` // 用户点赞数量
  111 + CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
  112 + AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
  113 + CreatedAt int64 `json:"createdAt"` //
  114 + }
  115 +)
  116 +
  117 +// 小程序获取文章的评论列表
  118 +type (
  119 + MiniListArticleCommentRequest {
  120 + Page int `json:"page"`
  121 + Size int `json:"size"`
  122 + CompanyId int64 `json:",optional"`
  123 + UserId int64 `json:",optional"`
  124 + ArticleId int64 `json:"articleId"`
  125 + SectionId int64 `json:"sectionId,optional"`
  126 + }
  127 + MiniListArticleCommentResponse {
  128 + Total int64 `json:"total"`
  129 + List []ArticleCommentAndReply `json:"list"`
  130 + }
  131 +
  132 + ArticleCommentAndReply {
  133 + Comment ArticleCommentItem `json:"comment"` //评论
  134 + Reply []ArticleCommentItem `json:"reply"` //回复的评论
  135 + TotalReply int64 `json:"totalReply"` //回复的评论数量
  136 + }
  137 +
  138 + ArticleCommentItem {
  139 + Id int64 `json:"id"`
  140 + Pid int64 `json:"pid"`
  141 + TopId int64 `json:"topId"`
  142 + ArtitcleId int64 `json:"articleId"` // 文章id
  143 + SectionId int64 `json:"sectionId"` // 段落id
  144 + FromUserId int64 `json:"fromUserId"` // 填写评论的人
  145 + FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
  146 + ToUserId int64 `json:"toUserId"` // 回复哪个人
  147 + ToUser CommentAuthor `json:"toUser"` // 回复哪个人
  148 + SectionContent string `json:"sectionContent"` // 引用的文章内容文本
  149 + CountReply int `json:"countReply"` // 回复数量
  150 + CountUserLove int `json:"countUserLove"` // 用户点赞数量
  151 + CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
  152 + AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
  153 + CreatedAt int64 `json:"createdAt"` //
  154 + MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞)
  155 + Content string `json:"content"` // 评论的内容
  156 + }
  157 +)
  158 +
  159 +// 小程序获取单个文章的评论
  160 +type (
  161 + MiniGetArticleCommentRequest {
  162 + CommentId int64 `path:"id"`
  163 + CompanyId int64 `path:",optional"`
  164 + UserId int64 `path:",optional"`
  165 + }
  166 + MiniGetArticleCommentResponse {
  167 + ArticleCommentAndReply
  168 + }
  169 +)
  170 +
  171 +// 小程序删除单个文章的评论
  172 +type (
  173 + MiniDeleteArticleCommentRequest {
  174 + CommentId int64 `path:"id"`
  175 + UserId int64 `path:",optional"`
  176 + CompanyId int64 `path:",optional"`
  177 + }
  178 + MiniDeleteArticleCommentResponse {
  179 + Id int64 `json:"id"`
  180 + }
  181 +)
  182 +
  183 +// 热门前5的评论列表
  184 +type (
  185 + MiniTop5ArticleCommentRequest {
  186 + CompanyId int64 `json:",optional"`
  187 + UserId int64 `json:",optional"`
  188 + ArticleId int64 `json:"articleId"`
  189 + }
  190 +
  191 + MiniTop5ArticleCommentResponse {
  192 + List []ArticleCommentItem `json:"list"`
  193 + }
  194 +)
  195 +
  196 +// 填写评论时选择@人
  197 +type (
  198 + MiniArticleCommentAtWhoRequest {
  199 + CompanyId int64 `json:",optional"`
  200 + UserId int64 `json:",optional"`
  201 + ArticleId int64 `json:"articleId"`
  202 + }
  203 +
  204 + MiniArticleCommentAtWhoResponse {
  205 + List []CommentAtWho `json:"list"`
  206 + }
  207 +)
  208 +
  209 +type(
  210 + SystemArticleCommentSearchMeRequest{
  211 + Page int `json:"page"`
  212 + Size int `json:"size"`
  213 + AuthorId int64 `json:"authorId"` // 用户
  214 + BeginTime int64 `json:"beginTime,optional"` // 开始时间
  215 + EndTime int64 `json:"endTime,optional"` // 结束时间
  216 + }
  217 + SystemArticleCommentSearchMeResponse{
  218 + List []ArticleCommentItem `json:"list"`
  219 + Total int64 `json:"total"`
75 } 220 }
76 ) 221 )
@@ -11,6 +11,7 @@ info( @@ -11,6 +11,7 @@ info(
11 @server( 11 @server(
12 prefix: v1 12 prefix: v1
13 group: department 13 group: department
  14 + middleware: LoginStatusCheck
14 jwt: SystemAuth 15 jwt: SystemAuth
15 ) 16 )
16 service Core { 17 service Core {
@@ -29,6 +30,10 @@ service Core { @@ -29,6 +30,10 @@ service Core {
29 @doc "部门-更新" 30 @doc "部门-更新"
30 @handler systemUpdate 31 @handler systemUpdate
31 put /system/department/:id (DepartmentUpdateRequest) returns (DepartmentGetResponse) 32 put /system/department/:id (DepartmentUpdateRequest) returns (DepartmentGetResponse)
  33 +
  34 + @doc "部门-删除"
  35 + @handler systemDelete
  36 + delete /system/department/:id (DepartmentGetRequest) returns (DepartmentGetResponse)
32 } 37 }
33 38
34 type ( 39 type (
@@ -48,6 +53,7 @@ type ( @@ -48,6 +53,7 @@ type (
48 DepartmentUpdateRequest { 53 DepartmentUpdateRequest {
49 Id int64 `path:"id"` 54 Id int64 `path:"id"`
50 Name string `json:"name"` 55 Name string `json:"name"`
  56 + Ids []int64 `json:"ids"` // 用户ID
51 } 57 }
52 58
53 DepartmentListRequest { 59 DepartmentListRequest {
@@ -9,21 +9,27 @@ info( @@ -9,21 +9,27 @@ info(
9 ) 9 )
10 10
11 @server( 11 @server(
12 - prefix: v1  
13 - group: role  
14 - jwt: SystemAuth 12 + prefix: v1
  13 + group: role
  14 + middleware: LoginStatusCheck
  15 + jwt: SystemAuth
15 ) 16 )
16 service Core { 17 service Core {
17 - @handler systemGetRole  
18 - get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)  
19 - @handler systemSaveRole  
20 - post /system/role (RoleSaveRequest) returns (RoleSaveResponse)  
21 - @handler systemDeleteRole  
22 - delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)  
23 - @handler systemUpdateRole  
24 - put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)  
25 - @handler systemSearchRole  
26 - post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse) 18 + @doc "角色详情"
  19 + @handler systemGetRole
  20 + get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
  21 + @doc "角色新增"
  22 + @handler systemSaveRole
  23 + post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
  24 + @doc "角色删除"
  25 + @handler systemDeleteRole
  26 + delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
  27 + @doc "角色更新"
  28 + @handler systemUpdateRole
  29 + put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
  30 + @doc "角色列表搜索"
  31 + @handler systemSearchRole
  32 + post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
27 } 33 }
28 34
29 type ( 35 type (
@@ -209,6 +209,7 @@ type ( @@ -209,6 +209,7 @@ type (
209 @server( 209 @server(
210 prefix: v1 210 prefix: v1
211 group: user 211 group: user
  212 + middleware: LoginStatusCheck
212 jwt: SystemAuth 213 jwt: SystemAuth
213 ) 214 )
214 service Core { 215 service Core {
@@ -249,7 +250,7 @@ service Core { @@ -249,7 +250,7 @@ service Core {
249 250
250 type( 251 type(
251 SystemUserInfoRequest{ 252 SystemUserInfoRequest{
252 - 253 + Token string `header:"x-mmm-accesstoken"`
253 } 254 }
254 SystemUserInfoResponse{ 255 SystemUserInfoResponse{
255 UserId int64 `json:"userId"` 256 UserId int64 `json:"userId"`
@@ -257,13 +258,16 @@ type( @@ -257,13 +258,16 @@ type(
257 Avatar string `json:"avatar"` 258 Avatar string `json:"avatar"`
258 CompanyId int64 `json:"companyId"` 259 CompanyId int64 `json:"companyId"`
259 CompanyName string `json:"companyName"` 260 CompanyName string `json:"companyName"`
  261 + Code string `json:"code"`
260 } 262 }
261 UserStatisticsRequest{ 263 UserStatisticsRequest{
262 - UserId int64 `json:"userId"`  
263 - ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 264 + UserId int64 `json:"userId,optional"`
  265 + ItemFlag int `json:"itemFlag"` //0:默认查询所有 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
264 } 266 }
265 UserStatisticsResponse{ 267 UserStatisticsResponse{
266 - List []StatisticsItem `json:"list"` 268 + TotalArticle int `json:"totalArticle"`
  269 + TotalComment int `json:"totalComment"`
  270 + TotalLoved int `json:"totalLoved"`
267 } 271 }
268 StatisticsItem{ 272 StatisticsItem{
269 ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 273 ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
1 Name: discuss 1 Name: discuss
2 Host: 0.0.0.0 2 Host: 0.0.0.0
3 Port: 8081 3 Port: 8081
4 -Verbose: true 4 +Verbose: false
5 Migrate: false 5 Migrate: false
6 Timeout: 30000 6 Timeout: 30000
7 Log: 7 Log:
@@ -12,7 +12,7 @@ Log: @@ -12,7 +12,7 @@ Log:
12 TimeFormat: 2006-01-02 15:04:05.000 12 TimeFormat: 2006-01-02 15:04:05.000
13 13
14 SystemAuth: 14 SystemAuth:
15 - AccessSecret: discuss-secret 15 + AccessSecret: digital-platform
16 AccessExpire: 360000 16 AccessExpire: 360000
17 17
18 MiniAuth: 18 MiniAuth:
@@ -25,3 +25,8 @@ Redis: @@ -25,3 +25,8 @@ Redis:
25 Pass: 25 Pass:
26 DB: 26 DB:
27 DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=sumifcc-discuss-dev port=31543 sslmode=disable TimeZone=Asia/Shanghai 27 DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=sumifcc-discuss-dev port=31543 sslmode=disable TimeZone=Asia/Shanghai
  28 +
  29 +ApiAuth:
  30 + Name: ApiAuth
  31 + Host: http://digital-platform-dev.fjmaimaimai.com
  32 + Timeout: 0s
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "github.com/zeromicro/go-zero/core/stores/redis" 4 "github.com/zeromicro/go-zero/core/stores/redis"
5 "github.com/zeromicro/go-zero/rest" 5 "github.com/zeromicro/go-zero/rest"
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/config" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/config"
  7 + "time"
7 ) 8 )
8 9
9 type Config struct { 10 type Config struct {
@@ -13,4 +14,11 @@ type Config struct { @@ -13,4 +14,11 @@ type Config struct {
13 SystemAuth config.Auth 14 SystemAuth config.Auth
14 MiniAuth config.Auth 15 MiniAuth config.Auth
15 Migrate bool `json:",optional,default=true"` 16 Migrate bool `json:",optional,default=true"`
  17 + ApiAuth ApiService
  18 +}
  19 +
  20 +type ApiService struct {
  21 + Name string
  22 + Host string
  23 + Timeout time.Duration
16 } 24 }
  1 +package article
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  12 +)
  13 +
  14 +func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15 + return func(w http.ResponseWriter, r *http.Request) {
  16 + var req types.MiniAllArticleTagRequest
  17 + if err := httpx.Parse(r, &req); err != nil {
  18 + httpx.ErrorCtx(r.Context(), w, err)
  19 + return
  20 + }
  21 +
  22 + l := article.NewMiniAllArticleTagLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
  25 + req.UserId = token.UserId
  26 + resp, err := l.MiniAllArticleTag(&req)
  27 + result.HttpResult(r, w, resp, err)
  28 + }
  29 +}
  1 +package article
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +)
  11 +
  12 +func MiniArticleSetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.MiniArticleSetTagRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := article.NewMiniArticleSetTagLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniArticleSetTag(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  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 SystemArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  14 + return func(w http.ResponseWriter, r *http.Request) {
  15 + var req types.SystemArticleSearchMeRequest
  16 + if err := httpx.Parse(r, &req); err != nil {
  17 + httpx.ErrorCtx(r.Context(), w, err)
  18 + return
  19 + }
  20 +
  21 + l := article.NewSystemArticleSearchMeLogic(r.Context(), svcCtx)
  22 + resp, err := l.SystemArticleSearchMe(&req)
  23 + result.HttpResult(r, w, resp, err)
  24 + }
  25 +}
  1 +package comment
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  12 +)
  13 +
  14 +func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15 + return func(w http.ResponseWriter, r *http.Request) {
  16 + var req types.MiniArticleCommentAtWhoRequest
  17 + if err := httpx.Parse(r, &req); err != nil {
  18 + httpx.ErrorCtx(r.Context(), w, err)
  19 + return
  20 + }
  21 +
  22 + l := comment.NewMiniArticleCommentAtWhoLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
  25 + req.UserId = token.UserId
  26 + resp, err := l.MiniArticleCommentAtWho(&req)
  27 + result.HttpResult(r, w, resp, err)
  28 + }
  29 +}
  1 +package comment
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  12 +)
  13 +
  14 +func MiniDeleteArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15 + return func(w http.ResponseWriter, r *http.Request) {
  16 + var req types.MiniDeleteArticleCommentRequest
  17 + if err := httpx.Parse(r, &req); err != nil {
  18 + httpx.ErrorCtx(r.Context(), w, err)
  19 + return
  20 + }
  21 +
  22 + l := comment.NewMiniDeleteArticleCommentLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
  25 + req.UserId = token.UserId
  26 + resp, err := l.MiniDeleteArticleComment(&req)
  27 + result.HttpResult(r, w, resp, err)
  28 + }
  29 +}
  1 +package comment
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  12 +)
  13 +
  14 +func MiniGetArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15 + return func(w http.ResponseWriter, r *http.Request) {
  16 + var req types.MiniGetArticleCommentRequest
  17 + if err := httpx.Parse(r, &req); err != nil {
  18 + httpx.ErrorCtx(r.Context(), w, err)
  19 + return
  20 + }
  21 +
  22 + l := comment.NewMiniGetArticleCommentLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
  25 + req.UserId = token.UserId
  26 + resp, err := l.MiniGetArticleComment(&req)
  27 + result.HttpResult(r, w, resp, err)
  28 + }
  29 +}
  1 +package comment
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  12 +)
  13 +
  14 +func MiniListArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15 + return func(w http.ResponseWriter, r *http.Request) {
  16 + var req types.MiniListArticleCommentRequest
  17 + if err := httpx.Parse(r, &req); err != nil {
  18 + httpx.ErrorCtx(r.Context(), w, err)
  19 + return
  20 + }
  21 + l := comment.NewMiniListArticleCommentLogic(r.Context(), svcCtx)
  22 + token := contextdata.GetUserTokenFromCtx(r.Context())
  23 + req.CompanyId = token.CompanyId
  24 + req.UserId = token.UserId
  25 + resp, err := l.MiniListArticleComment(&req)
  26 + result.HttpResult(r, w, resp, err)
  27 + }
  28 +}
  1 +package comment
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  12 +)
  13 +
  14 +func MiniTop5ArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15 + return func(w http.ResponseWriter, r *http.Request) {
  16 + var req types.MiniTop5ArticleCommentRequest
  17 + if err := httpx.Parse(r, &req); err != nil {
  18 + httpx.ErrorCtx(r.Context(), w, err)
  19 + return
  20 + }
  21 +
  22 + l := comment.NewMiniTop5ArticleCommentLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
  25 + req.UserId = token.UserId
  26 + resp, err := l.MiniTop5ArticleComment(&req)
  27 + result.HttpResult(r, w, resp, err)
  28 + }
  29 +}
  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 SystemArticleCommentSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  14 + return func(w http.ResponseWriter, r *http.Request) {
  15 + var req types.SystemArticleCommentSearchMeRequest
  16 + if err := httpx.Parse(r, &req); err != nil {
  17 + httpx.ErrorCtx(r.Context(), w, err)
  18 + return
  19 + }
  20 +
  21 + l := comment.NewSystemArticleCommentSearchMeLogic(r.Context(), svcCtx)
  22 + resp, err := l.SystemArticleCommentSearchMe(&req)
  23 + result.HttpResult(r, w, resp, err)
  24 + }
  25 +}
  1 +package department
  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/department"
  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 SystemDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  14 + return func(w http.ResponseWriter, r *http.Request) {
  15 + var req types.DepartmentGetRequest
  16 + if err := httpx.Parse(r, &req); err != nil {
  17 + httpx.ErrorCtx(r.Context(), w, err)
  18 + return
  19 + }
  20 +
  21 + l := department.NewSystemDeleteLogic(r.Context(), svcCtx)
  22 + resp, err := l.SystemDelete(&req)
  23 + result.HttpResult(r, w, resp, err)
  24 + }
  25 +}
@@ -30,12 +30,52 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -30,12 +30,52 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
30 Path: "/article_comment", 30 Path: "/article_comment",
31 Handler: comment.MiniCreateArticleCommentHandler(serverCtx), 31 Handler: comment.MiniCreateArticleCommentHandler(serverCtx),
32 }, 32 },
  33 + {
  34 + Method: http.MethodPost,
  35 + Path: "/article_comment/list",
  36 + Handler: comment.MiniListArticleCommentHandler(serverCtx),
  37 + },
  38 + {
  39 + Method: http.MethodPost,
  40 + Path: "/article_comment/top5",
  41 + Handler: comment.MiniTop5ArticleCommentHandler(serverCtx),
  42 + },
  43 + {
  44 + Method: http.MethodGet,
  45 + Path: "/article_comment/:id",
  46 + Handler: comment.MiniGetArticleCommentHandler(serverCtx),
  47 + },
  48 + {
  49 + Method: http.MethodDelete,
  50 + Path: "/article_comment/:id",
  51 + Handler: comment.MiniDeleteArticleCommentHandler(serverCtx),
  52 + },
  53 + {
  54 + Method: http.MethodPost,
  55 + Path: "/article_comment/at_who/list",
  56 + Handler: comment.MiniArticleCommentAtWhoHandler(serverCtx),
  57 + },
33 }, 58 },
34 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), 59 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
35 rest.WithPrefix("/v1/mini"), 60 rest.WithPrefix("/v1/mini"),
36 ) 61 )
37 62
38 server.AddRoutes( 63 server.AddRoutes(
  64 + rest.WithMiddlewares(
  65 + []rest.Middleware{serverCtx.LoginStatusCheck},
  66 + []rest.Route{
  67 + {
  68 + Method: http.MethodPost,
  69 + Path: "/article_comment/search/me",
  70 + Handler: comment.SystemArticleCommentSearchMeHandler(serverCtx),
  71 + },
  72 + }...,
  73 + ),
  74 + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
  75 + rest.WithPrefix("/v1/system"),
  76 + )
  77 +
  78 + server.AddRoutes(
39 []rest.Route{ 79 []rest.Route{
40 { 80 {
41 Method: http.MethodPost, 81 Method: http.MethodPost,
@@ -80,7 +120,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -80,7 +120,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
80 Handler: tags.SearchTagHandler(serverCtx), 120 Handler: tags.SearchTagHandler(serverCtx),
81 }, 121 },
82 }, 122 },
83 - rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), 123 + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
84 rest.WithPrefix("/v1/system"), 124 rest.WithPrefix("/v1/system"),
85 ) 125 )
86 126
@@ -158,58 +198,61 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -158,58 +198,61 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
158 ) 198 )
159 199
160 server.AddRoutes( 200 server.AddRoutes(
161 - []rest.Route{  
162 - {  
163 - Method: http.MethodPost,  
164 - Path: "/system/user/info",  
165 - Handler: user.SystemUserInfoHandler(serverCtx),  
166 - },  
167 - {  
168 - Method: http.MethodPost,  
169 - Path: "/system/user/statistics",  
170 - Handler: user.SystemUserStatisticsHandler(serverCtx),  
171 - },  
172 - {  
173 - Method: http.MethodGet,  
174 - Path: "/system/user/:id",  
175 - Handler: user.SystemUserGetHandler(serverCtx),  
176 - },  
177 - {  
178 - Method: http.MethodPut,  
179 - Path: "/system/user/:id",  
180 - Handler: user.SystemUserUpdateHandler(serverCtx),  
181 - },  
182 - {  
183 - Method: http.MethodPost,  
184 - Path: "/system/user/search",  
185 - Handler: user.SystemUserSearchHandler(serverCtx),  
186 - },  
187 - {  
188 - Method: http.MethodGet,  
189 - Path: "/system/account/:id",  
190 - Handler: user.SystemUserAccountGetHandler(serverCtx),  
191 - },  
192 - {  
193 - Method: http.MethodPost,  
194 - Path: "/system/account",  
195 - Handler: user.SystemUserAccountSaveHandler(serverCtx),  
196 - },  
197 - {  
198 - Method: http.MethodPost,  
199 - Path: "/system/account/enable",  
200 - Handler: user.SystemUserAccountEnableHandler(serverCtx),  
201 - },  
202 - {  
203 - Method: http.MethodPut,  
204 - Path: "/system/account/:id",  
205 - Handler: user.SystemUserAccountUpdateHandler(serverCtx),  
206 - },  
207 - {  
208 - Method: http.MethodPost,  
209 - Path: "/system/account/search",  
210 - Handler: user.SystemUserAccountSearchHandler(serverCtx),  
211 - },  
212 - }, 201 + rest.WithMiddlewares(
  202 + []rest.Middleware{serverCtx.LoginStatusCheck},
  203 + []rest.Route{
  204 + {
  205 + Method: http.MethodPost,
  206 + Path: "/system/user/info",
  207 + Handler: user.SystemUserInfoHandler(serverCtx),
  208 + },
  209 + {
  210 + Method: http.MethodPost,
  211 + Path: "/system/user/statistics",
  212 + Handler: user.SystemUserStatisticsHandler(serverCtx),
  213 + },
  214 + {
  215 + Method: http.MethodGet,
  216 + Path: "/system/user/:id",
  217 + Handler: user.SystemUserGetHandler(serverCtx),
  218 + },
  219 + {
  220 + Method: http.MethodPut,
  221 + Path: "/system/user/:id",
  222 + Handler: user.SystemUserUpdateHandler(serverCtx),
  223 + },
  224 + {
  225 + Method: http.MethodPost,
  226 + Path: "/system/user/search",
  227 + Handler: user.SystemUserSearchHandler(serverCtx),
  228 + },
  229 + {
  230 + Method: http.MethodGet,
  231 + Path: "/system/account/:id",
  232 + Handler: user.SystemUserAccountGetHandler(serverCtx),
  233 + },
  234 + {
  235 + Method: http.MethodPost,
  236 + Path: "/system/account",
  237 + Handler: user.SystemUserAccountSaveHandler(serverCtx),
  238 + },
  239 + {
  240 + Method: http.MethodPost,
  241 + Path: "/system/account/enable",
  242 + Handler: user.SystemUserAccountEnableHandler(serverCtx),
  243 + },
  244 + {
  245 + Method: http.MethodPut,
  246 + Path: "/system/account/:id",
  247 + Handler: user.SystemUserAccountUpdateHandler(serverCtx),
  248 + },
  249 + {
  250 + Method: http.MethodPost,
  251 + Path: "/system/account/search",
  252 + Handler: user.SystemUserAccountSearchHandler(serverCtx),
  253 + },
  254 + }...,
  255 + ),
213 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 256 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
214 rest.WithPrefix("/v1"), 257 rest.WithPrefix("/v1"),
215 ) 258 )
@@ -316,6 +359,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -316,6 +359,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
316 Path: "/article_backup/search", 359 Path: "/article_backup/search",
317 Handler: article.MiniArticleBackupSearchHandler(serverCtx), 360 Handler: article.MiniArticleBackupSearchHandler(serverCtx),
318 }, 361 },
  362 + {
  363 + Method: http.MethodPost,
  364 + Path: "/article/set_tag",
  365 + Handler: article.MiniArticleSetTagHandler(serverCtx),
  366 + },
  367 + {
  368 + Method: http.MethodGet,
  369 + Path: "/article_tag/list/all",
  370 + Handler: article.MiniAllArticleTagHandler(serverCtx),
  371 + },
319 }, 372 },
320 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), 373 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
321 rest.WithPrefix("/v1/mini"), 374 rest.WithPrefix("/v1/mini"),
@@ -343,66 +396,82 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -343,66 +396,82 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
343 Path: "/article/history", 396 Path: "/article/history",
344 Handler: article.SystemHistoryArticleHandler(serverCtx), 397 Handler: article.SystemHistoryArticleHandler(serverCtx),
345 }, 398 },
  399 + {
  400 + Method: http.MethodPost,
  401 + Path: "/article/search/me",
  402 + Handler: article.SystemArticleSearchMeHandler(serverCtx),
  403 + },
346 }, 404 },
347 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 405 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
348 rest.WithPrefix("/v1/system"), 406 rest.WithPrefix("/v1/system"),
349 ) 407 )
350 408
351 server.AddRoutes( 409 server.AddRoutes(
352 - []rest.Route{  
353 - {  
354 - Method: http.MethodGet,  
355 - Path: "/system/role/:id",  
356 - Handler: role.SystemGetRoleHandler(serverCtx),  
357 - },  
358 - {  
359 - Method: http.MethodPost,  
360 - Path: "/system/role",  
361 - Handler: role.SystemSaveRoleHandler(serverCtx),  
362 - },  
363 - {  
364 - Method: http.MethodDelete,  
365 - Path: "/system/role/:id",  
366 - Handler: role.SystemDeleteRoleHandler(serverCtx),  
367 - },  
368 - {  
369 - Method: http.MethodPut,  
370 - Path: "/system/role/:id",  
371 - Handler: role.SystemUpdateRoleHandler(serverCtx),  
372 - },  
373 - {  
374 - Method: http.MethodPost,  
375 - Path: "/system/role/search",  
376 - Handler: role.SystemSearchRoleHandler(serverCtx),  
377 - },  
378 - }, 410 + rest.WithMiddlewares(
  411 + []rest.Middleware{serverCtx.LoginStatusCheck},
  412 + []rest.Route{
  413 + {
  414 + Method: http.MethodGet,
  415 + Path: "/system/role/:id",
  416 + Handler: role.SystemGetRoleHandler(serverCtx),
  417 + },
  418 + {
  419 + Method: http.MethodPost,
  420 + Path: "/system/role",
  421 + Handler: role.SystemSaveRoleHandler(serverCtx),
  422 + },
  423 + {
  424 + Method: http.MethodDelete,
  425 + Path: "/system/role/:id",
  426 + Handler: role.SystemDeleteRoleHandler(serverCtx),
  427 + },
  428 + {
  429 + Method: http.MethodPut,
  430 + Path: "/system/role/:id",
  431 + Handler: role.SystemUpdateRoleHandler(serverCtx),
  432 + },
  433 + {
  434 + Method: http.MethodPost,
  435 + Path: "/system/role/search",
  436 + Handler: role.SystemSearchRoleHandler(serverCtx),
  437 + },
  438 + }...,
  439 + ),
379 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 440 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
380 rest.WithPrefix("/v1"), 441 rest.WithPrefix("/v1"),
381 ) 442 )
382 443
383 server.AddRoutes( 444 server.AddRoutes(
384 - []rest.Route{  
385 - {  
386 - Method: http.MethodPost,  
387 - Path: "/system/department/list",  
388 - Handler: department.SystemListHandler(serverCtx),  
389 - },  
390 - {  
391 - Method: http.MethodPost,  
392 - Path: "/system/department/add",  
393 - Handler: department.SystemAddHandler(serverCtx),  
394 - },  
395 - {  
396 - Method: http.MethodGet,  
397 - Path: "/system/department/:id",  
398 - Handler: department.SystemGetHandler(serverCtx),  
399 - },  
400 - {  
401 - Method: http.MethodPut,  
402 - Path: "/system/department/:id",  
403 - Handler: department.SystemUpdateHandler(serverCtx),  
404 - },  
405 - }, 445 + rest.WithMiddlewares(
  446 + []rest.Middleware{serverCtx.LoginStatusCheck},
  447 + []rest.Route{
  448 + {
  449 + Method: http.MethodPost,
  450 + Path: "/system/department/list",
  451 + Handler: department.SystemListHandler(serverCtx),
  452 + },
  453 + {
  454 + Method: http.MethodPost,
  455 + Path: "/system/department/add",
  456 + Handler: department.SystemAddHandler(serverCtx),
  457 + },
  458 + {
  459 + Method: http.MethodGet,
  460 + Path: "/system/department/:id",
  461 + Handler: department.SystemGetHandler(serverCtx),
  462 + },
  463 + {
  464 + Method: http.MethodPut,
  465 + Path: "/system/department/:id",
  466 + Handler: department.SystemUpdateHandler(serverCtx),
  467 + },
  468 + {
  469 + Method: http.MethodDelete,
  470 + Path: "/system/department/:id",
  471 + Handler: department.SystemDeleteHandler(serverCtx),
  472 + },
  473 + }...,
  474 + ),
406 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 475 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
407 rest.WithPrefix("/v1"), 476 rest.WithPrefix("/v1"),
408 ) 477 )
@@ -7,6 +7,8 @@ import ( @@ -7,6 +7,8 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 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
12 func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -18,11 +20,9 @@ func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -18,11 +20,9 @@ func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
18 } 20 }
19 21
20 l := tags.NewCreateTagLogic(r.Context(), svcCtx) 22 l := tags.NewCreateTagLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
21 resp, err := l.CreateTag(&req) 25 resp, err := l.CreateTag(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.OkJsonCtx(r.Context(), w, resp)  
26 - } 26 + result.HttpResult(r, w, resp, err)
27 } 27 }
28 } 28 }
@@ -7,6 +7,8 @@ import ( @@ -7,6 +7,8 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 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
12 func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -18,11 +20,9 @@ func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -18,11 +20,9 @@ func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
18 } 20 }
19 21
20 l := tags.NewDeleteTagLogic(r.Context(), svcCtx) 22 l := tags.NewDeleteTagLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
21 resp, err := l.DeleteTag(&req) 25 resp, err := l.DeleteTag(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.OkJsonCtx(r.Context(), w, resp)  
26 - } 26 + result.HttpResult(r, w, resp, err)
27 } 27 }
28 } 28 }
@@ -7,6 +7,8 @@ import ( @@ -7,6 +7,8 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 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
12 func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -18,11 +20,9 @@ func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -18,11 +20,9 @@ func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
18 } 20 }
19 21
20 l := tags.NewEditTagLogic(r.Context(), svcCtx) 22 l := tags.NewEditTagLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
21 resp, err := l.EditTag(&req) 25 resp, err := l.EditTag(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.OkJsonCtx(r.Context(), w, resp)  
26 - } 26 + result.HttpResult(r, w, resp, err)
27 } 27 }
28 } 28 }
@@ -7,6 +7,8 @@ import ( @@ -7,6 +7,8 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 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
12 func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -16,13 +18,10 @@ func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -16,13 +18,10 @@ func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
16 httpx.ErrorCtx(r.Context(), w, err) 18 httpx.ErrorCtx(r.Context(), w, err)
17 return 19 return
18 } 20 }
19 - 21 + token := contextdata.GetUserTokenFromCtx(r.Context())
  22 + req.CompanyId = token.CompanyId
20 l := tags.NewGetTagLogic(r.Context(), svcCtx) 23 l := tags.NewGetTagLogic(r.Context(), svcCtx)
21 resp, err := l.GetTag(&req) 24 resp, err := l.GetTag(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.OkJsonCtx(r.Context(), w, resp)  
26 - } 25 + result.HttpResult(r, w, resp, err)
27 } 26 }
28 } 27 }
@@ -7,6 +7,8 @@ import ( @@ -7,6 +7,8 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 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
12 func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -18,11 +20,9 @@ func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -18,11 +20,9 @@ func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
18 } 20 }
19 21
20 l := tags.NewSearchTagLogic(r.Context(), svcCtx) 22 l := tags.NewSearchTagLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
21 resp, err := l.SearchTag(&req) 25 resp, err := l.SearchTag(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.OkJsonCtx(r.Context(), w, resp)  
26 - } 26 + result.HttpResult(r, w, resp, err)
27 } 27 }
28 } 28 }
  1 +package article
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  10 +
  11 + "github.com/zeromicro/go-zero/core/logx"
  12 +)
  13 +
  14 +type MiniAllArticleTagLogic struct {
  15 + logx.Logger
  16 + ctx context.Context
  17 + svcCtx *svc.ServiceContext
  18 +}
  19 +
  20 +func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniAllArticleTagLogic {
  21 + return &MiniAllArticleTagLogic{
  22 + Logger: logx.WithContext(ctx),
  23 + ctx: ctx,
  24 + svcCtx: svcCtx,
  25 + }
  26 +}
  27 +
  28 +func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) {
  29 + var conn = l.svcCtx.DefaultDBConn()
  30 + queryOption := domain.NewQueryOptions().WithFindOnly()
  31 + _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption)
  32 + if err != nil {
  33 + return nil, xerr.NewErrMsgErr("获取标签列表失败", err)
  34 + }
  35 + // 合并输出数据
  36 + var group []string
  37 + tagMap := map[string][]types.ArticleTagItem{}
  38 + for _, val := range tagList {
  39 + if m, ok := tagMap[val.Category]; ok {
  40 + m = append(m, types.ArticleTagItem{
  41 + Id: val.Id,
  42 + Group: val.Category,
  43 + Name: val.Name,
  44 + Image: val.Image.Url,
  45 + })
  46 + tagMap[val.Category] = m
  47 + } else {
  48 + group = append(group, val.Category)
  49 + tagMap[val.Category] = []types.ArticleTagItem{
  50 + {
  51 + Id: val.Id,
  52 + Group: val.Category,
  53 + Name: val.Name,
  54 + Image: val.Image.Url,
  55 + },
  56 + }
  57 + }
  58 + }
  59 + resp = &types.MiniAllArticleTagResponse{
  60 + TagGroup: make([]types.ArticleTagGroup, 0),
  61 + }
  62 + for i := range group {
  63 + resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{
  64 + Group: group[i],
  65 + Tags: tagMap[group[i]],
  66 + })
  67 + }
  68 + return resp, nil
  69 +}
@@ -26,6 +26,7 @@ func NewMiniArticleMarkUserReadLogic(ctx context.Context, svcCtx *svc.ServiceCon @@ -26,6 +26,7 @@ func NewMiniArticleMarkUserReadLogic(ctx context.Context, svcCtx *svc.ServiceCon
26 } 26 }
27 } 27 }
28 28
  29 +// 记录人员浏览的文章
29 func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniArticleMarkUserReadRequest) (resp *types.MiniArticleMarkUserReadResponse, err error) { 30 func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniArticleMarkUserReadRequest) (resp *types.MiniArticleMarkUserReadResponse, err error) {
30 var conn = l.svcCtx.DefaultDBConn() 31 var conn = l.svcCtx.DefaultDBConn()
31 32
@@ -84,7 +85,7 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr @@ -84,7 +85,7 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr
84 return err 85 return err
85 } 86 }
86 //增加浏览计数 87 //增加浏览计数
87 - err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo) 88 + err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo.Id)
88 return err 89 return err
89 }, true) 90 }, true)
90 if err != nil { 91 if err != nil {
@@ -42,19 +42,24 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea @@ -42,19 +42,24 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea
42 List: make([]types.ArticleSearchMe, len(articleList)), 42 List: make([]types.ArticleSearchMe, len(articleList)),
43 } 43 }
44 for i := range articleList { 44 for i := range articleList {
45 - images := []string{}  
46 - for _, val2 := range articleList[i].Images {  
47 - images = append(images, val2.Url)  
48 - }  
49 - resp.List[i] = types.ArticleSearchMe{  
50 - Id: articleList[i].Id,  
51 - Title: articleList[i].Title,  
52 - Images: images,  
53 - CreatedAt: articleList[i].CreatedAt,  
54 - CountLove: articleList[i].CountLove,  
55 - CountComment: articleList[i].CountComment,  
56 - Show: int(articleList[i].Show),  
57 - } 45 + resp.List[i] = NewArticle(articleList[i])
58 } 46 }
59 return 47 return
60 } 48 }
  49 +
  50 +func NewArticle(article *domain.Article) types.ArticleSearchMe {
  51 + images := []string{}
  52 + for _, val2 := range article.Images {
  53 + images = append(images, val2.Url)
  54 + }
  55 + articleSearchMe := types.ArticleSearchMe{
  56 + Id: article.Id,
  57 + Title: article.Title,
  58 + Images: images,
  59 + CreatedAt: article.CreatedAt,
  60 + CountLove: article.CountLove,
  61 + CountComment: article.CountComment,
  62 + Show: int(article.Show),
  63 + }
  64 + return articleSearchMe
  65 +}
  1 +package article
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 +
  9 + "github.com/zeromicro/go-zero/core/logx"
  10 +)
  11 +
  12 +type MiniArticleSetTagLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniArticleSetTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleSetTagLogic {
  19 + return &MiniArticleSetTagLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagRequest) (resp *types.MiniArticleSetTagResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
@@ -2,6 +2,7 @@ package article @@ -2,6 +2,7 @@ package article
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "text/template"
5 6
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/svc"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -29,6 +30,10 @@ func NewMiniCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceCont @@ -29,6 +30,10 @@ func NewMiniCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceCont
29 func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArticleDraftCreateRequest) (resp *types.MiniArticleDraftCreateResponse, err error) { 30 func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArticleDraftCreateRequest) (resp *types.MiniArticleDraftCreateResponse, err error) {
30 var conn = l.svcCtx.DefaultDBConn() 31 var conn = l.svcCtx.DefaultDBConn()
31 32
  33 + for i := range req.Section {
  34 + req.Section[i] = template.HTMLEscapeString(req.Section[i])
  35 + }
  36 +
32 newDraft := domain.ArticleDraft{ 37 newDraft := domain.ArticleDraft{
33 Id: 0, 38 Id: 0,
34 CompanyId: req.CompanyId, 39 CompanyId: req.CompanyId,
@@ -3,6 +3,7 @@ package article @@ -3,6 +3,7 @@ package article
3 import ( 3 import (
4 "context" 4 "context"
5 "strings" 5 "strings"
  6 + "text/template"
6 7
7 "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"
8 "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"
@@ -28,6 +29,7 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) @@ -28,6 +29,7 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext)
28 } 29 }
29 } 30 }
30 31
  32 +// 创建新文章
31 func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) { 33 func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) {
32 var conn = l.svcCtx.DefaultDBConn() 34 var conn = l.svcCtx.DefaultDBConn()
33 // 检查发布人 35 // 检查发布人
@@ -123,6 +125,8 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR @@ -123,6 +125,8 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
123 if len(newStr) == 0 { 125 if len(newStr) == 0 {
124 continue 126 continue
125 } 127 }
  128 + newStr = template.HTMLEscapeString(newStr)
  129 +
126 newSection := domain.ArticleSection{ 130 newSection := domain.ArticleSection{
127 Id: 0, 131 Id: 0,
128 CompanyId: author.CompanyId, 132 CompanyId: author.CompanyId,
@@ -26,6 +26,7 @@ func NewMiniGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mi @@ -26,6 +26,7 @@ func NewMiniGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mi
26 } 26 }
27 } 27 }
28 28
  29 +// 小程序端展示文章内容
29 func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (resp *types.MiniArticleGetResponse, err error) { 30 func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (resp *types.MiniArticleGetResponse, err error) {
30 // 获取文章内容 31 // 获取文章内容
31 var conn = l.svcCtx.DefaultDBConn() 32 var conn = l.svcCtx.DefaultDBConn()
@@ -88,10 +89,9 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( @@ -88,10 +89,9 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
88 Title: articleInfo.Title, 89 Title: articleInfo.Title,
89 AuthorId: articleInfo.AuthorId, 90 AuthorId: articleInfo.AuthorId,
90 Author: types.ArticleAuthor{ 91 Author: types.ArticleAuthor{
91 - Id: articleInfo.Author.Id,  
92 - Name: articleInfo.Author.Name,  
93 - Avatar: articleInfo.Author.Avatar,  
94 - // Group: articleInfo.Author.Group, 92 + Id: articleInfo.Author.Id,
  93 + Name: articleInfo.Author.Name,
  94 + Avatar: articleInfo.Author.Avatar,
95 Position: articleInfo.Author.Position, 95 Position: articleInfo.Author.Position,
96 Company: articleInfo.Author.Company, 96 Company: articleInfo.Author.Company,
97 }, 97 },
@@ -2,6 +2,7 @@ package article @@ -2,6 +2,7 @@ package article
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
5 6
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/svc"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -93,10 +94,18 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeArticle(req *types.MiniSetUserLi @@ -93,10 +94,18 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeArticle(req *types.MiniSetUserLi
93 return err 94 return err
94 } 95 }
95 // 减少文章的点赞数量 96 // 减少文章的点赞数量
96 - err = l.svcCtx.ArticleRepository.IncreaseCountLove(ctx, c, -1, articleInfo) 97 + err = l.svcCtx.ArticleRepository.IncreaseCountLove(ctx, c, -1, articleInfo.Id)
97 if err != nil { 98 if err != nil {
98 return err 99 return err
99 } 100 }
  101 +
  102 + // 删除点赞文章消息
  103 + var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
  104 + err = messageLogic.UnLikeArticle(c, articleInfo.Id)
  105 + if err != nil {
  106 + return err
  107 + }
  108 +
100 return nil 109 return nil
101 }, true) 110 }, true)
102 if err != nil { 111 if err != nil {
@@ -166,10 +175,18 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeComment(req *types.MiniSetUserLi @@ -166,10 +175,18 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeComment(req *types.MiniSetUserLi
166 return err 175 return err
167 } 176 }
168 // 减少评论的点赞数量 177 // 减少评论的点赞数量
169 - err = l.svcCtx.ArticleCommentRepository.IncreaseCountUserLove(ctx, c, -1, commentInfo) 178 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountUserLove(ctx, c, -1, commentInfo.Id)
170 if err != nil { 179 if err != nil {
171 return err 180 return err
172 } 181 }
  182 +
  183 + // 删除点赞评论消息
  184 + var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
  185 + err = messageLogic.UnLikeComment(c, commentInfo.ArticleId, commentInfo.Id)
  186 + if err != nil {
  187 + return err
  188 + }
  189 +
173 return nil 190 return nil
174 }, true) 191 }, true)
175 if err != nil { 192 if err != nil {
@@ -239,10 +256,18 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ @@ -239,10 +256,18 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
239 return err 256 return err
240 } 257 }
241 // 增加文章的点赞数量 258 // 增加文章的点赞数量
242 - err = l.svcCtx.ArticleRepository.IncreaseCountLove(ctx, c, 1, articleInfo) 259 + err = l.svcCtx.ArticleRepository.IncreaseCountLove(ctx, c, 1, articleInfo.Id)
243 if err != nil { 260 if err != nil {
244 return err 261 return err
245 } 262 }
  263 +
  264 + // 创建点赞消息
  265 + var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
  266 + err = messageLogic.LikeArticle(c, articleInfo.Id, articleInfo.AuthorId)
  267 + if err != nil {
  268 + return err
  269 + }
  270 +
246 return nil 271 return nil
247 }, true) 272 }, true)
248 if err != nil { 273 if err != nil {
@@ -320,10 +345,18 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ @@ -320,10 +345,18 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ
320 return err 345 return err
321 } 346 }
322 // 增加评论的点赞数量 347 // 增加评论的点赞数量
323 - err = l.svcCtx.ArticleCommentRepository.IncreaseCountUserLove(ctx, c, 1, commentInfo) 348 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountUserLove(ctx, c, 1, commentInfo.Id)
324 if err != nil { 349 if err != nil {
325 return err 350 return err
326 } 351 }
  352 +
  353 + // 创建点赞消息
  354 + var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
  355 + err = messageLogic.LikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.FromUserId)
  356 + if err != nil {
  357 + return err
  358 + }
  359 +
327 return nil 360 return nil
328 }, true) 361 }, true)
329 if err != nil { 362 if err != nil {
@@ -2,6 +2,7 @@ package article @@ -2,6 +2,7 @@ package article
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "text/template"
5 6
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/svc"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -37,6 +38,10 @@ func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArti @@ -37,6 +38,10 @@ func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArti
37 return nil, xerr.NewErrMsg("更新草稿失败") 38 return nil, xerr.NewErrMsg("更新草稿失败")
38 } 39 }
39 } 40 }
  41 + for i := range req.Section {
  42 + req.Section[i] = template.HTMLEscapeString(req.Section[i])
  43 + }
  44 +
40 draftInfo.Content = req.Section 45 draftInfo.Content = req.Section
41 draftInfo.Title = req.Title 46 draftInfo.Title = req.Title
42 draftInfo.Location = domain.Location{ 47 draftInfo.Location = domain.Location{
@@ -71,6 +71,7 @@ func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeAr @@ -71,6 +71,7 @@ func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeAr
71 if u, ok := userMap[val.UserId]; ok { 71 if u, ok := userMap[val.UserId]; ok {
72 item.Name = u.Name 72 item.Name = u.Name
73 item.Avatar = u.Avatar 73 item.Avatar = u.Avatar
  74 + item.Position = u.Position
74 } 75 }
75 resp.List[i] = item 76 resp.List[i] = item
76 } 77 }
  1 +package article
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  7 + "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 SystemArticleSearchMeLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewSystemArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleSearchMeLogic {
  22 + return &SystemArticleSearchMeLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +func (l *SystemArticleSearchMeLogic) SystemArticleSearchMe(req *types.SystemArticleSearchMeRequest) (resp *types.SystemArticleSearchMeResponse, err error) {
  30 + var (
  31 + conn = l.svcCtx.DefaultDBConn()
  32 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  33 + )
  34 + queryOptions := domain.NewQueryOptions().
  35 + WithOffsetLimit(req.Page, req.Size).
  36 + MustWithKV("authorId", req.AuthorId).
  37 + WithKV("beginCreatedAt", req.BeginTime).
  38 + WithKV("endCreatedAt", req.EndTime)
  39 +
  40 + cnt, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions)
  41 + if err != nil {
  42 + return &types.SystemArticleSearchMeResponse{}, xerr.NewErrMsgErr("获取文章列表失败", err)
  43 + }
  44 +
  45 + resp = &types.SystemArticleSearchMeResponse{
  46 + Total: int(cnt),
  47 + List: make([]types.ArticleSearchMe, len(articleList)),
  48 + }
  49 + for i := range articleList {
  50 + resp.List[i] = NewArticle(articleList[i])
  51 + }
  52 + return
  53 +}
  1 +package comment
  2 +
  3 +import (
  4 + "context"
  5 + "sort"
  6 + "strings"
  7 +
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  12 +
  13 + "github.com/zeromicro/go-zero/core/logx"
  14 +)
  15 +
  16 +type MiniArticleCommentAtWhoLogic struct {
  17 + logx.Logger
  18 + ctx context.Context
  19 + svcCtx *svc.ServiceContext
  20 +}
  21 +
  22 +func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleCommentAtWhoLogic {
  23 + return &MiniArticleCommentAtWhoLogic{
  24 + Logger: logx.WithContext(ctx),
  25 + ctx: ctx,
  26 + svcCtx: svcCtx,
  27 + }
  28 +}
  29 +
  30 +// MiniArticleCommentAtWho 填写评估时@谁 的可选择者列表
  31 +func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) {
  32 + var conn = l.svcCtx.DefaultDBConn()
  33 + articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
  34 + if err != nil {
  35 + return nil, xerr.NewErrMsgErr("获取评论人信息失败", err)
  36 + }
  37 + if articleInfo.CompanyId != req.CompanyId {
  38 + resp = &types.MiniArticleCommentAtWhoResponse{}
  39 + return resp, nil
  40 + }
  41 +
  42 + var userList []*domain.User
  43 + if len(articleInfo.WhoRead) == 0 {
  44 + //获取所有人
  45 + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId)
  46 + _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
  47 + if err != nil {
  48 + resp = &types.MiniArticleCommentAtWhoResponse{}
  49 + return resp, nil
  50 + }
  51 + } else {
  52 + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.WhoRead)
  53 + _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
  54 + if err != nil {
  55 + resp = &types.MiniArticleCommentAtWhoResponse{}
  56 + return resp, nil
  57 + }
  58 + }
  59 +
  60 + uList := make([]types.CommentAtWho, len(userList))
  61 +
  62 + for i := range userList {
  63 + uList[i] = types.CommentAtWho{
  64 + Id: userList[i].Id,
  65 + Name: userList[i].Name,
  66 + FirstLetter: "",
  67 + }
  68 + for _, val := range userList[i].PinYinName {
  69 + uList[i].FirstLetter = strings.ToUpper(string(val))
  70 + break
  71 + }
  72 + }
  73 + sort.Slice(uList, func(i, j int) bool {
  74 + return uList[i].FirstLetter < uList[j].FirstLetter
  75 + })
  76 + resp = &types.MiniArticleCommentAtWhoResponse{
  77 + List: uList,
  78 + }
  79 + return resp, nil
  80 +}
@@ -3,6 +3,8 @@ package comment @@ -3,6 +3,8 @@ package comment
3 import ( 3 import (
4 "context" 4 "context"
5 5
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
  7 +
6 "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"
7 "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"
8 "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/db/transaction"
@@ -11,6 +13,7 @@ import ( @@ -11,6 +13,7 @@ import (
11 13
12 "text/template" 14 "text/template"
13 15
  16 + "github.com/samber/lo"
14 "github.com/zeromicro/go-zero/core/logx" 17 "github.com/zeromicro/go-zero/core/logx"
15 ) 18 )
16 19
@@ -49,13 +52,12 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini @@ -49,13 +52,12 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
49 return nil, xerr.NewErrMsg("没有评论权限") 52 return nil, xerr.NewErrMsg("没有评论权限")
50 } 53 }
51 //查看评论权限, 54 //查看评论权限,
52 - //临时注释  
53 - // if len(articleInfo.WhoReview) > 0 {  
54 - // ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)  
55 - // if ok < 0 {  
56 - // return nil, xerr.NewErrMsg("没有评论权限")  
57 - // }  
58 - // } 55 + if len(articleInfo.WhoReview) > 0 {
  56 + ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
  57 + if ok < 0 {
  58 + return nil, xerr.NewErrMsg("没有评论权限")
  59 + }
  60 + }
59 // 对段落进行评论 61 // 对段落进行评论
60 var selctionInfo *domain.ArticleSection 62 var selctionInfo *domain.ArticleSection
61 if req.SectionId > 0 { 63 if req.SectionId > 0 {
@@ -83,15 +85,22 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini @@ -83,15 +85,22 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
83 } 85 }
84 } 86 }
85 var atWhoList []*domain.User 87 var atWhoList []*domain.User
  88 + var atWhoIds = make([]int64, 0)
86 if len(req.AtWho) > 0 { 89 if len(req.AtWho) > 0 {
87 - queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", req.AtWho) 90 + for _, val := range req.AtWho {
  91 + atWhoIds = append(atWhoIds, val.Id)
  92 + }
  93 + atWhoIds = lo.Uniq(atWhoIds)
  94 + queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", atWhoIds)
88 _, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) 95 _, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
89 if err != nil { 96 if err != nil {
90 return nil, xerr.NewErrMsgErr("检查@的人员失败", err) 97 return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
91 } 98 }
  99 + if len(atWhoIds) != len(atWhoList) {
  100 + return nil, xerr.NewErrMsg("检查@的人员失败")
  101 + }
92 } 102 }
93 // 处理文本内容 103 // 处理文本内容
94 - // content:=  
95 content := template.HTMLEscapeString(req.Content) 104 content := template.HTMLEscapeString(req.Content)
96 105
97 newComment := domain.ArticleComment{ 106 newComment := domain.ArticleComment{
@@ -149,16 +158,52 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini @@ -149,16 +158,52 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
149 } 158 }
150 //保存数据 159 //保存数据
151 err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { 160 err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
152 - // 增加平评论计数  
153 - err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, articleInfo) 161 + //保存评论
  162 + _, err = l.svcCtx.ArticleCommentRepository.Insert(ctx, c, &newComment)
154 if err != nil { 163 if err != nil {
155 return err 164 return err
156 } 165 }
157 - //保存评论  
158 - _, err = l.svcCtx.ArticleCommentRepository.Insert(ctx, c, &newComment) 166 + // 增加文章评论计数
  167 + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, articleInfo.Id)
  168 + if err != nil {
  169 + return err
  170 + }
  171 + //增加段落评论计数
  172 + if newComment.SectionId > 0 {
  173 + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, newComment.SectionId)
  174 + if err != nil {
  175 + return err
  176 + }
  177 + }
  178 + //增加评论回复计数
  179 + if pComment != nil {
  180 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, pComment.Id)
  181 + if err != nil {
  182 + return err
  183 + }
  184 + }
  185 + // 增加最顶层的评论回复计数
  186 + if newComment.TopId != 0 && newComment.Pid != newComment.TopId {
  187 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, newComment.TopId)
  188 + if err != nil {
  189 + return err
  190 + }
  191 + }
  192 +
  193 + // 创建回复消息
  194 + var atAllIds = make([]int64, 0)
  195 + atAllIds = append(atAllIds, newComment.ToUserId)
  196 + atAllIds = append(atAllIds, atWhoIds...)
  197 + var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
  198 + if pComment != nil {
  199 + err = messageLogic.CommentReply(c, pComment.ArticleId, pComment.SectionId, pComment.Id, req.Content, atAllIds) // 对评论回复
  200 + } else {
  201 + err = messageLogic.CommentArticle(c, req.ArtitcleId, req.SectionId, req.Content, atAllIds) // 对文章回复
  202 + }
159 if err != nil { 203 if err != nil {
160 return err 204 return err
161 } 205 }
  206 +
162 return nil 207 return nil
163 }, true) 208 }, true)
164 209
@@ -171,7 +216,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini @@ -171,7 +216,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
171 Pid: newComment.Pid, 216 Pid: newComment.Pid,
172 TopId: newComment.TopId, 217 TopId: newComment.TopId,
173 ArtitcleId: newComment.ArticleId, 218 ArtitcleId: newComment.ArticleId,
174 - SectionId: newComment.ArticleId, 219 + SectionId: newComment.SectionId,
175 FromUserId: newComment.FromUserId, 220 FromUserId: newComment.FromUserId,
176 FromUser: types.CommentAuthor{ 221 FromUser: types.CommentAuthor{
177 Id: newComment.FromUser.Id, 222 Id: newComment.FromUser.Id,
@@ -192,16 +237,14 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini @@ -192,16 +237,14 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
192 CountReply: 0, 237 CountReply: 0,
193 CountUserLove: 0, 238 CountUserLove: 0,
194 CountAdminLove: 0, 239 CountAdminLove: 0,
195 - AtWho: []types.CommentAuthor{}, 240 + AtWho: []types.CommentAtWho{},
  241 + CreatedAt: newComment.CreatedAt,
196 } 242 }
197 243
198 for _, val := range newComment.AtWho { 244 for _, val := range newComment.AtWho {
199 - resp.AtWho = append(resp.AtWho, types.CommentAuthor{  
200 - Id: val.Id,  
201 - Name: val.Name,  
202 - Avatar: val.Avatar,  
203 - Position: val.Position,  
204 - Company: val.Company, 245 + resp.AtWho = append(resp.AtWho, types.CommentAtWho{
  246 + Id: val.Id,
  247 + Name: val.Name,
205 }) 248 })
206 } 249 }
207 250
  1 +package comment
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  11 +
  12 + "github.com/zeromicro/go-zero/core/logx"
  13 +)
  14 +
  15 +type MiniDeleteArticleCommentLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniDeleteArticleCommentLogic {
  22 + return &MiniDeleteArticleCommentLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +// 小程序端人人员删除评论
  30 +func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) {
  31 + var conn = l.svcCtx.DefaultDBConn()
  32 + commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
  33 + if err != nil {
  34 + return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
  35 + }
  36 +
  37 + if commetInfo.FromUserId != req.UserId {
  38 + return nil, xerr.NewErrMsg("没有操作权限")
  39 + }
  40 +
  41 + commetInfo.Show = domain.CommentShowDisable
  42 +
  43 + // 变更回复数量
  44 + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
  45 + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
  46 + if err != nil {
  47 + return err
  48 + }
  49 + // 减少上级评论的回复数量
  50 + if commetInfo.Pid != 0 {
  51 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid)
  52 + if err != nil {
  53 + return err
  54 + }
  55 + }
  56 + // 减少最顶层的评论回复计数
  57 + if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
  58 + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId)
  59 + if err != nil {
  60 + return err
  61 + }
  62 + }
  63 + //减少加段落评论计数
  64 + if commetInfo.SectionId > 0 {
  65 + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId)
  66 + if err != nil {
  67 + return err
  68 + }
  69 + }
  70 + // 减少文章的评论数
  71 + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId)
  72 + if err != nil {
  73 + return err
  74 + }
  75 + return nil
  76 + }, true)
  77 +
  78 + if err != nil {
  79 + return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
  80 + }
  81 + resp = &types.MiniDeleteArticleCommentResponse{Id: commetInfo.Id}
  82 + return resp, nil
  83 +}
  1 +package comment
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  10 +
  11 + "github.com/zeromicro/go-zero/core/logx"
  12 +)
  13 +
  14 +type MiniGetArticleCommentLogic struct {
  15 + logx.Logger
  16 + ctx context.Context
  17 + svcCtx *svc.ServiceContext
  18 +}
  19 +
  20 +func NewMiniGetArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniGetArticleCommentLogic {
  21 + return &MiniGetArticleCommentLogic{
  22 + Logger: logx.WithContext(ctx),
  23 + ctx: ctx,
  24 + svcCtx: svcCtx,
  25 + }
  26 +}
  27 +
  28 +// 获取单条评论详情
  29 +func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArticleCommentRequest) (resp *types.MiniGetArticleCommentResponse, err error) {
  30 + var conn = l.svcCtx.DefaultDBConn()
  31 + //获取主评论
  32 + commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
  33 + if err != nil {
  34 + return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
  35 + }
  36 + if commentInfo.CompanyId != req.CompanyId {
  37 + return nil, xerr.NewErrMsg("没有查看权限")
  38 + }
  39 +
  40 + if commentInfo.Show == domain.CommentShowDisable {
  41 + return nil, xerr.NewErrMsg("没有查看权限")
  42 + }
  43 + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("topId", commentInfo.Id).MustWithKV("show", domain.CommentShowEnable)
  44 + //获取回复的评论
  45 + _, replyCommenList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
  46 +
  47 + if err != nil {
  48 + return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
  49 + }
  50 + queryOption = domain.NewQueryOptions().WithFindOnly().
  51 + MustWithKV("articleId", commentInfo.ArticleId).
  52 + MustWithKV("userId", req.UserId)
  53 + // 获取我点赞的评论
  54 + _, userFlagList, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption)
  55 + if err != nil {
  56 + return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
  57 + }
  58 + // 我点赞的
  59 + flagMap := map[int64]struct{}{}
  60 + for _, val := range userFlagList {
  61 + flagMap[val.CommentId] = struct{}{}
  62 + }
  63 +
  64 + //混合数据
  65 + commentResp := types.ArticleCommentItem{
  66 + Id: commentInfo.Id,
  67 + Pid: commentInfo.Pid,
  68 + TopId: commentInfo.TopId,
  69 + ArtitcleId: commentInfo.ArticleId,
  70 + SectionId: commentInfo.ArticleId,
  71 + FromUserId: commentInfo.FromUserId,
  72 + FromUser: types.CommentAuthor{
  73 + Id: commentInfo.FromUser.Id,
  74 + Name: commentInfo.FromUser.Name,
  75 + Avatar: commentInfo.FromUser.Avatar,
  76 + Position: commentInfo.FromUser.Position,
  77 + Company: commentInfo.FromUser.Company,
  78 + },
  79 + ToUserId: commentInfo.ToUserId,
  80 + ToUser: types.CommentAuthor{
  81 + Id: commentInfo.ToUser.Id,
  82 + Name: commentInfo.ToUser.Name,
  83 + Avatar: commentInfo.ToUser.Avatar,
  84 + Position: commentInfo.ToUser.Position,
  85 + Company: commentInfo.ToUser.Company,
  86 + },
  87 + SectionContent: commentInfo.SectionContent,
  88 + CountReply: commentInfo.CountReply,
  89 + CountUserLove: commentInfo.CountUserLove,
  90 + CountAdminLove: commentInfo.CountAdminLove,
  91 + AtWho: []types.CommentAtWho{},
  92 + CreatedAt: commentInfo.CreatedAt,
  93 + MeLoveFlag: 0,
  94 + }
  95 + if _, ok := flagMap[commentInfo.Id]; ok {
  96 + commentResp.MeLoveFlag = 1
  97 + }
  98 + for _, val := range commentInfo.AtWho {
  99 + commentResp.AtWho = append(commentResp.AtWho, types.CommentAtWho{
  100 + Id: val.Id,
  101 + Name: val.Name,
  102 + })
  103 + }
  104 + // 回复的评论
  105 + allReply := []types.ArticleCommentItem{}
  106 + for _, val := range replyCommenList {
  107 + reply := types.ArticleCommentItem{
  108 + Id: val.Id,
  109 + Pid: val.Pid,
  110 + TopId: val.TopId,
  111 + ArtitcleId: val.ArticleId,
  112 + SectionId: val.SectionId,
  113 + FromUserId: val.FromUserId,
  114 + FromUser: types.CommentAuthor{
  115 + Id: val.FromUser.Id,
  116 + Name: val.FromUser.Name,
  117 + Avatar: val.FromUser.Avatar,
  118 + Position: val.FromUser.Position,
  119 + Company: val.FromUser.Company,
  120 + },
  121 + ToUserId: val.ToUserId,
  122 + ToUser: types.CommentAuthor{
  123 + Id: val.ToUser.Id,
  124 + Name: val.ToUser.Name,
  125 + Avatar: val.ToUser.Avatar,
  126 + Position: val.ToUser.Position,
  127 + Company: val.ToUser.Company,
  128 + },
  129 + SectionContent: val.SectionContent,
  130 + CountReply: val.CountReply,
  131 + CountUserLove: val.CountUserLove,
  132 + CountAdminLove: val.CountAdminLove,
  133 + AtWho: []types.CommentAtWho{},
  134 + CreatedAt: val.CreatedAt,
  135 + MeLoveFlag: 0,
  136 + }
  137 + if _, ok := flagMap[val.Id]; ok {
  138 + reply.MeLoveFlag = 1
  139 + }
  140 + for _, val2 := range val.AtWho {
  141 + reply.AtWho = append(reply.AtWho, types.CommentAtWho{
  142 + Id: val2.Id,
  143 + Name: val2.Name,
  144 + })
  145 + }
  146 + allReply = append(allReply, reply)
  147 + }
  148 + resp = &types.MiniGetArticleCommentResponse{
  149 + ArticleCommentAndReply: types.ArticleCommentAndReply{
  150 + Comment: commentResp,
  151 + Reply: allReply,
  152 + TotalReply: int64(len(replyCommenList)),
  153 + },
  154 + }
  155 + return
  156 +}
  1 +package comment
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  10 +
  11 + "github.com/zeromicro/go-zero/core/logx"
  12 +)
  13 +
  14 +type MiniListArticleCommentLogic struct {
  15 + logx.Logger
  16 + ctx context.Context
  17 + svcCtx *svc.ServiceContext
  18 +}
  19 +
  20 +func NewMiniListArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniListArticleCommentLogic {
  21 + return &MiniListArticleCommentLogic{
  22 + Logger: logx.WithContext(ctx),
  23 + ctx: ctx,
  24 + svcCtx: svcCtx,
  25 + }
  26 +}
  27 +
  28 +func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniListArticleCommentRequest) (resp *types.MiniListArticleCommentResponse, err error) {
  29 + // 先获取最顶层的评论
  30 + var conn = l.svcCtx.DefaultDBConn()
  31 + if req.Page > 40 {
  32 + req.Page = 40
  33 + }
  34 +
  35 + queryOption := domain.NewQueryOptions().
  36 + WithOffsetLimit(req.Page, req.Size).
  37 + MustWithKV("topId", 0).
  38 + MustWithKV("articleId", req.ArticleId).
  39 + MustWithKV("sectionId", req.SectionId).
  40 + MustWithKV("show", domain.CommentShowEnable).
  41 + MustWithKV("companyId", req.CompanyId)
  42 +
  43 + cnt, commentList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
  44 + if err != nil {
  45 + return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
  46 + }
  47 + if cnt == 0 {
  48 + resp = &types.MiniListArticleCommentResponse{
  49 + Total: 0,
  50 + List: make([]types.ArticleCommentAndReply, 0),
  51 + }
  52 + return
  53 + }
  54 +
  55 + queryOption = domain.NewQueryOptions().WithFindOnly().
  56 + MustWithKV("articleId", req.ArticleId).
  57 + MustWithKV("userId", req.UserId)
  58 + // 获取我点赞的评论
  59 + _, userFlagList, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption)
  60 + if err != nil {
  61 + return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
  62 + }
  63 + // 我点赞的
  64 + flagMap := map[int64]struct{}{}
  65 + for _, val := range userFlagList {
  66 + flagMap[val.CommentId] = struct{}{}
  67 + }
  68 + resp = &types.MiniListArticleCommentResponse{
  69 + Total: cnt,
  70 + List: make([]types.ArticleCommentAndReply, len(commentList)),
  71 + }
  72 + // 获取回复的评论
  73 + for i, val := range commentList {
  74 + item := types.ArticleCommentAndReply{
  75 + Comment: types.ArticleCommentItem{
  76 + Id: val.Id,
  77 + Pid: val.Pid,
  78 + TopId: val.TopId,
  79 + ArtitcleId: val.ArticleId,
  80 + SectionId: val.SectionId,
  81 + FromUserId: val.FromUserId,
  82 + FromUser: types.CommentAuthor{
  83 + Id: val.FromUser.Id,
  84 + Name: val.FromUser.Name,
  85 + Avatar: val.FromUser.Avatar,
  86 + Position: val.FromUser.Position,
  87 + Company: val.FromUser.Company,
  88 + },
  89 + ToUserId: val.ToUserId,
  90 + ToUser: types.CommentAuthor{
  91 + Id: val.ToUser.Id,
  92 + Name: val.ToUser.Name,
  93 + Avatar: val.ToUser.Avatar,
  94 + Position: val.ToUser.Position,
  95 + Company: val.ToUser.Company,
  96 + },
  97 + SectionContent: val.SectionContent,
  98 + CountReply: val.CountReply,
  99 + CountUserLove: val.CountUserLove,
  100 + CountAdminLove: val.CountAdminLove,
  101 + AtWho: []types.CommentAtWho{},
  102 + CreatedAt: val.CreatedAt,
  103 + MeLoveFlag: 0,
  104 + },
  105 + Reply: []types.ArticleCommentItem{},
  106 + TotalReply: int64(val.CountReply),
  107 + }
  108 +
  109 + if _, ok := flagMap[val.Id]; ok {
  110 + item.Comment.MeLoveFlag = 1
  111 + }
  112 +
  113 + for _, val2 := range val.AtWho {
  114 + item.Comment.AtWho = append(item.Comment.AtWho, types.CommentAtWho{
  115 + Id: val2.Id,
  116 + Name: val2.Name,
  117 + })
  118 + }
  119 +
  120 + //获取回复的评论
  121 + cntReply, reply := l.listCommentReply(item.Comment.Id, flagMap)
  122 +
  123 + resp.List[i] = item
  124 + resp.List[i].Reply = reply
  125 + resp.List[i].TotalReply = cntReply
  126 + }
  127 + return resp, nil
  128 +}
  129 +
  130 +// listCommentReply
  131 +func (l *MiniListArticleCommentLogic) listCommentReply(commentId int64, loveFlagMap map[int64]struct{}) (cnt int64, replyList []types.ArticleCommentItem) {
  132 + var conn = l.svcCtx.DefaultDBConn()
  133 + queryOption := domain.NewQueryOptions().
  134 + WithOffsetLimit(1, 2).
  135 + MustWithKV("topId", commentId).
  136 + MustWithKV("show", domain.CommentShowEnable)
  137 +
  138 + cnt, commentList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
  139 + if err != nil {
  140 + return cnt, []types.ArticleCommentItem{}
  141 + }
  142 + if cnt == 0 {
  143 + replyList = []types.ArticleCommentItem{}
  144 + return cnt, replyList
  145 + }
  146 +
  147 + for _, val := range commentList {
  148 + item := types.ArticleCommentItem{
  149 + Id: val.Id,
  150 + Pid: val.Pid,
  151 + TopId: val.TopId,
  152 + ArtitcleId: val.ArticleId,
  153 + SectionId: val.SectionId,
  154 + FromUserId: val.FromUserId,
  155 + FromUser: types.CommentAuthor{
  156 + Id: val.FromUser.Id,
  157 + Name: val.FromUser.Name,
  158 + Avatar: val.FromUser.Avatar,
  159 + Position: val.FromUser.Position,
  160 + Company: val.FromUser.Company,
  161 + },
  162 + ToUserId: val.ToUserId,
  163 + ToUser: types.CommentAuthor{
  164 + Id: val.ToUser.Id,
  165 + Name: val.ToUser.Name,
  166 + Avatar: val.ToUser.Avatar,
  167 + Position: val.ToUser.Position,
  168 + Company: val.ToUser.Company,
  169 + },
  170 + SectionContent: val.SectionContent,
  171 + CountReply: val.CountReply,
  172 + CountUserLove: val.CountUserLove,
  173 + CountAdminLove: val.CountAdminLove,
  174 + AtWho: []types.CommentAtWho{},
  175 + CreatedAt: val.CreatedAt,
  176 + MeLoveFlag: 0,
  177 + }
  178 +
  179 + if _, ok := loveFlagMap[val.Id]; ok {
  180 + item.MeLoveFlag = 1
  181 + }
  182 + for _, val2 := range val.AtWho {
  183 + item.AtWho = append(item.AtWho, types.CommentAtWho{
  184 + Id: val2.Id,
  185 + Name: val2.Name,
  186 + })
  187 + }
  188 + replyList = append(replyList, item)
  189 + }
  190 + return cnt, replyList
  191 +}
  1 +package comment
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  10 +
  11 + "github.com/zeromicro/go-zero/core/logx"
  12 +)
  13 +
  14 +type MiniTop5ArticleCommentLogic struct {
  15 + logx.Logger
  16 + ctx context.Context
  17 + svcCtx *svc.ServiceContext
  18 +}
  19 +
  20 +func NewMiniTop5ArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniTop5ArticleCommentLogic {
  21 + return &MiniTop5ArticleCommentLogic{
  22 + Logger: logx.WithContext(ctx),
  23 + ctx: ctx,
  24 + svcCtx: svcCtx,
  25 + }
  26 +}
  27 +
  28 +// 获取前5的评论
  29 +func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5ArticleCommentRequest) (resp *types.MiniTop5ArticleCommentResponse, err error) {
  30 + var conn = l.svcCtx.DefaultDBConn()
  31 + commentList, err := l.svcCtx.ArticleCommentRepository.Top5Comment(l.ctx, conn, req.CompanyId, req.ArticleId)
  32 + if err != nil {
  33 + return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
  34 + }
  35 +
  36 + queryOption := domain.NewQueryOptions().WithFindOnly().
  37 + MustWithKV("articleId", req.ArticleId).
  38 + MustWithKV("userId", req.UserId)
  39 + // 获取我点赞的评论
  40 + _, userFlagList, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption)
  41 + if err != nil {
  42 + return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
  43 + }
  44 + // 我点赞的
  45 + flagMap := map[int64]struct{}{}
  46 + for _, val := range userFlagList {
  47 + flagMap[val.CommentId] = struct{}{}
  48 + }
  49 +
  50 + resp = &types.MiniTop5ArticleCommentResponse{
  51 + List: make([]types.ArticleCommentItem, len(commentList)),
  52 + }
  53 + for i, val := range commentList {
  54 + item := NewArticleCommentItem(val)
  55 +
  56 + if _, ok := flagMap[val.Id]; ok {
  57 + item.MeLoveFlag = 1
  58 + }
  59 + for _, val2 := range val.AtWho {
  60 + item.AtWho = append(item.AtWho, types.CommentAtWho{
  61 + Id: val2.Id,
  62 + Name: val2.Name,
  63 + })
  64 + }
  65 + resp.List[i] = item
  66 + }
  67 + return
  68 +}
  69 +
  70 +func NewArticleCommentItem(val *domain.ArticleComment) types.ArticleCommentItem {
  71 + item := types.ArticleCommentItem{
  72 + Id: val.Id,
  73 + Pid: val.Pid,
  74 + TopId: val.TopId,
  75 + ArtitcleId: val.ArticleId,
  76 + SectionId: val.SectionId,
  77 + FromUserId: val.FromUserId,
  78 + FromUser: types.CommentAuthor{
  79 + Id: val.FromUser.Id,
  80 + Name: val.FromUser.Name,
  81 + Avatar: val.FromUser.Avatar,
  82 + Position: val.FromUser.Position,
  83 + Company: val.FromUser.Company,
  84 + },
  85 + ToUserId: val.ToUserId,
  86 + ToUser: types.CommentAuthor{
  87 + Id: val.ToUser.Id,
  88 + Name: val.ToUser.Name,
  89 + Avatar: val.ToUser.Avatar,
  90 + Position: val.ToUser.Position,
  91 + Company: val.ToUser.Company,
  92 + },
  93 + SectionContent: val.SectionContent,
  94 + CountReply: val.CountReply,
  95 + CountUserLove: val.CountUserLove,
  96 + CountAdminLove: val.CountAdminLove,
  97 + AtWho: []types.CommentAtWho{},
  98 + CreatedAt: val.CreatedAt,
  99 + MeLoveFlag: 0,
  100 + Content: val.Content,
  101 + }
  102 + return item
  103 +}
  1 +package comment
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  7 + "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 SystemArticleCommentSearchMeLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewSystemArticleCommentSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleCommentSearchMeLogic {
  22 + return &SystemArticleCommentSearchMeLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +func (l *SystemArticleCommentSearchMeLogic) SystemArticleCommentSearchMe(req *types.SystemArticleCommentSearchMeRequest) (resp *types.SystemArticleCommentSearchMeResponse, err error) {
  30 + var (
  31 + conn = l.svcCtx.DefaultDBConn()
  32 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  33 + )
  34 + queryOptions := domain.IndexCompanyId(userToken.CompanyId)().
  35 + WithOffsetLimit(req.Page, req.Size).
  36 + MustWithKV("fromUserId", req.AuthorId).
  37 + WithKV("beginCreatedAt", req.BeginTime).
  38 + WithKV("endCreatedAt", req.EndTime)
  39 +
  40 + cnt, articleList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOptions)
  41 + if err != nil {
  42 + return &types.SystemArticleCommentSearchMeResponse{}, xerr.NewErrMsgErr("获取评论回复列表失败", err)
  43 + }
  44 +
  45 + resp = &types.SystemArticleCommentSearchMeResponse{
  46 + Total: cnt,
  47 + List: make([]types.ArticleCommentItem, len(articleList)),
  48 + }
  49 + for i := range articleList {
  50 + resp.List[i] = NewArticleCommentItem(articleList[i])
  51 + }
  52 + return
  53 +}
@@ -31,14 +31,14 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types @@ -31,14 +31,14 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types
31 var userToken = contextdata.GetUserTokenFromCtx(l.ctx) 31 var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
32 var conn = l.svcCtx.DefaultDBConn() 32 var conn = l.svcCtx.DefaultDBConn()
33 33
34 - _, list, err := l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.NewQueryOptions().  
35 - WithOffsetLimit(1, 1).WithFindOnly(). 34 + total, _, err := l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.NewQueryOptions().
  35 + WithCountOnly().
36 WithKV("companyId", userToken.CompanyId). 36 WithKV("companyId", userToken.CompanyId).
37 WithKV("name", req.Name)) 37 WithKV("name", req.Name))
38 if err != nil { 38 if err != nil {
39 return nil, err 39 return nil, err
40 } 40 }
41 - if len(list) > 0 { 41 + if total > 0 {
42 return nil, xerr.NewErrMsg("该分组名称已存在(不能重复)") 42 return nil, xerr.NewErrMsg("该分组名称已存在(不能重复)")
43 } 43 }
44 44
@@ -48,7 +48,7 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types @@ -48,7 +48,7 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types
48 CompanyId: userToken.CompanyId, 48 CompanyId: userToken.CompanyId,
49 Name: req.Name, 49 Name: req.Name,
50 } 50 }
51 - err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { 51 + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
52 _, err = l.svcCtx.DepartmentRepository.Insert(l.ctx, conn, insert) 52 _, err = l.svcCtx.DepartmentRepository.Insert(l.ctx, conn, insert)
53 if err != nil { 53 if err != nil {
54 return err 54 return err
  1 +package department
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  9 +
  10 + "github.com/zeromicro/go-zero/core/logx"
  11 +)
  12 +
  13 +type SystemDeleteLogic struct {
  14 + logx.Logger
  15 + ctx context.Context
  16 + svcCtx *svc.ServiceContext
  17 +}
  18 +
  19 +func NewSystemDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteLogic {
  20 + return &SystemDeleteLogic{
  21 + Logger: logx.WithContext(ctx),
  22 + ctx: ctx,
  23 + svcCtx: svcCtx,
  24 + }
  25 +}
  26 +
  27 +func (l *SystemDeleteLogic) SystemDelete(req *types.DepartmentGetRequest) (resp *types.DepartmentGetResponse, err error) {
  28 + var conn = l.svcCtx.DefaultDBConn()
  29 +
  30 + one, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id)
  31 + if err != nil {
  32 + return nil, err
  33 + }
  34 +
  35 + // 获取公司下的所有用户
  36 + _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
  37 + WithFindOnly().
  38 + WithKV(" companyId", one.CompanyId))
  39 + if err != nil {
  40 + return nil, err
  41 + }
  42 +
  43 + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
  44 + _, err = l.svcCtx.DepartmentRepository.Delete(l.ctx, conn, one)
  45 + if err != nil {
  46 + return err
  47 + }
  48 +
  49 + // 移除用户中关联的分组
  50 + if len(users) > 0 {
  51 + var findIndex = func(ids []int64, id int64) int {
  52 + for i, _ := range ids {
  53 + if ids[i] == id {
  54 + return i
  55 + }
  56 + }
  57 + return -1
  58 + }
  59 + for i := range users {
  60 + user := users[i]
  61 + var targetIndex = findIndex(user.Departments, req.Id)
  62 + if targetIndex != -1 { // 归属分组存在,则移除
  63 + user.Departments = append(user.Departments[:targetIndex], user.Departments[targetIndex+1:]...) // 移除分组ID
  64 + _, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user)
  65 + if err != nil {
  66 + return err
  67 + }
  68 + }
  69 + }
  70 + }
  71 + return nil
  72 + }, true)
  73 +
  74 + return
  75 +}
@@ -31,15 +31,15 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re @@ -31,15 +31,15 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re
31 var userToken = contextdata.GetUserTokenFromCtx(l.ctx) 31 var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
32 var conn = l.svcCtx.DefaultDBConn() 32 var conn = l.svcCtx.DefaultDBConn()
33 33
34 - _, list, err := l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.NewQueryOptions().  
35 - WithOffsetLimit(1, 1).WithCountOnly(). 34 + total, _, err := l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.NewQueryOptions().
  35 + WithCountOnly().
36 WithKV("companyId", userToken.CompanyId). 36 WithKV("companyId", userToken.CompanyId).
37 WithKV("notId", req.Id). // 排除自己 37 WithKV("notId", req.Id). // 排除自己
38 WithKV("name", req.Name)) 38 WithKV("name", req.Name))
39 if err != nil { 39 if err != nil {
40 return nil, err 40 return nil, err
41 } 41 }
42 - if len(list) > 0 { 42 + if total > 0 {
43 return nil, xerr.NewErrMsg("该分组名称已存在(不能重复)") 43 return nil, xerr.NewErrMsg("该分组名称已存在(不能重复)")
44 } 44 }
45 45
@@ -49,10 +49,59 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re @@ -49,10 +49,59 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re
49 } 49 }
50 one.Name = req.Name 50 one.Name = req.Name
51 51
  52 + // 更新分组中的用户Id
  53 + var newIdMap = map[int64]int{}
  54 + for i := range req.Ids {
  55 + newIdMap[req.Ids[i]] = 0
  56 + }
  57 +
  58 + // 获取公司下的所有用户
  59 + _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
  60 + WithFindOnly().
  61 + WithKV(" companyId", one.CompanyId))
  62 + if err != nil {
  63 + return nil, err
  64 + }
  65 +
52 // 更新 66 // 更新
53 - err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { 67 + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
54 _, err = l.svcCtx.DepartmentRepository.UpdateWithVersion(l.ctx, conn, one) 68 _, err = l.svcCtx.DepartmentRepository.UpdateWithVersion(l.ctx, conn, one)
55 - return err 69 + if err != nil {
  70 + return err
  71 + }
  72 +
  73 + var findIndex = func(ids []int64, id int64) int {
  74 + for i, _ := range ids {
  75 + if ids[i] == id {
  76 + return i
  77 + }
  78 + }
  79 + return -1
  80 + }
  81 + for i := range users {
  82 + var user = users[i]
  83 + if _, ok := newIdMap[user.Id]; ok {
  84 + var targetIndex = findIndex(user.Departments, req.Id)
  85 + if targetIndex == -1 { // 归属分组不存在,则新增
  86 + user.Departments = append(user.Departments)
  87 + _, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user)
  88 + if err != nil {
  89 + return err
  90 + }
  91 + }
  92 + } else {
  93 + var targetIndex = findIndex(user.Departments, req.Id)
  94 + if targetIndex != -1 { // 归属分组存在,则移除
  95 + user.Departments = append(user.Departments[:targetIndex], user.Departments[targetIndex+1:]...) // 移除分组ID
  96 + _, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user)
  97 + if err != nil {
  98 + return err
  99 + }
  100 + }
  101 + }
  102 + }
  103 +
  104 + return nil
56 }, true) 105 }, true)
57 if err != nil { 106 if err != nil {
58 return nil, xerr.NewErrMsgErr("分组修改失败", err) 107 return nil, xerr.NewErrMsgErr("分组修改失败", err)
@@ -207,23 +207,33 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res @@ -207,23 +207,33 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res
207 } 207 }
208 208
209 // CommentArticle 评论文章 209 // CommentArticle 评论文章
210 -func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, content string, at []int64) (err error) {  
211 - return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, 0, content, at) 210 +func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, sectionId int64, content string, at []int64) (err error) {
  211 + return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, sectionId, 0, content, at)
212 } 212 }
213 213
214 // CommentReply 评论回复 214 // CommentReply 评论回复
215 -func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, commentId int64, content string, at []int64) (err error) {  
216 - return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, commentId, content, at) 215 +func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, sectionId int64, commentId int64, content string, at []int64) (err error) {
  216 + return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, sectionId, commentId, content, at)
217 } 217 }
218 218
219 // LikeArticle 点赞文章 219 // LikeArticle 点赞文章
220 func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, at int64) (err error) { 220 func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, at int64) (err error) {
221 - return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, "", []int64{at}) 221 + return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, 0, "", []int64{at})
222 } 222 }
223 223
224 // LikeComment 点赞评论 224 // LikeComment 点赞评论
225 func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, at int64) (err error) { 225 func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, at int64) (err error) {
226 - return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, commentId, "", []int64{at}) 226 + return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, 0, commentId, "", []int64{at})
  227 +}
  228 +
  229 +// UnLikeArticle 取消点赞文章
  230 +func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64) (err error) {
  231 + return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0)
  232 +}
  233 +
  234 +// UnLikeComment 取消点赞评论
  235 +func (l *MiniBusinessLogic) UnLikeComment(conn transaction.Conn, articleId int64, commentId int64) (err error) {
  236 + return l.deleteMessage(conn, domain.OptTypeComment, articleId, commentId)
227 } 237 }
228 238
229 func (l *MiniBusinessLogic) createMessage( 239 func (l *MiniBusinessLogic) createMessage(
@@ -231,6 +241,7 @@ func (l *MiniBusinessLogic) createMessage( @@ -231,6 +241,7 @@ func (l *MiniBusinessLogic) createMessage(
231 msgType domain.MsgBusinessType, 241 msgType domain.MsgBusinessType,
232 optType domain.MsgBusinessOpt, 242 optType domain.MsgBusinessOpt,
233 articleId int64, 243 articleId int64,
  244 + sectionId int64,
234 commentId int64, 245 commentId int64,
235 content string, 246 content string,
236 at []int64) (err error) { 247 at []int64) (err error) {
@@ -245,6 +256,7 @@ func (l *MiniBusinessLogic) createMessage( @@ -245,6 +256,7 @@ func (l *MiniBusinessLogic) createMessage(
245 UserId: userToken.UserId, 256 UserId: userToken.UserId,
246 RecipientId: at[i], 257 RecipientId: at[i],
247 ArticleId: articleId, 258 ArticleId: articleId,
  259 + SectionId: sectionId,
248 CommentId: commentId, 260 CommentId: commentId,
249 Content: content, 261 Content: content,
250 } 262 }
@@ -255,3 +267,27 @@ func (l *MiniBusinessLogic) createMessage( @@ -255,3 +267,27 @@ func (l *MiniBusinessLogic) createMessage(
255 } 267 }
256 return nil 268 return nil
257 } 269 }
  270 +
  271 +func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId int64) (err error) {
  272 + var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  273 +
  274 + queryOption := domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1).
  275 + MustWithKV("type", domain.MsgTypeLike).
  276 + MustWithKV("optType", optType).
  277 + MustWithKV("companyId", userToken.CompanyId).
  278 + MustWithKV("recipientId", userToken.UserId).
  279 + MustWithKV("articleId", articleId).
  280 + MustWithKV("commentId", commentId)
  281 +
  282 + _, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, conn, queryOption)
  283 + if err != nil {
  284 + return err
  285 + }
  286 + for i := range list {
  287 + _, err = l.svcCtx.MessageBusinessRepository.Delete(l.ctx, conn, list[i])
  288 + if err != nil {
  289 + return err
  290 + }
  291 + }
  292 + return nil
  293 +}
@@ -32,14 +32,14 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag @@ -32,14 +32,14 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
32 //检查重复 32 //检查重复
33 cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{ 33 cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{
34 "name": req.Name, 34 "name": req.Name,
35 - "group": req.Group, 35 + "category": req.Category,
36 "countOnly": true, 36 "countOnly": true,
37 }) 37 })
38 if err != nil { 38 if err != nil {
39 return nil, xerr.NewErrMsgErr("添加标签失败", err) 39 return nil, xerr.NewErrMsgErr("添加标签失败", err)
40 } 40 }
41 if cnt > 0 { 41 if cnt > 0 {
42 - return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name)) 42 + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name))
43 } 43 }
44 //TODO 获取图片的尺寸大小 44 //TODO 获取图片的尺寸大小
45 45
@@ -55,9 +55,10 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag @@ -55,9 +55,10 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
55 Width: 0, 55 Width: 0,
56 Height: 0, 56 Height: 0,
57 }, 57 },
58 - Name: req.Name,  
59 - Group: req.Group,  
60 - Remark: req.Remark, 58 + Name: req.Name,
  59 + Category: req.Category,
  60 + Remark: req.Remark,
  61 + Other: req.Other,
61 } 62 }
62 63
63 newTag, err = l.svcCtx.ArticleTagRepository.Insert(l.ctx, conn, newTag) 64 newTag, err = l.svcCtx.ArticleTagRepository.Insert(l.ctx, conn, newTag)
@@ -33,7 +33,7 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe @@ -33,7 +33,7 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
33 queryOptions := domain.NewQueryOptions(). 33 queryOptions := domain.NewQueryOptions().
34 WithFindOnly(). 34 WithFindOnly().
35 MustWithKV("name", req.Name). 35 MustWithKV("name", req.Name).
36 - MustWithKV("group", req.Group). 36 + MustWithKV("category", req.Category).
37 WithOffsetLimit(1, 1) 37 WithOffsetLimit(1, 1)
38 38
39 _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) 39 _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
@@ -42,7 +42,7 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe @@ -42,7 +42,7 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
42 } 42 }
43 if len(tagList) > 0 { 43 if len(tagList) > 0 {
44 if tagList[0].Id != req.Id { 44 if tagList[0].Id != req.Id {
45 - return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name)) 45 + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name))
46 } 46 }
47 } 47 }
48 oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) 48 oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id)
@@ -55,11 +55,11 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe @@ -55,11 +55,11 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
55 55
56 //TODO 获取图片的尺寸大小 56 //TODO 获取图片的尺寸大小
57 57
58 - oldTag.Group = req.Group 58 + oldTag.Category = req.Category
59 oldTag.Image.Url = req.Image 59 oldTag.Image.Url = req.Image
60 oldTag.Name = req.Name 60 oldTag.Name = req.Name
61 oldTag.Remark = req.Remark 61 oldTag.Remark = req.Remark
62 - 62 + oldTag.Other = req.Other
63 oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag) 63 oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag)
64 if err != nil { 64 if err != nil {
65 return nil, xerr.NewErrMsgErr("添加标签失败", err) 65 return nil, xerr.NewErrMsgErr("添加标签失败", err)
@@ -35,11 +35,12 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon @@ -35,11 +35,12 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon
35 return nil, xerr.NewErrMsg("获取标签失败") 35 return nil, xerr.NewErrMsg("获取标签失败")
36 } 36 }
37 resp = &types.TagGetResponse{ 37 resp = &types.TagGetResponse{
38 - Id: oldTag.Id,  
39 - Image: oldTag.Image.Url,  
40 - Name: oldTag.Name,  
41 - Group: oldTag.Group,  
42 - Remark: oldTag.Remark, 38 + Id: oldTag.Id,
  39 + Image: oldTag.Image.Url,
  40 + Name: oldTag.Name,
  41 + Category: oldTag.Category,
  42 + Remark: oldTag.Remark,
  43 + Other: oldTag.Other,
43 } 44 }
44 return 45 return
45 } 46 }
@@ -27,8 +27,8 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi @@ -27,8 +27,8 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
27 var conn = l.svcCtx.DefaultDBConn() 27 var conn = l.svcCtx.DefaultDBConn()
28 queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) 28 queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
29 29
30 - if len(req.Group) > 0 {  
31 - queryOptions = queryOptions.MustWithKV("group", req.Group) 30 + if len(req.Category) > 0 {
  31 + queryOptions = queryOptions.MustWithKV("group", req.Category)
32 } 32 }
33 if len(req.TagName) > 0 { 33 if len(req.TagName) > 0 {
34 queryOptions = queryOptions.MustWithKV("name", req.TagName) 34 queryOptions = queryOptions.MustWithKV("name", req.TagName)
@@ -50,10 +50,10 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi @@ -50,10 +50,10 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
50 Id: tagList[i].Id, 50 Id: tagList[i].Id,
51 Image: tagList[i].Image.Url, 51 Image: tagList[i].Image.Url,
52 Name: tagList[i].Name, 52 Name: tagList[i].Name,
53 - Group: tagList[i].Group, 53 + Category: tagList[i].Category,
54 Remark: tagList[i].Remark, 54 Remark: tagList[i].Remark,
55 CreatedAt: tagList[i].CreatedAt, 55 CreatedAt: tagList[i].CreatedAt,
56 } 56 }
57 } 57 }
58 - return 58 + return resp, nil
59 } 59 }
@@ -33,9 +33,10 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -33,9 +33,10 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
33 userToken = contextdata.GetUserTokenFromCtx(l.ctx) 33 userToken = contextdata.GetUserTokenFromCtx(l.ctx)
34 users []*domain.User 34 users []*domain.User
35 departments []*domain.Department 35 departments []*domain.Department
  36 + groups = make([]DepartmentUser, 0)
36 ) 37 )
37 resp = map[string]interface{}{ 38 resp = map[string]interface{}{
38 - "list": make([]DepartmentUser, 0), 39 + "list": groups,
39 } 40 }
40 _, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly()) 41 _, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly())
41 if err != nil { 42 if err != nil {
@@ -58,13 +59,17 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -58,13 +59,17 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
58 } 59 }
59 if lo.Contains(user.Departments, item.Id) && !groupUserSet.Contains(user.Id) { 60 if lo.Contains(user.Departments, item.Id) && !groupUserSet.Contains(user.Id) {
60 group.Users = append(group.Users, &domain.User{ 61 group.Users = append(group.Users, &domain.User{
61 - Id: user.Id,  
62 - Name: user.Name, 62 + Id: user.Id,
  63 + Name: user.Name,
  64 + PinYinName: user.PinYinName,
63 }) 65 })
64 } 66 }
65 } 67 }
  68 + groups = append(groups, group)
66 }) 69 })
67 - 70 + resp = map[string]interface{}{
  71 + "list": groups,
  72 + }
68 return 73 return
69 } 74 }
70 75
@@ -2,6 +2,7 @@ package user @@ -2,6 +2,7 @@ package user
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "github.com/samber/lo"
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/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/domain"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
@@ -33,6 +34,9 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System @@ -33,6 +34,9 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System
33 users []*domain.User 34 users []*domain.User
34 userToken = contextdata.GetUserTokenFromCtx(l.ctx) 35 userToken = contextdata.GetUserTokenFromCtx(l.ctx)
35 ) 36 )
  37 + if !lo.Contains([]int{domain.UserEnable, domain.UserDisable}, req.Status) {
  38 + return nil, xerr.NewErrMsg("启用状态有误")
  39 + }
36 if _, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", req.UserIds).WithFindOnly()); err != nil { 40 if _, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", req.UserIds).WithFindOnly()); err != nil {
37 return nil, xerr.NewErrMsgErr("公司不存在", err) 41 return nil, xerr.NewErrMsgErr("公司不存在", err)
38 } 42 }
@@ -50,5 +54,6 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System @@ -50,5 +54,6 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System
50 }, true); err != nil { 54 }, true); err != nil {
51 return nil, xerr.NewErrMsgErr("更新启用状态失败", err) 55 return nil, xerr.NewErrMsgErr("更新启用状态失败", err)
52 } 56 }
  57 + resp = &types.SystemUserAccountEnableResponse{}
53 return 58 return
54 } 59 }
@@ -2,8 +2,15 @@ package user @@ -2,8 +2,15 @@ package user
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "fmt"
5 "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"
6 "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/cmd/discuss/interanl/pkg/gateway/authlib"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool"
  12 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  13 + "strconv"
7 14
8 "github.com/zeromicro/go-zero/core/logx" 15 "github.com/zeromicro/go-zero/core/logx"
9 ) 16 )
@@ -23,6 +30,67 @@ func NewSystemUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sy @@ -23,6 +30,67 @@ func NewSystemUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sy
23 } 30 }
24 31
25 func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) (resp *types.SystemUserInfoResponse, err error) { 32 func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) (resp *types.SystemUserInfoResponse, err error) {
  33 + var (
  34 + conn = l.svcCtx.DefaultDBConn()
  35 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  36 + response *authlib.DataUserMe
  37 + company *domain.Company
  38 + companyId int64
  39 + code = tool.Krand(6, tool.KC_RAND_KIND_ALL)
  40 + )
  41 + if response, err = l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{
  42 + Token: req.Token,
  43 + }); err != nil {
  44 + return nil, xerr.NewErrMsgErr("获取用户资料失败", err)
  45 + }
  46 +
  47 + companyId, _ = strconv.ParseInt(response.CurrentCompany.ID, 10, 64)
  48 + resp = &types.SystemUserInfoResponse{}
  49 + resp.UserName = response.User.NickName
  50 + resp.UserId, _ = strconv.ParseInt(response.User.ID, 10, 64)
  51 + resp.Avatar = response.User.Avatar
  52 + resp.CompanyName = response.CurrentCompany.Name
  53 + resp.CompanyId = companyId
  54 + resp.Code = code
26 55
  56 + if companyId != userToken.CompanyId {
  57 + return nil, xerr.NewErrMsgErr("获取用户资料失败", fmt.Errorf("当前登录公司信息不匹配"))
  58 + }
  59 + company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId)
  60 + // 新建公司
  61 + if err == domain.ErrNotFound {
  62 + company = &domain.Company{
  63 + Id: companyId,
  64 + Name: response.CurrentCompany.Name,
  65 + Logo: response.CurrentCompany.Logo,
  66 + Code: code,
  67 + }
  68 + if company, err = l.svcCtx.CompanyRepository.Insert(l.ctx, conn, company); err != nil {
  69 + return nil, xerr.NewErrMsgErr("获取用户资料失败", err)
  70 + }
  71 + err = nil
  72 + return
  73 + }
  74 + if err != nil {
  75 + return nil, xerr.NewErrMsgErr("获取用户资料失败", err)
  76 + }
  77 + resp.Code = company.Code
  78 + // 更新公司
  79 + if response.CurrentCompany != nil {
  80 + var changed bool
  81 + if response.CurrentCompany.Name != "" && response.CurrentCompany.Name != company.Name {
  82 + company.Name = response.CurrentCompany.Name
  83 + changed = true
  84 + }
  85 + if response.CurrentCompany.Logo != "" && response.CurrentCompany.Logo != company.Logo {
  86 + company.Logo = response.CurrentCompany.Logo
  87 + changed = true
  88 + }
  89 + if changed {
  90 + if company, err = l.svcCtx.CompanyRepository.UpdateWithVersion(l.ctx, conn, company); err != nil {
  91 + return nil, xerr.NewErrMsgErr("获取用户资料失败", err)
  92 + }
  93 + }
  94 + }
27 return 95 return
28 } 96 }
@@ -2,6 +2,8 @@ package user @@ -2,6 +2,8 @@ package user
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
5 7
6 "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"
7 "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"
@@ -24,7 +26,58 @@ func NewSystemUserStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContex @@ -24,7 +26,58 @@ func NewSystemUserStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContex
24 } 26 }
25 27
26 func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisticsRequest) (resp *types.UserStatisticsResponse, err error) { 28 func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisticsRequest) (resp *types.UserStatisticsResponse, err error) {
27 - // todo: add your logic here and delete this line 29 + var (
  30 + userId = req.UserId
  31 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  32 + )
  33 + s := StatisticsItems(l.ctx, l.svcCtx, userToken.CompanyId, userId, req.ItemFlag)
  34 + resp = &types.UserStatisticsResponse{
  35 + TotalArticle: s.TotalArticle,
  36 + TotalComment: s.TotalComment,
  37 + TotalLoved: s.TotalLoved,
  38 + }
  39 + return
  40 +}
28 41
  42 +func StatisticsItems(ctx context.Context, svcCtx *svc.ServiceContext, companyId, userId int64, itemFlag int) (s Statistics) {
  43 + var conn = svcCtx.DefaultDBConn()
  44 + s = Statistics{}
  45 + if itemFlag == 0 {
  46 + itemFlag = -1
  47 + }
  48 + if (itemFlag & TotalArticle) > 0 {
  49 + var total int64
  50 + total, _, _ = svcCtx.ArticleRepository.Find(ctx, conn, companyId, domain.NewQueryOptions().WithCountOnly().MustWithKV("authorId", userId))
  51 + s.TotalArticle = int(total)
  52 + }
  53 + if (itemFlag & TotalComment) > 0 {
  54 + var total int64
  55 + total, _, _ = svcCtx.ArticleCommentRepository.Find(ctx, conn, domain.IndexCompanyId(companyId)().WithCountOnly().MustWithKV("fromUserId", userId))
  56 + s.TotalComment = int(total)
  57 + }
  58 + if (itemFlag & TotalLoved) > 0 {
  59 + var total int64
  60 + total, _, _ = svcCtx.UserLoveFlagRepository.Find(ctx, conn, domain.IndexCompanyId(companyId)().WithCountOnly().MustWithKV("userId", userId))
  61 + s.TotalComment = int(total)
  62 + }
29 return 63 return
30 } 64 }
  65 +
  66 +type Statistics struct {
  67 + TotalArticle int `json:"totalArticle"`
  68 + TotalComment int `json:"totalComment"`
  69 + TotalLoved int `json:"totalLoved"`
  70 +}
  71 +
  72 +const (
  73 + TotalArticle = 1
  74 + TotalComment = 2
  75 + TotalLoved = 4
  76 +)
  77 +
  78 +func NewStatisticsItem(itemFlag int, value float64) types.StatisticsItem {
  79 + return types.StatisticsItem{
  80 + ItemFlag: itemFlag,
  81 + Value: value,
  82 + }
  83 +}
  1 +package middleware
  2 +
  3 +import (
  4 + "github.com/zeromicro/go-zero/rest/httpx"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  9 + "net/http"
  10 +)
  11 +
  12 +type LoginStatusCheckMiddleware struct {
  13 + apiAuth authlib.ApiAuthService
  14 +}
  15 +
  16 +func NewLoginStatusCheckMiddleware(apiAuth authlib.ApiAuthService) *LoginStatusCheckMiddleware {
  17 + return &LoginStatusCheckMiddleware{
  18 + apiAuth: apiAuth,
  19 + }
  20 +}
  21 +
  22 +func (m *LoginStatusCheckMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
  23 + return func(w http.ResponseWriter, r *http.Request) {
  24 + token := r.Header.Get("x-mmm-accesstoken")
  25 + if len(token) > 0 {
  26 + _, err := m.apiAuth.LoginCheck(r.Context(), authlib.RequestLoginCheck{
  27 + Token: token,
  28 + })
  29 + if err != nil {
  30 + gatewayError, ok := err.(gateway.HttpError)
  31 + if ok {
  32 + unAuthResponse(w, gatewayError.Base.Code, gatewayError.Base.Msg)
  33 + return
  34 + }
  35 + result.HttpResult(r, w, struct{}{}, xerr.NewErr(err))
  36 + return
  37 + }
  38 + }
  39 + next(w, r)
  40 + }
  41 +}
  42 +
  43 +func unAuthResponse(w http.ResponseWriter, code int, msg string) {
  44 + data := map[string]interface{}{
  45 + "msg": msg,
  46 + "code": code,
  47 + "data": struct{}{},
  48 + }
  49 + httpx.WriteJson(w, http.StatusUnauthorized, data)
  50 +}
@@ -2,10 +2,14 @@ package svc @@ -2,10 +2,14 @@ package svc
2 2
3 import ( 3 import (
4 "github.com/zeromicro/go-zero/core/stores/redis" 4 "github.com/zeromicro/go-zero/core/stores/redis"
  5 + "github.com/zeromicro/go-zero/rest"
5 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/config" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/config"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/middleware"
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/repository" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/repository"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway"
  12 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/cache" 13 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/cache"
10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/database" 14 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/database"
11 "gorm.io/gorm" 15 "gorm.io/gorm"
@@ -33,6 +37,10 @@ type ServiceContext struct { @@ -33,6 +37,10 @@ type ServiceContext struct {
33 UserLoveFlagRepository domain.UserLoveFlagRepository 37 UserLoveFlagRepository domain.UserLoveFlagRepository
34 UserReadArticleRepository domain.UserReadArticleRepository 38 UserReadArticleRepository domain.UserReadArticleRepository
35 UserRepository domain.UserRepository 39 UserRepository domain.UserRepository
  40 +
  41 + ApiAuthService authlib.ApiAuthService
  42 +
  43 + LoginStatusCheck rest.Middleware
36 } 44 }
37 45
38 func NewServiceContext(c config.Config) *ServiceContext { 46 func NewServiceContext(c config.Config) *ServiceContext {
@@ -41,11 +49,16 @@ func NewServiceContext(c config.Config) *ServiceContext { @@ -41,11 +49,16 @@ func NewServiceContext(c config.Config) *ServiceContext {
41 49
42 mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass) 50 mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass)
43 redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"}) 51 redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"})
44 - 52 + apiAuth := authlib.ApiAuthService{
  53 + Service: gateway.NewService(c.ApiAuth.Name, c.ApiAuth.Host, c.ApiAuth.Timeout),
  54 + }
45 return &ServiceContext{ 55 return &ServiceContext{
46 - Config: c,  
47 - DB: db,  
48 - Redis: redis, 56 + Config: c,
  57 + DB: db,
  58 + Redis: redis,
  59 + ApiAuthService: apiAuth,
  60 + LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle,
  61 +
49 CommentRepository: repository.NewCommentRepository(cache.NewCachedRepository(mlCache)), 62 CommentRepository: repository.NewCommentRepository(cache.NewCachedRepository(mlCache)),
50 ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), 63 ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)),
51 ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)), 64 ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)),