作者 庄敏学

解决冲突

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

要显示太多修改。

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

... ... @@ -127,6 +127,34 @@
]
}
},
"v1/mini/article/set_tag": {
"post": {
"summary": "小程序设置文章的定性标签",
"operationId": "MiniArticleSetTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleSetTagResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleSetTagRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/mini/article/user_like/list": {
"post": {
"summary": "小程序获取文章的点赞人员列表",
... ... @@ -293,6 +321,151 @@
]
}
},
<<<<<<< HEAD
=======
"v1/mini/article_comment/at_who/list": {
"post": {
"summary": "小程序展示评论时@人可选列表",
"operationId": "MiniArticleCommentAtWho",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleCommentAtWhoResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleCommentAtWhoRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/mini/article_comment/list": {
"post": {
"summary": "小程序展示文章的评论列表",
"operationId": "MiniListArticleComment",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniListArticleCommentResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniListArticleCommentRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/mini/article_comment/top5": {
"post": {
"summary": "小程序展示文章的评论列表TOP5",
"operationId": "MiniTop5ArticleComment",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniTop5ArticleCommentResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniTop5ArticleCommentRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/mini/article_comment/{id}": {
"get": {
"summary": "小程序展示单个文章的评论",
"operationId": "MiniGetArticleComment",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniGetArticleCommentResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"comment"
]
},
"delete": {
"summary": "小程序展示删除文章评论",
"operationId": "MiniDeleteArticleComment",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniDeleteArticleCommentResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniDeleteArticleCommentRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
"v1/mini/article_draft": {
"post": {
"summary": "小程序创建文章进草稿箱",
... ... @@ -430,6 +603,61 @@
"requestBody": {},
"tags": [
"article"
<<<<<<< HEAD
=======
]
}
},
"v1/mini/article_tag/list/all": {
"get": {
"summary": "小程序所有的定性标签",
"operationId": "MiniAllArticleTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniAllArticleTagResponse"
}
}
},
"parameters": [
{
"name": "",
"description": " 公司id",
"in": "query",
"required": false,
"type": "integer",
"format": "int64"
},
{
"name": "",
"description": " 公司id",
"in": "query",
"required": false,
"type": "integer",
"format": "int64"
},
{
"name": "articleId",
"description": " 文章id",
"in": "query",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "tagId",
"description": " 标签id",
"in": "query",
"required": true,
"type": "integer",
"format": "int64"
}
],
"requestBody": {},
"tags": [
"article"
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
]
}
},
... ... @@ -1075,6 +1303,34 @@
]
}
},
"v1/system/article/search/me": {
"post": {
"summary": "管理后台获取我发布的文章",
"operationId": "SystemArticleSearchMe",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleSearchMeResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleSearchMeRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/{id}": {
"get": {
"summary": "管理后台获取文章内容详情",
... ... @@ -1101,6 +1357,34 @@
]
}
},
"v1/system/article_comment/search/me": {
"post": {
"summary": "小程序获取回复@人可选列表",
"operationId": "SystemArticleCommentSearchMe",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleCommentSearchMeResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleCommentSearchMeRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/system/article_tag": {
"post": {
"summary": "后台创建文章标签",
... ... @@ -1350,6 +1634,41 @@
"department"
]
},
<<<<<<< HEAD
=======
"delete": {
"summary": "部门-删除",
"operationId": "systemDelete",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/DepartmentGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/DepartmentGetRequest"
}
}
],
"requestBody": {},
"tags": [
"department"
]
},
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
"put": {
"summary": "部门-更新",
"operationId": "systemUpdate",
... ... @@ -1385,6 +1704,7 @@
},
"v1/system/role": {
"post": {
"summary": "角色新增",
"operationId": "systemSaveRole",
"responses": {
"200": {
... ... @@ -1412,6 +1732,7 @@
},
"v1/system/role/search": {
"post": {
"summary": "角色列表搜索",
"operationId": "systemSearchRole",
"responses": {
"200": {
... ... @@ -1439,6 +1760,7 @@
},
"v1/system/role/{id}": {
"get": {
"summary": "角色详情",
"operationId": "systemGetRole",
"responses": {
"200": {
... ... @@ -1462,6 +1784,7 @@
]
},
"delete": {
"summary": "角色删除",
"operationId": "systemDeleteRole",
"responses": {
"200": {
... ... @@ -1493,6 +1816,7 @@
]
},
"put": {
"summary": "角色更新",
"operationId": "systemUpdateRole",
"responses": {
"200": {
... ... @@ -1770,12 +2094,146 @@
"company"
]
},
"ArticleSearchMe": {
<<<<<<< HEAD
=======
"ArticleCommentAndReply": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"comment": {
"$ref": "#/definitions/ArticleCommentItem",
"description": "评论"
},
"reply": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleCommentItem"
},
"description": "回复的评论"
},
"totalReply": {
"type": "integer",
"format": "int64",
"description": "回复的评论数量"
}
},
"title": "ArticleCommentAndReply",
"required": [
"comment",
"reply",
"totalReply"
]
},
"ArticleCommentItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"pid": {
"type": "integer",
"format": "int64"
},
"topId": {
"type": "integer",
"format": "int64"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"sectionId": {
"type": "integer",
"format": "int64",
"description": " 段落id"
},
"fromUserId": {
"type": "integer",
"format": "int64",
"description": " 填写评论的人"
},
"fromUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 填写评论的人"
},
"toUserId": {
"type": "integer",
"format": "int64",
"description": " 回复哪个人"
},
"toUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 回复哪个人"
},
"sectionContent": {
"type": "string",
"description": " 引用的文章内容文本"
},
"countReply": {
"type": "integer",
"format": "int32",
"description": " 回复数量"
},
"countUserLove": {
"type": "integer",
"format": "int32",
"description": " 用户点赞数量"
},
"countAdminLove": {
"type": "integer",
"format": "int32",
"description": " 运营点赞数量"
},
"atWho": {
"type": "array",
"items": {
"$ref": "#/definitions/CommentAtWho"
},
"description": " 填写评论时@的人"
},
"createdAt": {
"type": "integer",
"format": "int64"
},
"meLoveFlag": {
"type": "integer",
"format": "int32",
"description": "当前人员对评论的点赞标识 (0 没有点赞 1有点赞)"
},
"content": {
"type": "string",
"description": " 评论的内容"
}
},
"title": "ArticleCommentItem",
"required": [
"id",
"pid",
"topId",
"articleId",
"sectionId",
"fromUserId",
"fromUser",
"toUserId",
"toUser",
"sectionContent",
"countReply",
"countUserLove",
"countAdminLove",
"atWho",
"createdAt",
"meLoveFlag",
"content"
]
},
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
"ArticleSearchMe": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"title": {
... ... @@ -1852,6 +2310,27 @@
"totalComment"
]
},
"ArticleTagItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"group": {
"type": "string"
},
"name": {
"type": "string"
}
},
"title": "ArticleTagItem",
"required": [
"id",
"group",
"name"
]
},
"Auth": {
"type": "object",
"properties": {
... ... @@ -1876,6 +2355,25 @@
"code"
]
},
<<<<<<< HEAD
=======
"CommentAtWho": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"title": "CommentAtWho",
"required": [
"id"
]
},
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
"CommentAuthor": {
"type": "object",
"properties": {
... ... @@ -1904,10 +2402,14 @@
"title": "CommentAuthor",
"required": [
"id",
<<<<<<< HEAD
"name",
"avatar",
"position",
"company"
=======
"name"
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
]
},
"Company": {
... ... @@ -2112,12 +2614,28 @@
},
"name": {
"type": "string"
<<<<<<< HEAD
=======
},
"ids": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 用户ID"
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
}
},
"title": "DepartmentUpdateRequest",
"required": [
"id",
<<<<<<< HEAD
"name"
=======
"name",
"ids"
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
]
},
"FollowRequest": {
... ... @@ -2363,6 +2881,58 @@
"total"
]
},
"MiniAllArticleTagRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64",
"description": " 公司id"
},
"": {
"type": "integer",
"format": "int64",
"description": " 公司id"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"tagId": {
"type": "integer",
"format": "int64",
"description": " 标签id"
}
},
"title": "MiniAllArticleTagRequest",
"required": [
"articleId",
"tagId"
]
},
"MiniAllArticleTagResponse": {
"type": "object",
"properties": {
"tagGroup": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTagItem"
}
}
},
"title": "MiniAllArticleTagResponse",
"required": [
"tagGroup",
"tags"
]
},
"MiniArticleBackupItem": {
"type": "object",
"properties": {
... ... @@ -2465,6 +3035,45 @@
"type": "object",
"title": "MiniArticleCommentAtUserResponse"
},
<<<<<<< HEAD
=======
"MiniArticleCommentAtWhoRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"articleId": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleCommentAtWhoRequest",
"required": [
"articleId"
]
},
"MiniArticleCommentAtWhoResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/CommentAtWho"
}
}
},
"title": "MiniArticleCommentAtWhoResponse",
"required": [
"list"
]
},
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
"MiniArticleCreateRequest": {
"type": "object",
"properties": {
... ... @@ -3023,7 +3632,11 @@
"meLoveFlag": {
"type": "integer",
"format": "int32",
<<<<<<< HEAD
"description": "当前人员对文章的点赞标识"
=======
"description": " 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)"
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
}
},
"title": "MiniArticleGetResponse",
... ... @@ -3209,6 +3822,52 @@
"list"
]
},
<<<<<<< HEAD
=======
"MiniArticleSetTagRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64",
"description": " 公司id"
},
"": {
"type": "integer",
"format": "int64",
"description": " 公司id"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"tagId": {
"type": "integer",
"format": "int64",
"description": " 标签id"
}
},
"title": "MiniArticleSetTagRequest",
"required": [
"articleId",
"tagId"
]
},
"MiniArticleSetTagResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleSetTagResponse",
"required": [
"id"
]
},
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
"MiniCreateArticleCommentRequest": {
"type": "object",
"properties": {
... ... @@ -3232,7 +3891,11 @@
"format": "int64",
"description": " 服务端自动获取"
},
<<<<<<< HEAD
"commnet": {
=======
"pid": {
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
"type": "integer",
"format": "int64",
"description": " 回复那个评论的id"
... ... @@ -3244,8 +3907,12 @@
"atWho": {
"type": "array",
"items": {
<<<<<<< HEAD
"type": "integer",
"format": "int64"
=======
"$ref": "#/definitions/CommentAtWho"
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
},
"description": " 填写评论时@的人"
}
... ... @@ -3254,97 +3921,235 @@
"required": [
"articleId",
"sectionId",
<<<<<<< HEAD
"commnet",
=======
"pid",
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
"content",
"atWho"
]
},
"MiniCreateArticleCommentResponse": {
"MiniCreateArticleCommentResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"pid": {
"type": "integer",
"format": "int64"
},
"topId": {
"type": "integer",
"format": "int64"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"sectionId": {
"type": "integer",
"format": "int64",
"description": " 段落id"
},
"fromUserId": {
"type": "integer",
"format": "int64",
"description": " 填写评论的人"
},
"fromUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 填写评论的人"
},
"toUserId": {
"type": "integer",
"format": "int64",
"description": " 回复哪个人"
},
"toUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 回复哪个人"
},
"sectionContent": {
"type": "string",
"description": " 引用的文章内容文本"
},
"countReply": {
"type": "integer",
"format": "int32",
"description": " 回复数量"
},
"countUserLove": {
"type": "integer",
"format": "int32",
"description": " 用户点赞数量"
},
"countAdminLove": {
"type": "integer",
"format": "int32",
"description": " 运营点赞数量"
},
"atWho": {
"type": "array",
"items": {
<<<<<<< HEAD
"$ref": "#/definitions/CommentAuthor"
},
"description": " 填写评论时@的人"
=======
"$ref": "#/definitions/CommentAtWho"
},
"description": " 填写评论时@的人"
},
"createdAt": {
"type": "integer",
"format": "int64"
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
}
},
"title": "MiniCreateArticleCommentResponse",
"required": [
"id",
"pid",
"topId",
"articleId",
"sectionId",
"fromUserId",
"fromUser",
"toUserId",
"toUser",
"sectionContent",
"countReply",
"countUserLove",
"countAdminLove",
<<<<<<< HEAD
"atWho"
=======
"atWho",
"createdAt"
]
},
"MiniDeleteArticleCommentRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniDeleteArticleCommentRequest",
"required": [
"id"
]
},
"MiniDeleteArticleCommentResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniDeleteArticleCommentResponse",
"required": [
"id"
]
},
"MiniGetArticleCommentRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"pid": {
"": {
"type": "integer",
"format": "int64"
},
"topId": {
"": {
"type": "integer",
"format": "int64"
},
"articleId": {
}
},
"title": "MiniGetArticleCommentRequest",
"required": [
"id"
]
},
"MiniGetArticleCommentResponse": {
"type": "object",
"properties": {
"": {
"$ref": "#/definitions/ArticleCommentAndReply"
}
},
"title": "MiniGetArticleCommentResponse"
},
"MiniListArticleCommentRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int64",
"description": " 文章id"
"format": "int32"
},
"sectionId": {
"size": {
"type": "integer",
"format": "int64",
"description": " 段落id"
"format": "int32"
},
"fromUserId": {
"": {
"type": "integer",
"format": "int64",
"description": " 填写评论的人"
},
"fromUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 填写评论的人"
"format": "int64"
},
"toUserId": {
"": {
"type": "integer",
"format": "int64",
"description": " 回复哪个人"
},
"toUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 回复哪个人"
},
"sectionContent": {
"type": "string",
"description": " 引用的文章内容文本"
"format": "int64"
},
"countReply": {
"articleId": {
"type": "integer",
"format": "int32",
"description": " 回复数量"
"format": "int64"
},
"countUserLove": {
"sectionId": {
"type": "integer",
"format": "int32",
"description": " 用户点赞数量"
},
"countAdminLove": {
"format": "int64"
}
},
"title": "MiniListArticleCommentRequest",
"required": [
"page",
"size",
"articleId"
]
},
"MiniListArticleCommentResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32",
"description": " 运营点赞数量"
"format": "int64"
},
"atWho": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/CommentAuthor"
},
"description": " 填写评论时@的人"
"$ref": "#/definitions/ArticleCommentAndReply"
}
}
},
"title": "MiniCreateArticleCommentResponse",
"title": "MiniListArticleCommentResponse",
"required": [
"id",
"pid",
"topId",
"articleId",
"sectionId",
"fromUserId",
"fromUser",
"toUserId",
"toUser",
"sectionContent",
"countReply",
"countUserLove",
"countAdminLove",
"atWho"
"total",
"list"
>>>>>>> 77e95275539c30c5787295a0b7f7cd16a3263567
]
},
"MiniMyLikeRequest": {
... ... @@ -3442,6 +4247,42 @@
"count"
]
},
"MiniTop5ArticleCommentRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"articleId": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniTop5ArticleCommentRequest",
"required": [
"articleId"
]
},
"MiniTop5ArticleCommentResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleCommentItem"
}
}
},
"title": "MiniTop5ArticleCommentResponse",
"required": [
"list"
]
},
"MiniUserApplyJoinCompanyRequest": {
"type": "object",
"properties": {
... ... @@ -4114,6 +4955,60 @@
"value"
]
},
"SystemArticleCommentSearchMeRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": " 用户"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": " 开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": " 结束时间"
}
},
"title": "SystemArticleCommentSearchMeRequest",
"required": [
"page",
"size",
"authorId"
]
},
"SystemArticleCommentSearchMeResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleCommentItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "SystemArticleCommentSearchMeResponse",
"required": [
"list",
"total"
]
},
"SystemArticleGetRequest": {
"type": "object",
"properties": {
... ... @@ -4368,6 +5263,60 @@
"targetUser"
]
},
"SystemArticleSearchMeRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": " 用户"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": " 开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": " 结束时间"
}
},
"title": "SystemArticleSearchMeRequest",
"required": [
"page",
"size",
"authorId"
]
},
"SystemArticleSearchMeResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSearchMe"
}
}
},
"title": "SystemArticleSearchMeResponse",
"required": [
"total",
"list"
]
},
"SystemArticleSearchRequest": {
"type": "object",
"properties": {
... ... @@ -4848,7 +5797,15 @@
},
"SystemUserInfoRequest": {
"type": "object",
"title": "SystemUserInfoRequest"
"properties": {
"Token": {
"type": "string"
}
},
"title": "SystemUserInfoRequest",
"required": [
"x-mmm-accesstoken"
]
},
"SystemUserInfoResponse": {
"type": "object",
... ... @@ -4869,6 +5826,9 @@
},
"companyName": {
"type": "string"
},
"code": {
"type": "string"
}
},
"title": "SystemUserInfoResponse",
... ... @@ -4877,7 +5837,8 @@
"userName",
"avatar",
"companyId",
"companyName"
"companyName",
"code"
]
},
"SystemUserSearchRequest": {
... ... @@ -5443,28 +6404,35 @@
"itemFlag": {
"type": "integer",
"format": "int32",
"description": " 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳"
"description": "0:默认查询所有 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳"
}
},
"title": "UserStatisticsRequest",
"required": [
"userId",
"itemFlag"
]
},
"UserStatisticsResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/StatisticsItem"
}
"totalArticle": {
"type": "integer",
"format": "int32"
},
"totalComment": {
"type": "integer",
"format": "int32"
},
"totalLoved": {
"type": "integer",
"format": "int32"
}
},
"title": "UserStatisticsResponse",
"required": [
"list"
"totalArticle",
"totalComment",
"totalLoved"
]
},
"WhichUserLikeArticle": {
... ...
... ... @@ -63,6 +63,15 @@ service Core {
@doc "小程序获取文章的编辑记录"
@handler MiniArticleBackupSearch
post /article_backup/search (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse)
@doc "小程序设置文章的定性标签"
@handler MiniArticleSetTag
post /article/set_tag (MiniArticleSetTagRequest) returns (MiniArticleSetTagResponse)
@doc "小程序所有的定性标签"
@handler MiniAllArticleTag
get /article_tag/list/all (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse)
}
// 管理后台接口
... ... @@ -87,4 +96,9 @@ service Core {
@doc "管理后台编辑历史"
@handler SystemHistoryArticle
post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse)
@doc "管理后台获取我发布的文章"
@handler SystemArticleSearchMe
post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse)
}
\ No newline at end of file
... ...
... ... @@ -8,14 +8,42 @@ info(
version: "v1"
)
@server(
prefix: v1/system
group: tags
jwt: SystemAuth
)
service Core {
@doc "后台创建文章标签"
@handler CreateTag
post /article_tag (TagCreateRequest) returns (TagCreateResponse)
@doc "后台编辑文章标签"
@handler EditTag
put /article_tag (TagEditRequest) returns (TagEditResponse)
@doc "后台获取文章标签"
@handler GetTag
get /article_tag/:id (TagGetRequest) returns (TagGetResponse)
@doc "后台删除文章标签"
@handler DeleteTag
delete /article_tag/:id (TagDeleteRequest) returns (TagDeleteResponse)
@doc "后台搜索标签"
@handler SearchTag
post/article_tag/search (TagListRequest) returns (TagListResponse)
}
// 创建标签
type (
TagCreateRequest {
CompanyId int64 `json:"companyId"`
CompanyId int64 `json:",optional"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
}
TagCreateResponse {
... ... @@ -27,11 +55,12 @@ type (
type (
TagEditRequest {
Id int64 `json:"id"`
CompanyId int64 `json:"-"`
CompanyId int64 `json:",optional"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
}
TagEditResponse {
... ... @@ -43,14 +72,15 @@ type (
type (
TagGetRequest {
Id int64 `path:"id"`
CompanyId int64 `path:"-"`
CompanyId int64 `path:",optional"`
}
TagGetResponse {
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
Other string `json:"other"`
}
)
... ... @@ -59,9 +89,9 @@ type (
TagListRequest {
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:"-"`
CompanyId int64 `json:",optional"`
TagName string `json:"tagName,optional"`
Group string `json:"group,optional"`
Category string `json:"category,optional"`
Remark string `json:"remark,optional"`
}
TagListResponse {
... ... @@ -71,9 +101,9 @@ type (
TagItem {
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
CreatedAt int64 `json:"createdAt"`
}
)
... ... @@ -82,36 +112,9 @@ type (
type (
TagDeleteRequest {
Id int64 `path:"id"`
CompanyId int64 `path:"-"`
CompanyId int64 `path:",optional"`
}
TagDeleteResponse {
Id int64 `json:"id"`
}
)
@server(
prefix: v1/system
group: tags
jwt: MiniAuth
)
service Core {
@doc "后台创建文章标签"
@handler CreateTag
post /article_tag (TagCreateRequest) returns (TagCreateResponse)
@doc "后台编辑文章标签"
@handler EditTag
put /article_tag (TagEditRequest) returns (TagEditResponse)
@doc "后台获取文章标签"
@handler GetTag
get /article_tag/:id (TagGetRequest) returns (TagGetResponse)
@doc "后台删除文章标签"
@handler DeleteTag
delete /article_tag/:id (TagDeleteRequest) returns (TagDeleteResponse)
@doc "后台搜索标签"
@handler SearchTag
post/article_tag/search (TagListRequest) returns (TagListResponse)
}
\ No newline at end of file
)
\ No newline at end of file
... ...
... ... @@ -55,7 +55,7 @@ type (
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
MeLoveFlag int `json:"meLoveFlag"` //当前人员对文章的点赞标识
MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
}
ArticleSection {
Id int64 `json:"id"` //段落id
... ... @@ -88,6 +88,18 @@ type (
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
}
SystemArticleSearchMeRequest {
Page int `json:"page"`
Size int `json:"size"`
AuthorId int64 `json:"authorId"` // 用户
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
}
SystemArticleSearchMeResponse {
Total int `json:"total"`
List []ArticleSearchMe `json:"list"`
}
)
//小程序端获取文章有哪些人进行了点赞
... ... @@ -107,6 +119,7 @@ type (
UserId int64 `json:"userId"` // 人员id
Name string `json:"name"` // 人员名称
Avatar string `json:"avatar"` // 人员头像
Position string `json:"position"` // 职位
CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
}
)
... ... @@ -278,6 +291,40 @@ type (
}
)
//小程序端设置文章的定性标签
type (
MiniArticleSetTagRequest{
CompanyId int64 `json:",optional"` // 公司id
UserId int64 `json:",optional"` // 公司id
ArticleId int64 `json:"articleId"` // 文章id
TagId int64 `json:"tagId"` // 标签id
}
MiniArticleSetTagResponse{
Id int64 `json:"id"`
}
)
//小程序端获取所有的定性标签
type (
MiniAllArticleTagRequest{
CompanyId int64 `json:",optional"` // 公司id
UserId int64 `json:",optional"` // 公司id
}
MiniAllArticleTagResponse{
TagGroup []ArticleTagGroup `json:"tagGroup"`
}
ArticleTagGroup {
Group string `json:"group"`
Tags []ArticleTagItem `json:"tags"`
}
ArticleTagItem {
Id int64 `json:"id"`
Group string `json:"group"`
Name string `json:"name"`
Image string `json:"image"`
}
)
... ...
... ... @@ -23,6 +23,39 @@ service Core {
@doc "小程序填写文章的评论"
@handler MiniCreateArticleComment
post /article_comment (MiniCreateArticleCommentRequest) returns (MiniCreateArticleCommentResponse)
@doc "小程序展示文章的评论列表"
@handler MiniListArticleComment
post /article_comment/list (MiniListArticleCommentRequest) returns (MiniListArticleCommentResponse)
@doc "小程序展示文章的评论列表TOP5"
@handler MiniTop5ArticleComment
post /article_comment/top5 (MiniTop5ArticleCommentRequest) returns (MiniTop5ArticleCommentResponse)
@doc "小程序展示单个文章的评论"
@handler MiniGetArticleComment
get /article_comment/:id (MiniGetArticleCommentRequest) returns (MiniGetArticleCommentResponse)
@doc "小程序展示删除文章评论"
@handler MiniDeleteArticleComment
delete /article_comment/:id (MiniDeleteArticleCommentRequest) returns (MiniDeleteArticleCommentResponse)
@doc "小程序展示评论时@人可选列表"
@handler MiniArticleCommentAtWho
post /article_comment/at_who/list (MiniArticleCommentAtWhoRequest) returns (MiniArticleCommentAtWhoResponse)
}
// 后台接口
@server(
prefix: v1/system
group: comment
middleware: LoginStatusCheck
jwt: SystemAuth
)
service Core {
@doc "小程序获取回复@人可选列表"
@handler SystemArticleCommentSearchMe
post /article_comment/search/me (SystemArticleCommentSearchMeRequest) returns (SystemArticleCommentSearchMeResponse)
}
//
... ... @@ -38,39 +71,151 @@ type (
//评论的填写人
type CommentAuthor {
Id int64 `json:"id"` // 人员id
Name string `json:"name"` // 人员的名字
Avatar string `json:"avatar"` // 人员头像URL
Position string `json:"position"` // 职位
Company string `json:"company"` // 公司
Id int64 `json:"id"` // 人员id
Name string `json:"name"` // 人员的名字
Avatar string `json:"avatar,optional"` // 人员头像URL
Position string `json:"position,optional"` // 职位
Company string `json:"company,optional"` // 公司
}
// 小程序填写文章的评论
type (
MiniCreateArticleCommentRequest {
ArtitcleId int64 `json:"articleId"` // 文章id
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:",optional"` // 填写文章的人,服务端自动获取
CompanyId int64 `json:",optional"` // 服务端自动获取
Pid int64 `json:"commnet"` // 回复那个评论的id
Content string `json:"content"` // 评论的内容
AtWho []int64 `json:"atWho"` // 填写评论时@的人
ArtitcleId int64 `json:"articleId"` // 文章id
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:",optional"` // 填写文章的人,服务端自动获取
CompanyId int64 `json:",optional"` // 服务端自动获取
Pid int64 `json:"pid"` // 回复那个评论的id
Content string `json:"content"` // 评论的内容
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
}
CommentAtWho {
Id int64 `json:"id"`
Name string `json:"name,optional"`
FirstLetter string `json:"firstLetter,optional"`
}
MiniCreateArticleCommentResponse {
Id int64 `json:"id"`
Pid int64 `json:"pid"`
TopId int64 `json:"topId"`
ArtitcleId int64 `json:"articleId"` // 文章id
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:"fromUserId"` // 填写评论的人
FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
ToUserId int64 `json:"toUserId"` // 回复哪个人
ToUser CommentAuthor `json:"toUser"` // 回复哪个人
SectionContent string `json:"sectionContent"` // 引用的文章内容文本
CountReply int `json:"countReply"` // 回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
AtWho []CommentAuthor `json:"atWho"` // 填写评论时@的人
Id int64 `json:"id"`
Pid int64 `json:"pid"`
TopId int64 `json:"topId"`
ArtitcleId int64 `json:"articleId"` // 文章id
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:"fromUserId"` // 填写评论的人
FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
ToUserId int64 `json:"toUserId"` // 回复哪个人
ToUser CommentAuthor `json:"toUser"` // 回复哪个人
SectionContent string `json:"sectionContent"` // 引用的文章内容文本
CountReply int `json:"countReply"` // 回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
CreatedAt int64 `json:"createdAt"` //
}
)
// 小程序获取文章的评论列表
type (
MiniListArticleCommentRequest {
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:",optional"`
UserId int64 `json:",optional"`
ArticleId int64 `json:"articleId"`
SectionId int64 `json:"sectionId,optional"`
}
MiniListArticleCommentResponse {
Total int64 `json:"total"`
List []ArticleCommentAndReply `json:"list"`
}
ArticleCommentAndReply {
Comment ArticleCommentItem `json:"comment"` //评论
Reply []ArticleCommentItem `json:"reply"` //回复的评论
TotalReply int64 `json:"totalReply"` //回复的评论数量
}
ArticleCommentItem {
Id int64 `json:"id"`
Pid int64 `json:"pid"`
TopId int64 `json:"topId"`
ArtitcleId int64 `json:"articleId"` // 文章id
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:"fromUserId"` // 填写评论的人
FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
ToUserId int64 `json:"toUserId"` // 回复哪个人
ToUser CommentAuthor `json:"toUser"` // 回复哪个人
SectionContent string `json:"sectionContent"` // 引用的文章内容文本
CountReply int `json:"countReply"` // 回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
CreatedAt int64 `json:"createdAt"` //
MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞)
Content string `json:"content"` // 评论的内容
}
)
// 小程序获取单个文章的评论
type (
MiniGetArticleCommentRequest {
CommentId int64 `path:"id"`
CompanyId int64 `path:",optional"`
UserId int64 `path:",optional"`
}
MiniGetArticleCommentResponse {
ArticleCommentAndReply
}
)
// 小程序删除单个文章的评论
type (
MiniDeleteArticleCommentRequest {
CommentId int64 `path:"id"`
UserId int64 `path:",optional"`
CompanyId int64 `path:",optional"`
}
MiniDeleteArticleCommentResponse {
Id int64 `json:"id"`
}
)
// 热门前5的评论列表
type (
MiniTop5ArticleCommentRequest {
CompanyId int64 `json:",optional"`
UserId int64 `json:",optional"`
ArticleId int64 `json:"articleId"`
}
MiniTop5ArticleCommentResponse {
List []ArticleCommentItem `json:"list"`
}
)
// 填写评论时选择@人
type (
MiniArticleCommentAtWhoRequest {
CompanyId int64 `json:",optional"`
UserId int64 `json:",optional"`
ArticleId int64 `json:"articleId"`
}
MiniArticleCommentAtWhoResponse {
List []CommentAtWho `json:"list"`
}
)
type(
SystemArticleCommentSearchMeRequest{
Page int `json:"page"`
Size int `json:"size"`
AuthorId int64 `json:"authorId"` // 用户
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
}
SystemArticleCommentSearchMeResponse{
List []ArticleCommentItem `json:"list"`
Total int64 `json:"total"`
}
)
\ No newline at end of file
... ...
... ... @@ -11,6 +11,7 @@ info(
@server(
prefix: v1
group: department
middleware: LoginStatusCheck
jwt: SystemAuth
)
service Core {
... ... @@ -29,6 +30,10 @@ service Core {
@doc "部门-更新"
@handler systemUpdate
put /system/department/:id (DepartmentUpdateRequest) returns (DepartmentGetResponse)
@doc "部门-删除"
@handler systemDelete
delete /system/department/:id (DepartmentGetRequest) returns (DepartmentGetResponse)
}
type (
... ... @@ -48,6 +53,7 @@ type (
DepartmentUpdateRequest {
Id int64 `path:"id"`
Name string `json:"name"`
Ids []int64 `json:"ids"` // 用户ID
}
DepartmentListRequest {
... ...
... ... @@ -9,21 +9,27 @@ info(
)
@server(
prefix: v1
group: role
jwt: SystemAuth
prefix: v1
group: role
middleware: LoginStatusCheck
jwt: SystemAuth
)
service Core {
@handler systemGetRole
get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
@handler systemSaveRole
post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
@handler systemDeleteRole
delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
@handler systemUpdateRole
put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
@handler systemSearchRole
post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
@doc "角色详情"
@handler systemGetRole
get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
@doc "角色新增"
@handler systemSaveRole
post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
@doc "角色删除"
@handler systemDeleteRole
delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
@doc "角色更新"
@handler systemUpdateRole
put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
@doc "角色列表搜索"
@handler systemSearchRole
post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
}
type (
... ...
... ... @@ -209,6 +209,7 @@ type (
@server(
prefix: v1
group: user
middleware: LoginStatusCheck
jwt: SystemAuth
)
service Core {
... ... @@ -249,7 +250,7 @@ service Core {
type(
SystemUserInfoRequest{
Token string `header:"x-mmm-accesstoken"`
}
SystemUserInfoResponse{
UserId int64 `json:"userId"`
... ... @@ -257,13 +258,16 @@ type(
Avatar string `json:"avatar"`
CompanyId int64 `json:"companyId"`
CompanyName string `json:"companyName"`
Code string `json:"code"`
}
UserStatisticsRequest{
UserId int64 `json:"userId"`
ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
UserId int64 `json:"userId,optional"`
ItemFlag int `json:"itemFlag"` //0:默认查询所有 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
}
UserStatisticsResponse{
List []StatisticsItem `json:"list"`
TotalArticle int `json:"totalArticle"`
TotalComment int `json:"totalComment"`
TotalLoved int `json:"totalLoved"`
}
StatisticsItem{
ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
... ...
Name: discuss
Host: 0.0.0.0
Port: 8081
Verbose: true
Verbose: false
Migrate: false
Timeout: 30000
Log:
... ... @@ -12,7 +12,7 @@ Log:
TimeFormat: 2006-01-02 15:04:05.000
SystemAuth:
AccessSecret: discuss-secret
AccessSecret: digital-platform
AccessExpire: 360000
MiniAuth:
... ... @@ -25,3 +25,8 @@ Redis:
Pass:
DB:
DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=sumifcc-discuss-dev port=31543 sslmode=disable TimeZone=Asia/Shanghai
ApiAuth:
Name: ApiAuth
Host: http://digital-platform-dev.fjmaimaimai.com
Timeout: 0s
... ...
... ... @@ -4,6 +4,7 @@ import (
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/rest"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/config"
"time"
)
type Config struct {
... ... @@ -13,4 +14,11 @@ type Config struct {
SystemAuth config.Auth
MiniAuth config.Auth
Migrate bool `json:",optional,default=true"`
ApiAuth ApiService
}
type ApiService struct {
Name string
Host string
Timeout time.Duration
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniAllArticleTagRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniAllArticleTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniAllArticleTag(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniArticleSetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleSetTagRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniArticleSetTagLogic(r.Context(), svcCtx)
resp, err := l.MiniArticleSetTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package article
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleSearchMeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemArticleSearchMeLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleSearchMe(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleCommentAtWhoRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewMiniArticleCommentAtWhoLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniArticleCommentAtWho(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniDeleteArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniDeleteArticleCommentRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewMiniDeleteArticleCommentLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniDeleteArticleComment(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniGetArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniGetArticleCommentRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewMiniGetArticleCommentLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniGetArticleComment(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniListArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniListArticleCommentRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewMiniListArticleCommentLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniListArticleComment(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniTop5ArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniTop5ArticleCommentRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewMiniTop5ArticleCommentLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniTop5ArticleComment(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package comment
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemArticleCommentSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleCommentSearchMeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewSystemArticleCommentSearchMeLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleCommentSearchMe(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package department
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/department"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DepartmentGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := department.NewSystemDeleteLogic(r.Context(), svcCtx)
resp, err := l.SystemDelete(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -30,12 +30,52 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article_comment",
Handler: comment.MiniCreateArticleCommentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_comment/list",
Handler: comment.MiniListArticleCommentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_comment/top5",
Handler: comment.MiniTop5ArticleCommentHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_comment/:id",
Handler: comment.MiniGetArticleCommentHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article_comment/:id",
Handler: comment.MiniDeleteArticleCommentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_comment/at_who/list",
Handler: comment.MiniArticleCommentAtWhoHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithPrefix("/v1/mini"),
)
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/article_comment/search/me",
Handler: comment.SystemArticleCommentSearchMeHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
... ... @@ -80,7 +120,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: tags.SearchTagHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
... ... @@ -158,58 +198,61 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/system/user/info",
Handler: user.SystemUserInfoHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/user/statistics",
Handler: user.SystemUserStatisticsHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/system/user/:id",
Handler: user.SystemUserGetHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/user/:id",
Handler: user.SystemUserUpdateHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/user/search",
Handler: user.SystemUserSearchHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/system/account/:id",
Handler: user.SystemUserAccountGetHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/account",
Handler: user.SystemUserAccountSaveHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/account/enable",
Handler: user.SystemUserAccountEnableHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/account/:id",
Handler: user.SystemUserAccountUpdateHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/account/search",
Handler: user.SystemUserAccountSearchHandler(serverCtx),
},
},
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/system/user/info",
Handler: user.SystemUserInfoHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/user/statistics",
Handler: user.SystemUserStatisticsHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/system/user/:id",
Handler: user.SystemUserGetHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/user/:id",
Handler: user.SystemUserUpdateHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/user/search",
Handler: user.SystemUserSearchHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/system/account/:id",
Handler: user.SystemUserAccountGetHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/account",
Handler: user.SystemUserAccountSaveHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/account/enable",
Handler: user.SystemUserAccountEnableHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/account/:id",
Handler: user.SystemUserAccountUpdateHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/account/search",
Handler: user.SystemUserAccountSearchHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1"),
)
... ... @@ -316,6 +359,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article_backup/search",
Handler: article.MiniArticleBackupSearchHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/set_tag",
Handler: article.MiniArticleSetTagHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_tag/list/all",
Handler: article.MiniAllArticleTagHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithPrefix("/v1/mini"),
... ... @@ -343,66 +396,82 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article/history",
Handler: article.SystemHistoryArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search/me",
Handler: article.SystemArticleSearchMeHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/system/role/:id",
Handler: role.SystemGetRoleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/role",
Handler: role.SystemSaveRoleHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/system/role/:id",
Handler: role.SystemDeleteRoleHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/role/:id",
Handler: role.SystemUpdateRoleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/role/search",
Handler: role.SystemSearchRoleHandler(serverCtx),
},
},
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck},
[]rest.Route{
{
Method: http.MethodGet,
Path: "/system/role/:id",
Handler: role.SystemGetRoleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/role",
Handler: role.SystemSaveRoleHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/system/role/:id",
Handler: role.SystemDeleteRoleHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/role/:id",
Handler: role.SystemUpdateRoleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/role/search",
Handler: role.SystemSearchRoleHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/system/department/list",
Handler: department.SystemListHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/department/add",
Handler: department.SystemAddHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/system/department/:id",
Handler: department.SystemGetHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/department/:id",
Handler: department.SystemUpdateHandler(serverCtx),
},
},
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/system/department/list",
Handler: department.SystemListHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/department/add",
Handler: department.SystemAddHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/system/department/:id",
Handler: department.SystemGetHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/department/:id",
Handler: department.SystemUpdateHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/system/department/:id",
Handler: department.SystemDeleteHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1"),
)
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := tags.NewCreateTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.CreateTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := tags.NewDeleteTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.DeleteTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := tags.NewEditTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.EditTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -16,13 +18,10 @@ func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
httpx.ErrorCtx(r.Context(), w, err)
return
}
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
l := tags.NewGetTagLogic(r.Context(), svcCtx)
resp, err := l.GetTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := tags.NewSearchTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.SearchTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniAllArticleTagLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniAllArticleTagLogic {
return &MiniAllArticleTagLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
queryOption := domain.NewQueryOptions().WithFindOnly()
_, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取标签列表失败", err)
}
// 合并输出数据
var group []string
tagMap := map[string][]types.ArticleTagItem{}
for _, val := range tagList {
if m, ok := tagMap[val.Category]; ok {
m = append(m, types.ArticleTagItem{
Id: val.Id,
Group: val.Category,
Name: val.Name,
Image: val.Image.Url,
})
tagMap[val.Category] = m
} else {
group = append(group, val.Category)
tagMap[val.Category] = []types.ArticleTagItem{
{
Id: val.Id,
Group: val.Category,
Name: val.Name,
Image: val.Image.Url,
},
}
}
}
resp = &types.MiniAllArticleTagResponse{
TagGroup: make([]types.ArticleTagGroup, 0),
}
for i := range group {
resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{
Group: group[i],
Tags: tagMap[group[i]],
})
}
return resp, nil
}
... ...
... ... @@ -26,6 +26,7 @@ func NewMiniArticleMarkUserReadLogic(ctx context.Context, svcCtx *svc.ServiceCon
}
}
// 记录人员浏览的文章
func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniArticleMarkUserReadRequest) (resp *types.MiniArticleMarkUserReadResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
... ... @@ -84,7 +85,7 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr
return err
}
//增加浏览计数
err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo)
err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo.Id)
return err
}, true)
if err != nil {
... ...
... ... @@ -42,19 +42,24 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea
List: make([]types.ArticleSearchMe, len(articleList)),
}
for i := range articleList {
images := []string{}
for _, val2 := range articleList[i].Images {
images = append(images, val2.Url)
}
resp.List[i] = types.ArticleSearchMe{
Id: articleList[i].Id,
Title: articleList[i].Title,
Images: images,
CreatedAt: articleList[i].CreatedAt,
CountLove: articleList[i].CountLove,
CountComment: articleList[i].CountComment,
Show: int(articleList[i].Show),
}
resp.List[i] = NewArticle(articleList[i])
}
return
}
func NewArticle(article *domain.Article) types.ArticleSearchMe {
images := []string{}
for _, val2 := range article.Images {
images = append(images, val2.Url)
}
articleSearchMe := types.ArticleSearchMe{
Id: article.Id,
Title: article.Title,
Images: images,
CreatedAt: article.CreatedAt,
CountLove: article.CountLove,
CountComment: article.CountComment,
Show: int(article.Show),
}
return articleSearchMe
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniArticleSetTagLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleSetTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleSetTagLogic {
return &MiniArticleSetTagLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagRequest) (resp *types.MiniArticleSetTagResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"text/template"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -29,6 +30,10 @@ func NewMiniCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceCont
func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArticleDraftCreateRequest) (resp *types.MiniArticleDraftCreateResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
for i := range req.Section {
req.Section[i] = template.HTMLEscapeString(req.Section[i])
}
newDraft := domain.ArticleDraft{
Id: 0,
CompanyId: req.CompanyId,
... ...
... ... @@ -3,6 +3,7 @@ package article
import (
"context"
"strings"
"text/template"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -28,6 +29,7 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
}
// 创建新文章
func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
// 检查发布人
... ... @@ -123,6 +125,8 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
if len(newStr) == 0 {
continue
}
newStr = template.HTMLEscapeString(newStr)
newSection := domain.ArticleSection{
Id: 0,
CompanyId: author.CompanyId,
... ...
... ... @@ -26,6 +26,7 @@ func NewMiniGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mi
}
}
// 小程序端展示文章内容
func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (resp *types.MiniArticleGetResponse, err error) {
// 获取文章内容
var conn = l.svcCtx.DefaultDBConn()
... ... @@ -88,10 +89,9 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
Title: articleInfo.Title,
AuthorId: articleInfo.AuthorId,
Author: types.ArticleAuthor{
Id: articleInfo.Author.Id,
Name: articleInfo.Author.Name,
Avatar: articleInfo.Author.Avatar,
// Group: articleInfo.Author.Group,
Id: articleInfo.Author.Id,
Name: articleInfo.Author.Name,
Avatar: articleInfo.Author.Avatar,
Position: articleInfo.Author.Position,
Company: articleInfo.Author.Company,
},
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -93,10 +94,18 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeArticle(req *types.MiniSetUserLi
return err
}
// 减少文章的点赞数量
err = l.svcCtx.ArticleRepository.IncreaseCountLove(ctx, c, -1, articleInfo)
err = l.svcCtx.ArticleRepository.IncreaseCountLove(ctx, c, -1, articleInfo.Id)
if err != nil {
return err
}
// 删除点赞文章消息
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
err = messageLogic.UnLikeArticle(c, articleInfo.Id)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
... ... @@ -166,10 +175,18 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeComment(req *types.MiniSetUserLi
return err
}
// 减少评论的点赞数量
err = l.svcCtx.ArticleCommentRepository.IncreaseCountUserLove(ctx, c, -1, commentInfo)
err = l.svcCtx.ArticleCommentRepository.IncreaseCountUserLove(ctx, c, -1, commentInfo.Id)
if err != nil {
return err
}
// 删除点赞评论消息
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
err = messageLogic.UnLikeComment(c, commentInfo.ArticleId, commentInfo.Id)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
... ... @@ -239,10 +256,18 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
return err
}
// 增加文章的点赞数量
err = l.svcCtx.ArticleRepository.IncreaseCountLove(ctx, c, 1, articleInfo)
err = l.svcCtx.ArticleRepository.IncreaseCountLove(ctx, c, 1, articleInfo.Id)
if err != nil {
return err
}
// 创建点赞消息
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
err = messageLogic.LikeArticle(c, articleInfo.Id, articleInfo.AuthorId)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
... ... @@ -320,10 +345,18 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ
return err
}
// 增加评论的点赞数量
err = l.svcCtx.ArticleCommentRepository.IncreaseCountUserLove(ctx, c, 1, commentInfo)
err = l.svcCtx.ArticleCommentRepository.IncreaseCountUserLove(ctx, c, 1, commentInfo.Id)
if err != nil {
return err
}
// 创建点赞消息
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
err = messageLogic.LikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.FromUserId)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"text/template"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -37,6 +38,10 @@ func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArti
return nil, xerr.NewErrMsg("更新草稿失败")
}
}
for i := range req.Section {
req.Section[i] = template.HTMLEscapeString(req.Section[i])
}
draftInfo.Content = req.Section
draftInfo.Title = req.Title
draftInfo.Location = domain.Location{
... ...
... ... @@ -71,6 +71,7 @@ func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeAr
if u, ok := userMap[val.UserId]; ok {
item.Name = u.Name
item.Avatar = u.Avatar
item.Position = u.Position
}
resp.List[i] = item
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemArticleSearchMeLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleSearchMeLogic {
return &SystemArticleSearchMeLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleSearchMeLogic) SystemArticleSearchMe(req *types.SystemArticleSearchMeRequest) (resp *types.SystemArticleSearchMeResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
MustWithKV("authorId", req.AuthorId).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime)
cnt, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions)
if err != nil {
return &types.SystemArticleSearchMeResponse{}, xerr.NewErrMsgErr("获取文章列表失败", err)
}
resp = &types.SystemArticleSearchMeResponse{
Total: int(cnt),
List: make([]types.ArticleSearchMe, len(articleList)),
}
for i := range articleList {
resp.List[i] = NewArticle(articleList[i])
}
return
}
... ...
package comment
import (
"context"
"sort"
"strings"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniArticleCommentAtWhoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleCommentAtWhoLogic {
return &MiniArticleCommentAtWhoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// MiniArticleCommentAtWho 填写评估时@谁 的可选择者列表
func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论人信息失败", err)
}
if articleInfo.CompanyId != req.CompanyId {
resp = &types.MiniArticleCommentAtWhoResponse{}
return resp, nil
}
var userList []*domain.User
if len(articleInfo.WhoRead) == 0 {
//获取所有人
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId)
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
resp = &types.MiniArticleCommentAtWhoResponse{}
return resp, nil
}
} else {
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.WhoRead)
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
resp = &types.MiniArticleCommentAtWhoResponse{}
return resp, nil
}
}
uList := make([]types.CommentAtWho, len(userList))
for i := range userList {
uList[i] = types.CommentAtWho{
Id: userList[i].Id,
Name: userList[i].Name,
FirstLetter: "",
}
for _, val := range userList[i].PinYinName {
uList[i].FirstLetter = strings.ToUpper(string(val))
break
}
}
sort.Slice(uList, func(i, j int) bool {
return uList[i].FirstLetter < uList[j].FirstLetter
})
resp = &types.MiniArticleCommentAtWhoResponse{
List: uList,
}
return resp, nil
}
... ...
... ... @@ -3,6 +3,8 @@ package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
... ... @@ -11,6 +13,7 @@ import (
"text/template"
"github.com/samber/lo"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -49,13 +52,12 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
return nil, xerr.NewErrMsg("没有评论权限")
}
//查看评论权限,
//临时注释
// if len(articleInfo.WhoReview) > 0 {
// ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
// if ok < 0 {
// return nil, xerr.NewErrMsg("没有评论权限")
// }
// }
if len(articleInfo.WhoReview) > 0 {
ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
if ok < 0 {
return nil, xerr.NewErrMsg("没有评论权限")
}
}
// 对段落进行评论
var selctionInfo *domain.ArticleSection
if req.SectionId > 0 {
... ... @@ -83,15 +85,22 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
}
}
var atWhoList []*domain.User
var atWhoIds = make([]int64, 0)
if len(req.AtWho) > 0 {
queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", req.AtWho)
for _, val := range req.AtWho {
atWhoIds = append(atWhoIds, val.Id)
}
atWhoIds = lo.Uniq(atWhoIds)
queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", atWhoIds)
_, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
}
if len(atWhoIds) != len(atWhoList) {
return nil, xerr.NewErrMsg("检查@的人员失败")
}
}
// 处理文本内容
// content:=
content := template.HTMLEscapeString(req.Content)
newComment := domain.ArticleComment{
... ... @@ -149,16 +158,52 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
}
//保存数据
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
// 增加平评论计数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, articleInfo)
//保存评论
_, err = l.svcCtx.ArticleCommentRepository.Insert(ctx, c, &newComment)
if err != nil {
return err
}
//保存评论
_, err = l.svcCtx.ArticleCommentRepository.Insert(ctx, c, &newComment)
// 增加文章评论计数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, articleInfo.Id)
if err != nil {
return err
}
//增加段落评论计数
if newComment.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, newComment.SectionId)
if err != nil {
return err
}
}
//增加评论回复计数
if pComment != nil {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, pComment.Id)
if err != nil {
return err
}
}
// 增加最顶层的评论回复计数
if newComment.TopId != 0 && newComment.Pid != newComment.TopId {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, newComment.TopId)
if err != nil {
return err
}
}
// 创建回复消息
var atAllIds = make([]int64, 0)
atAllIds = append(atAllIds, newComment.ToUserId)
atAllIds = append(atAllIds, atWhoIds...)
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
if pComment != nil {
err = messageLogic.CommentReply(c, pComment.ArticleId, pComment.SectionId, pComment.Id, req.Content, atAllIds) // 对评论回复
} else {
err = messageLogic.CommentArticle(c, req.ArtitcleId, req.SectionId, req.Content, atAllIds) // 对文章回复
}
if err != nil {
return err
}
return nil
}, true)
... ... @@ -171,7 +216,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
Pid: newComment.Pid,
TopId: newComment.TopId,
ArtitcleId: newComment.ArticleId,
SectionId: newComment.ArticleId,
SectionId: newComment.SectionId,
FromUserId: newComment.FromUserId,
FromUser: types.CommentAuthor{
Id: newComment.FromUser.Id,
... ... @@ -192,16 +237,14 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
CountReply: 0,
CountUserLove: 0,
CountAdminLove: 0,
AtWho: []types.CommentAuthor{},
AtWho: []types.CommentAtWho{},
CreatedAt: newComment.CreatedAt,
}
for _, val := range newComment.AtWho {
resp.AtWho = append(resp.AtWho, types.CommentAuthor{
Id: val.Id,
Name: val.Name,
Avatar: val.Avatar,
Position: val.Position,
Company: val.Company,
resp.AtWho = append(resp.AtWho, types.CommentAtWho{
Id: val.Id,
Name: val.Name,
})
}
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniDeleteArticleCommentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniDeleteArticleCommentLogic {
return &MiniDeleteArticleCommentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 小程序端人人员删除评论
func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
if err != nil {
return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
}
if commetInfo.FromUserId != req.UserId {
return nil, xerr.NewErrMsg("没有操作权限")
}
commetInfo.Show = domain.CommentShowDisable
// 变更回复数量
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
if err != nil {
return err
}
// 减少上级评论的回复数量
if commetInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid)
if err != nil {
return err
}
}
// 减少最顶层的评论回复计数
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId)
if err != nil {
return err
}
}
//减少加段落评论计数
if commetInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId)
if err != nil {
return err
}
}
// 减少文章的评论数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
return nil, xerr.NewErrMsgErr("删除评论信息失败", err)
}
resp = &types.MiniDeleteArticleCommentResponse{Id: commetInfo.Id}
return resp, nil
}
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniGetArticleCommentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniGetArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniGetArticleCommentLogic {
return &MiniGetArticleCommentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 获取单条评论详情
func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArticleCommentRequest) (resp *types.MiniGetArticleCommentResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
//获取主评论
commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
if commentInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("没有查看权限")
}
if commentInfo.Show == domain.CommentShowDisable {
return nil, xerr.NewErrMsg("没有查看权限")
}
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("topId", commentInfo.Id).MustWithKV("show", domain.CommentShowEnable)
//获取回复的评论
_, replyCommenList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
queryOption = domain.NewQueryOptions().WithFindOnly().
MustWithKV("articleId", commentInfo.ArticleId).
MustWithKV("userId", req.UserId)
// 获取我点赞的评论
_, userFlagList, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
// 我点赞的
flagMap := map[int64]struct{}{}
for _, val := range userFlagList {
flagMap[val.CommentId] = struct{}{}
}
//混合数据
commentResp := types.ArticleCommentItem{
Id: commentInfo.Id,
Pid: commentInfo.Pid,
TopId: commentInfo.TopId,
ArtitcleId: commentInfo.ArticleId,
SectionId: commentInfo.ArticleId,
FromUserId: commentInfo.FromUserId,
FromUser: types.CommentAuthor{
Id: commentInfo.FromUser.Id,
Name: commentInfo.FromUser.Name,
Avatar: commentInfo.FromUser.Avatar,
Position: commentInfo.FromUser.Position,
Company: commentInfo.FromUser.Company,
},
ToUserId: commentInfo.ToUserId,
ToUser: types.CommentAuthor{
Id: commentInfo.ToUser.Id,
Name: commentInfo.ToUser.Name,
Avatar: commentInfo.ToUser.Avatar,
Position: commentInfo.ToUser.Position,
Company: commentInfo.ToUser.Company,
},
SectionContent: commentInfo.SectionContent,
CountReply: commentInfo.CountReply,
CountUserLove: commentInfo.CountUserLove,
CountAdminLove: commentInfo.CountAdminLove,
AtWho: []types.CommentAtWho{},
CreatedAt: commentInfo.CreatedAt,
MeLoveFlag: 0,
}
if _, ok := flagMap[commentInfo.Id]; ok {
commentResp.MeLoveFlag = 1
}
for _, val := range commentInfo.AtWho {
commentResp.AtWho = append(commentResp.AtWho, types.CommentAtWho{
Id: val.Id,
Name: val.Name,
})
}
// 回复的评论
allReply := []types.ArticleCommentItem{}
for _, val := range replyCommenList {
reply := types.ArticleCommentItem{
Id: val.Id,
Pid: val.Pid,
TopId: val.TopId,
ArtitcleId: val.ArticleId,
SectionId: val.SectionId,
FromUserId: val.FromUserId,
FromUser: types.CommentAuthor{
Id: val.FromUser.Id,
Name: val.FromUser.Name,
Avatar: val.FromUser.Avatar,
Position: val.FromUser.Position,
Company: val.FromUser.Company,
},
ToUserId: val.ToUserId,
ToUser: types.CommentAuthor{
Id: val.ToUser.Id,
Name: val.ToUser.Name,
Avatar: val.ToUser.Avatar,
Position: val.ToUser.Position,
Company: val.ToUser.Company,
},
SectionContent: val.SectionContent,
CountReply: val.CountReply,
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
AtWho: []types.CommentAtWho{},
CreatedAt: val.CreatedAt,
MeLoveFlag: 0,
}
if _, ok := flagMap[val.Id]; ok {
reply.MeLoveFlag = 1
}
for _, val2 := range val.AtWho {
reply.AtWho = append(reply.AtWho, types.CommentAtWho{
Id: val2.Id,
Name: val2.Name,
})
}
allReply = append(allReply, reply)
}
resp = &types.MiniGetArticleCommentResponse{
ArticleCommentAndReply: types.ArticleCommentAndReply{
Comment: commentResp,
Reply: allReply,
TotalReply: int64(len(replyCommenList)),
},
}
return
}
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniListArticleCommentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniListArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniListArticleCommentLogic {
return &MiniListArticleCommentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniListArticleCommentRequest) (resp *types.MiniListArticleCommentResponse, err error) {
// 先获取最顶层的评论
var conn = l.svcCtx.DefaultDBConn()
if req.Page > 40 {
req.Page = 40
}
queryOption := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
MustWithKV("topId", 0).
MustWithKV("articleId", req.ArticleId).
MustWithKV("sectionId", req.SectionId).
MustWithKV("show", domain.CommentShowEnable).
MustWithKV("companyId", req.CompanyId)
cnt, commentList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
if cnt == 0 {
resp = &types.MiniListArticleCommentResponse{
Total: 0,
List: make([]types.ArticleCommentAndReply, 0),
}
return
}
queryOption = domain.NewQueryOptions().WithFindOnly().
MustWithKV("articleId", req.ArticleId).
MustWithKV("userId", req.UserId)
// 获取我点赞的评论
_, userFlagList, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
// 我点赞的
flagMap := map[int64]struct{}{}
for _, val := range userFlagList {
flagMap[val.CommentId] = struct{}{}
}
resp = &types.MiniListArticleCommentResponse{
Total: cnt,
List: make([]types.ArticleCommentAndReply, len(commentList)),
}
// 获取回复的评论
for i, val := range commentList {
item := types.ArticleCommentAndReply{
Comment: types.ArticleCommentItem{
Id: val.Id,
Pid: val.Pid,
TopId: val.TopId,
ArtitcleId: val.ArticleId,
SectionId: val.SectionId,
FromUserId: val.FromUserId,
FromUser: types.CommentAuthor{
Id: val.FromUser.Id,
Name: val.FromUser.Name,
Avatar: val.FromUser.Avatar,
Position: val.FromUser.Position,
Company: val.FromUser.Company,
},
ToUserId: val.ToUserId,
ToUser: types.CommentAuthor{
Id: val.ToUser.Id,
Name: val.ToUser.Name,
Avatar: val.ToUser.Avatar,
Position: val.ToUser.Position,
Company: val.ToUser.Company,
},
SectionContent: val.SectionContent,
CountReply: val.CountReply,
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
AtWho: []types.CommentAtWho{},
CreatedAt: val.CreatedAt,
MeLoveFlag: 0,
},
Reply: []types.ArticleCommentItem{},
TotalReply: int64(val.CountReply),
}
if _, ok := flagMap[val.Id]; ok {
item.Comment.MeLoveFlag = 1
}
for _, val2 := range val.AtWho {
item.Comment.AtWho = append(item.Comment.AtWho, types.CommentAtWho{
Id: val2.Id,
Name: val2.Name,
})
}
//获取回复的评论
cntReply, reply := l.listCommentReply(item.Comment.Id, flagMap)
resp.List[i] = item
resp.List[i].Reply = reply
resp.List[i].TotalReply = cntReply
}
return resp, nil
}
// listCommentReply
func (l *MiniListArticleCommentLogic) listCommentReply(commentId int64, loveFlagMap map[int64]struct{}) (cnt int64, replyList []types.ArticleCommentItem) {
var conn = l.svcCtx.DefaultDBConn()
queryOption := domain.NewQueryOptions().
WithOffsetLimit(1, 2).
MustWithKV("topId", commentId).
MustWithKV("show", domain.CommentShowEnable)
cnt, commentList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return cnt, []types.ArticleCommentItem{}
}
if cnt == 0 {
replyList = []types.ArticleCommentItem{}
return cnt, replyList
}
for _, val := range commentList {
item := types.ArticleCommentItem{
Id: val.Id,
Pid: val.Pid,
TopId: val.TopId,
ArtitcleId: val.ArticleId,
SectionId: val.SectionId,
FromUserId: val.FromUserId,
FromUser: types.CommentAuthor{
Id: val.FromUser.Id,
Name: val.FromUser.Name,
Avatar: val.FromUser.Avatar,
Position: val.FromUser.Position,
Company: val.FromUser.Company,
},
ToUserId: val.ToUserId,
ToUser: types.CommentAuthor{
Id: val.ToUser.Id,
Name: val.ToUser.Name,
Avatar: val.ToUser.Avatar,
Position: val.ToUser.Position,
Company: val.ToUser.Company,
},
SectionContent: val.SectionContent,
CountReply: val.CountReply,
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
AtWho: []types.CommentAtWho{},
CreatedAt: val.CreatedAt,
MeLoveFlag: 0,
}
if _, ok := loveFlagMap[val.Id]; ok {
item.MeLoveFlag = 1
}
for _, val2 := range val.AtWho {
item.AtWho = append(item.AtWho, types.CommentAtWho{
Id: val2.Id,
Name: val2.Name,
})
}
replyList = append(replyList, item)
}
return cnt, replyList
}
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniTop5ArticleCommentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniTop5ArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniTop5ArticleCommentLogic {
return &MiniTop5ArticleCommentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 获取前5的评论
func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5ArticleCommentRequest) (resp *types.MiniTop5ArticleCommentResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
commentList, err := l.svcCtx.ArticleCommentRepository.Top5Comment(l.ctx, conn, req.CompanyId, req.ArticleId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
queryOption := domain.NewQueryOptions().WithFindOnly().
MustWithKV("articleId", req.ArticleId).
MustWithKV("userId", req.UserId)
// 获取我点赞的评论
_, userFlagList, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
// 我点赞的
flagMap := map[int64]struct{}{}
for _, val := range userFlagList {
flagMap[val.CommentId] = struct{}{}
}
resp = &types.MiniTop5ArticleCommentResponse{
List: make([]types.ArticleCommentItem, len(commentList)),
}
for i, val := range commentList {
item := NewArticleCommentItem(val)
if _, ok := flagMap[val.Id]; ok {
item.MeLoveFlag = 1
}
for _, val2 := range val.AtWho {
item.AtWho = append(item.AtWho, types.CommentAtWho{
Id: val2.Id,
Name: val2.Name,
})
}
resp.List[i] = item
}
return
}
func NewArticleCommentItem(val *domain.ArticleComment) types.ArticleCommentItem {
item := types.ArticleCommentItem{
Id: val.Id,
Pid: val.Pid,
TopId: val.TopId,
ArtitcleId: val.ArticleId,
SectionId: val.SectionId,
FromUserId: val.FromUserId,
FromUser: types.CommentAuthor{
Id: val.FromUser.Id,
Name: val.FromUser.Name,
Avatar: val.FromUser.Avatar,
Position: val.FromUser.Position,
Company: val.FromUser.Company,
},
ToUserId: val.ToUserId,
ToUser: types.CommentAuthor{
Id: val.ToUser.Id,
Name: val.ToUser.Name,
Avatar: val.ToUser.Avatar,
Position: val.ToUser.Position,
Company: val.ToUser.Company,
},
SectionContent: val.SectionContent,
CountReply: val.CountReply,
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
AtWho: []types.CommentAtWho{},
CreatedAt: val.CreatedAt,
MeLoveFlag: 0,
Content: val.Content,
}
return item
}
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemArticleCommentSearchMeLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleCommentSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleCommentSearchMeLogic {
return &SystemArticleCommentSearchMeLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleCommentSearchMeLogic) SystemArticleCommentSearchMe(req *types.SystemArticleCommentSearchMeRequest) (resp *types.SystemArticleCommentSearchMeResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
queryOptions := domain.IndexCompanyId(userToken.CompanyId)().
WithOffsetLimit(req.Page, req.Size).
MustWithKV("fromUserId", req.AuthorId).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime)
cnt, articleList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOptions)
if err != nil {
return &types.SystemArticleCommentSearchMeResponse{}, xerr.NewErrMsgErr("获取评论回复列表失败", err)
}
resp = &types.SystemArticleCommentSearchMeResponse{
Total: cnt,
List: make([]types.ArticleCommentItem, len(articleList)),
}
for i := range articleList {
resp.List[i] = NewArticleCommentItem(articleList[i])
}
return
}
... ...
... ... @@ -31,14 +31,14 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
var conn = l.svcCtx.DefaultDBConn()
_, list, err := l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithOffsetLimit(1, 1).WithFindOnly().
total, _, err := l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithCountOnly().
WithKV("companyId", userToken.CompanyId).
WithKV("name", req.Name))
if err != nil {
return nil, err
}
if len(list) > 0 {
if total > 0 {
return nil, xerr.NewErrMsg("该分组名称已存在(不能重复)")
}
... ... @@ -48,7 +48,7 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types
CompanyId: userToken.CompanyId,
Name: req.Name,
}
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err = l.svcCtx.DepartmentRepository.Insert(l.ctx, conn, insert)
if err != nil {
return err
... ...
package department
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemDeleteLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteLogic {
return &SystemDeleteLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemDeleteLogic) SystemDelete(req *types.DepartmentGetRequest) (resp *types.DepartmentGetResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
one, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, err
}
// 获取公司下的所有用户
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithFindOnly().
WithKV(" companyId", one.CompanyId))
if err != nil {
return nil, err
}
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err = l.svcCtx.DepartmentRepository.Delete(l.ctx, conn, one)
if err != nil {
return err
}
// 移除用户中关联的分组
if len(users) > 0 {
var findIndex = func(ids []int64, id int64) int {
for i, _ := range ids {
if ids[i] == id {
return i
}
}
return -1
}
for i := range users {
user := users[i]
var targetIndex = findIndex(user.Departments, req.Id)
if targetIndex != -1 { // 归属分组存在,则移除
user.Departments = append(user.Departments[:targetIndex], user.Departments[targetIndex+1:]...) // 移除分组ID
_, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user)
if err != nil {
return err
}
}
}
}
return nil
}, true)
return
}
... ...
... ... @@ -31,15 +31,15 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
var conn = l.svcCtx.DefaultDBConn()
_, list, err := l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithOffsetLimit(1, 1).WithCountOnly().
total, _, err := l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithCountOnly().
WithKV("companyId", userToken.CompanyId).
WithKV("notId", req.Id). // 排除自己
WithKV("name", req.Name))
if err != nil {
return nil, err
}
if len(list) > 0 {
if total > 0 {
return nil, xerr.NewErrMsg("该分组名称已存在(不能重复)")
}
... ... @@ -49,10 +49,59 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re
}
one.Name = req.Name
// 更新分组中的用户Id
var newIdMap = map[int64]int{}
for i := range req.Ids {
newIdMap[req.Ids[i]] = 0
}
// 获取公司下的所有用户
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithFindOnly().
WithKV(" companyId", one.CompanyId))
if err != nil {
return nil, err
}
// 更新
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err = l.svcCtx.DepartmentRepository.UpdateWithVersion(l.ctx, conn, one)
return err
if err != nil {
return err
}
var findIndex = func(ids []int64, id int64) int {
for i, _ := range ids {
if ids[i] == id {
return i
}
}
return -1
}
for i := range users {
var user = users[i]
if _, ok := newIdMap[user.Id]; ok {
var targetIndex = findIndex(user.Departments, req.Id)
if targetIndex == -1 { // 归属分组不存在,则新增
user.Departments = append(user.Departments)
_, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user)
if err != nil {
return err
}
}
} else {
var targetIndex = findIndex(user.Departments, req.Id)
if targetIndex != -1 { // 归属分组存在,则移除
user.Departments = append(user.Departments[:targetIndex], user.Departments[targetIndex+1:]...) // 移除分组ID
_, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user)
if err != nil {
return err
}
}
}
}
return nil
}, true)
if err != nil {
return nil, xerr.NewErrMsgErr("分组修改失败", err)
... ...
... ... @@ -207,23 +207,33 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res
}
// CommentArticle 评论文章
func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, content string, at []int64) (err error) {
return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, 0, content, at)
func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, sectionId int64, content string, at []int64) (err error) {
return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, sectionId, 0, content, at)
}
// CommentReply 评论回复
func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, commentId int64, content string, at []int64) (err error) {
return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, commentId, content, at)
func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, sectionId int64, commentId int64, content string, at []int64) (err error) {
return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, sectionId, commentId, content, at)
}
// LikeArticle 点赞文章
func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, at int64) (err error) {
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, "", []int64{at})
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, 0, "", []int64{at})
}
// LikeComment 点赞评论
func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, at int64) (err error) {
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, commentId, "", []int64{at})
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, 0, commentId, "", []int64{at})
}
// UnLikeArticle 取消点赞文章
func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64) (err error) {
return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0)
}
// UnLikeComment 取消点赞评论
func (l *MiniBusinessLogic) UnLikeComment(conn transaction.Conn, articleId int64, commentId int64) (err error) {
return l.deleteMessage(conn, domain.OptTypeComment, articleId, commentId)
}
func (l *MiniBusinessLogic) createMessage(
... ... @@ -231,6 +241,7 @@ func (l *MiniBusinessLogic) createMessage(
msgType domain.MsgBusinessType,
optType domain.MsgBusinessOpt,
articleId int64,
sectionId int64,
commentId int64,
content string,
at []int64) (err error) {
... ... @@ -245,6 +256,7 @@ func (l *MiniBusinessLogic) createMessage(
UserId: userToken.UserId,
RecipientId: at[i],
ArticleId: articleId,
SectionId: sectionId,
CommentId: commentId,
Content: content,
}
... ... @@ -255,3 +267,27 @@ func (l *MiniBusinessLogic) createMessage(
}
return nil
}
func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId int64) (err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
queryOption := domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1).
MustWithKV("type", domain.MsgTypeLike).
MustWithKV("optType", optType).
MustWithKV("companyId", userToken.CompanyId).
MustWithKV("recipientId", userToken.UserId).
MustWithKV("articleId", articleId).
MustWithKV("commentId", commentId)
_, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return err
}
for i := range list {
_, err = l.svcCtx.MessageBusinessRepository.Delete(l.ctx, conn, list[i])
if err != nil {
return err
}
}
return nil
}
... ...
... ... @@ -32,14 +32,14 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
//检查重复
cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{
"name": req.Name,
"group": req.Group,
"category": req.Category,
"countOnly": true,
})
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
}
if cnt > 0 {
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name))
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name))
}
//TODO 获取图片的尺寸大小
... ... @@ -55,9 +55,10 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
Width: 0,
Height: 0,
},
Name: req.Name,
Group: req.Group,
Remark: req.Remark,
Name: req.Name,
Category: req.Category,
Remark: req.Remark,
Other: req.Other,
}
newTag, err = l.svcCtx.ArticleTagRepository.Insert(l.ctx, conn, newTag)
... ...
... ... @@ -33,7 +33,7 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
queryOptions := domain.NewQueryOptions().
WithFindOnly().
MustWithKV("name", req.Name).
MustWithKV("group", req.Group).
MustWithKV("category", req.Category).
WithOffsetLimit(1, 1)
_, 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
}
if len(tagList) > 0 {
if tagList[0].Id != req.Id {
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name))
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name))
}
}
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
//TODO 获取图片的尺寸大小
oldTag.Group = req.Group
oldTag.Category = req.Category
oldTag.Image.Url = req.Image
oldTag.Name = req.Name
oldTag.Remark = req.Remark
oldTag.Other = req.Other
oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag)
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
... ...
... ... @@ -35,11 +35,12 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon
return nil, xerr.NewErrMsg("获取标签失败")
}
resp = &types.TagGetResponse{
Id: oldTag.Id,
Image: oldTag.Image.Url,
Name: oldTag.Name,
Group: oldTag.Group,
Remark: oldTag.Remark,
Id: oldTag.Id,
Image: oldTag.Image.Url,
Name: oldTag.Name,
Category: oldTag.Category,
Remark: oldTag.Remark,
Other: oldTag.Other,
}
return
}
... ...
... ... @@ -27,8 +27,8 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
var conn = l.svcCtx.DefaultDBConn()
queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
if len(req.Group) > 0 {
queryOptions = queryOptions.MustWithKV("group", req.Group)
if len(req.Category) > 0 {
queryOptions = queryOptions.MustWithKV("group", req.Category)
}
if len(req.TagName) > 0 {
queryOptions = queryOptions.MustWithKV("name", req.TagName)
... ... @@ -50,10 +50,10 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
Id: tagList[i].Id,
Image: tagList[i].Image.Url,
Name: tagList[i].Name,
Group: tagList[i].Group,
Category: tagList[i].Category,
Remark: tagList[i].Remark,
CreatedAt: tagList[i].CreatedAt,
}
}
return
return resp, nil
}
... ...
... ... @@ -33,9 +33,10 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
users []*domain.User
departments []*domain.Department
groups = make([]DepartmentUser, 0)
)
resp = map[string]interface{}{
"list": make([]DepartmentUser, 0),
"list": groups,
}
_, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly())
if err != nil {
... ... @@ -58,13 +59,17 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
}
if lo.Contains(user.Departments, item.Id) && !groupUserSet.Contains(user.Id) {
group.Users = append(group.Users, &domain.User{
Id: user.Id,
Name: user.Name,
Id: user.Id,
Name: user.Name,
PinYinName: user.PinYinName,
})
}
}
groups = append(groups, group)
})
resp = map[string]interface{}{
"list": groups,
}
return
}
... ...
... ... @@ -2,6 +2,7 @@ package user
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
... ... @@ -33,6 +34,9 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System
users []*domain.User
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
if !lo.Contains([]int{domain.UserEnable, domain.UserDisable}, req.Status) {
return nil, xerr.NewErrMsg("启用状态有误")
}
if _, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", req.UserIds).WithFindOnly()); err != nil {
return nil, xerr.NewErrMsgErr("公司不存在", err)
}
... ... @@ -50,5 +54,6 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System
}, true); err != nil {
return nil, xerr.NewErrMsgErr("更新启用状态失败", err)
}
resp = &types.SystemUserAccountEnableResponse{}
return
}
... ...
... ... @@ -2,8 +2,15 @@ package user
import (
"context"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -23,6 +30,67 @@ func NewSystemUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sy
}
func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) (resp *types.SystemUserInfoResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
response *authlib.DataUserMe
company *domain.Company
companyId int64
code = tool.Krand(6, tool.KC_RAND_KIND_ALL)
)
if response, err = l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{
Token: req.Token,
}); err != nil {
return nil, xerr.NewErrMsgErr("获取用户资料失败", err)
}
companyId, _ = strconv.ParseInt(response.CurrentCompany.ID, 10, 64)
resp = &types.SystemUserInfoResponse{}
resp.UserName = response.User.NickName
resp.UserId, _ = strconv.ParseInt(response.User.ID, 10, 64)
resp.Avatar = response.User.Avatar
resp.CompanyName = response.CurrentCompany.Name
resp.CompanyId = companyId
resp.Code = code
if companyId != userToken.CompanyId {
return nil, xerr.NewErrMsgErr("获取用户资料失败", fmt.Errorf("当前登录公司信息不匹配"))
}
company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId)
// 新建公司
if err == domain.ErrNotFound {
company = &domain.Company{
Id: companyId,
Name: response.CurrentCompany.Name,
Logo: response.CurrentCompany.Logo,
Code: code,
}
if company, err = l.svcCtx.CompanyRepository.Insert(l.ctx, conn, company); err != nil {
return nil, xerr.NewErrMsgErr("获取用户资料失败", err)
}
err = nil
return
}
if err != nil {
return nil, xerr.NewErrMsgErr("获取用户资料失败", err)
}
resp.Code = company.Code
// 更新公司
if response.CurrentCompany != nil {
var changed bool
if response.CurrentCompany.Name != "" && response.CurrentCompany.Name != company.Name {
company.Name = response.CurrentCompany.Name
changed = true
}
if response.CurrentCompany.Logo != "" && response.CurrentCompany.Logo != company.Logo {
company.Logo = response.CurrentCompany.Logo
changed = true
}
if changed {
if company, err = l.svcCtx.CompanyRepository.UpdateWithVersion(l.ctx, conn, company); err != nil {
return nil, xerr.NewErrMsgErr("获取用户资料失败", err)
}
}
}
return
}
... ...
... ... @@ -2,6 +2,8 @@ package user
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -24,7 +26,58 @@ func NewSystemUserStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContex
}
func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisticsRequest) (resp *types.UserStatisticsResponse, err error) {
// todo: add your logic here and delete this line
var (
userId = req.UserId
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
s := StatisticsItems(l.ctx, l.svcCtx, userToken.CompanyId, userId, req.ItemFlag)
resp = &types.UserStatisticsResponse{
TotalArticle: s.TotalArticle,
TotalComment: s.TotalComment,
TotalLoved: s.TotalLoved,
}
return
}
func StatisticsItems(ctx context.Context, svcCtx *svc.ServiceContext, companyId, userId int64, itemFlag int) (s Statistics) {
var conn = svcCtx.DefaultDBConn()
s = Statistics{}
if itemFlag == 0 {
itemFlag = -1
}
if (itemFlag & TotalArticle) > 0 {
var total int64
total, _, _ = svcCtx.ArticleRepository.Find(ctx, conn, companyId, domain.NewQueryOptions().WithCountOnly().MustWithKV("authorId", userId))
s.TotalArticle = int(total)
}
if (itemFlag & TotalComment) > 0 {
var total int64
total, _, _ = svcCtx.ArticleCommentRepository.Find(ctx, conn, domain.IndexCompanyId(companyId)().WithCountOnly().MustWithKV("fromUserId", userId))
s.TotalComment = int(total)
}
if (itemFlag & TotalLoved) > 0 {
var total int64
total, _, _ = svcCtx.UserLoveFlagRepository.Find(ctx, conn, domain.IndexCompanyId(companyId)().WithCountOnly().MustWithKV("userId", userId))
s.TotalComment = int(total)
}
return
}
type Statistics struct {
TotalArticle int `json:"totalArticle"`
TotalComment int `json:"totalComment"`
TotalLoved int `json:"totalLoved"`
}
const (
TotalArticle = 1
TotalComment = 2
TotalLoved = 4
)
func NewStatisticsItem(itemFlag int, value float64) types.StatisticsItem {
return types.StatisticsItem{
ItemFlag: itemFlag,
Value: value,
}
}
... ...
package middleware
import (
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"net/http"
)
type LoginStatusCheckMiddleware struct {
apiAuth authlib.ApiAuthService
}
func NewLoginStatusCheckMiddleware(apiAuth authlib.ApiAuthService) *LoginStatusCheckMiddleware {
return &LoginStatusCheckMiddleware{
apiAuth: apiAuth,
}
}
func (m *LoginStatusCheckMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
token := r.Header.Get("x-mmm-accesstoken")
if len(token) > 0 {
_, err := m.apiAuth.LoginCheck(r.Context(), authlib.RequestLoginCheck{
Token: token,
})
if err != nil {
gatewayError, ok := err.(gateway.HttpError)
if ok {
unAuthResponse(w, gatewayError.Base.Code, gatewayError.Base.Msg)
return
}
result.HttpResult(r, w, struct{}{}, xerr.NewErr(err))
return
}
}
next(w, r)
}
}
func unAuthResponse(w http.ResponseWriter, code int, msg string) {
data := map[string]interface{}{
"msg": msg,
"code": code,
"data": struct{}{},
}
httpx.WriteJson(w, http.StatusUnauthorized, data)
}
... ...
... ... @@ -2,10 +2,14 @@ package svc
import (
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/rest"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/config"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/middleware"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/repository"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/cache"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/database"
"gorm.io/gorm"
... ... @@ -33,6 +37,10 @@ type ServiceContext struct {
UserLoveFlagRepository domain.UserLoveFlagRepository
UserReadArticleRepository domain.UserReadArticleRepository
UserRepository domain.UserRepository
ApiAuthService authlib.ApiAuthService
LoginStatusCheck rest.Middleware
}
func NewServiceContext(c config.Config) *ServiceContext {
... ... @@ -41,11 +49,16 @@ func NewServiceContext(c config.Config) *ServiceContext {
mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass)
redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"})
apiAuth := authlib.ApiAuthService{
Service: gateway.NewService(c.ApiAuth.Name, c.ApiAuth.Host, c.ApiAuth.Timeout),
}
return &ServiceContext{
Config: c,
DB: db,
Redis: redis,
Config: c,
DB: db,
Redis: redis,
ApiAuthService: apiAuth,
LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle,
CommentRepository: repository.NewCommentRepository(cache.NewCachedRepository(mlCache)),
ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)),
ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)),
... ...