作者 庄敏学

管理后台增加帖子草稿|已删除列表

正在显示 36 个修改的文件 包含 3746 行增加169 行删除
... ... @@ -333,6 +333,32 @@
]
}
},
"v1/mini/article_backup/{id}": {
"get": {
"summary": "小程序获取文章的编辑记录",
"operationId": "MiniGetArticleBackup",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniGetArticleBackupResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/mini/article_comment": {
"post": {
"summary": "小程序填写文章的评论",
... ... @@ -766,7 +792,7 @@
"v1/mini/homepage/user_beliked": {
"post": {
"summary": "个人主页-获赞的列表",
"operationId": "miniHomepageUserBeliked",
"operationId": "miniHomepageUserBeLiked",
"responses": {
"200": {
"description": "A successful response.",
... ... @@ -1722,6 +1748,58 @@
}
},
"v1/system/article": {
"delete": {
"summary": "管理后台删除文章",
"operationId": "SystemDeleteArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleDeleteResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
},
"post": {
"summary": "管理后台新增文章",
"operationId": "SystemCreateArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleCreateResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleCreateRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
},
"put": {
"summary": "管理后台编辑帖子",
"operationId": "SystemUpdateArticle",
... ... @@ -1750,6 +1828,196 @@
]
}
},
"v1/system/article/deleted/list": {
"post": {
"summary": "管理后台已删除列表",
"operationId": "SystemArticleSearchDeleted",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleSearchDeletedResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleSearchDeletedRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/deleted/restore": {
"put": {
"summary": "管理后台文章删除恢复",
"operationId": "SystemRestoreArticleDeleted",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleDeletedRestoreResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleDeletedRestoreRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/draft": {
"delete": {
"summary": "管理后台删除草稿",
"operationId": "SystemDeleteArticleDraft",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleDraftDeleteResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleDraftDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
},
"post": {
"summary": "管理后台新增草稿",
"operationId": "SystemCreateArticleDraft",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleDraftCreateResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleDraftCreateRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
},
"put": {
"summary": "管理后台编辑草稿",
"operationId": "SystemUpdateArticleDraft",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleDraftUpdateResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleDraftUpdateRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/draft/search": {
"post": {
"summary": "管理后台草稿列表",
"operationId": "SystemSearchArticleDraft",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleDraftSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleDraftSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/draft/{id}": {
"get": {
"summary": "管理后台获取草稿",
"operationId": "SystemGetArticleDraft",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleDraftGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/history": {
"post": {
"summary": "管理后台编辑历史",
... ... @@ -3808,12 +4076,31 @@
"type": "string"
}
},
"videos": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
}
},
"changeField": {
"type": "array",
"items": {
"type": "string"
}
},
"createdAt": {
"type": "integer",
"format": "int64"
},
"location": {
"$ref": "#/definitions/Location"
},
"action": {
"type": "string"
},
"show": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniArticleBackupItem",
... ... @@ -3822,8 +4109,12 @@
"title",
"content",
"images",
"videos",
"changeField",
"createdAt",
"location"
"location",
"action",
"show"
]
},
"MiniArticleBackupSearchRequest": {
... ... @@ -4991,7 +5282,7 @@
"type": "object",
"title": "MiniEditUserInfoResponse"
},
"MiniGetArticleCommentRequest": {
"MiniGetArticleBackupRequest": {
"type": "object",
"properties": {
"id": {
... ... @@ -5000,14 +5291,92 @@
},
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
"format": "int64",
"description": " 服务端自动获取"
}
},
"title": "MiniGetArticleCommentRequest",
"title": "MiniGetArticleBackupRequest",
"required": [
"id"
]
},
"MiniGetArticleBackupResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"title": {
"type": "string"
},
"content": {
"type": "string"
},
"images": {
"type": "array",
"items": {
"type": "string"
}
},
"videos": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
}
},
"changeField": {
"type": "array",
"items": {
"type": "string"
}
},
"createdAt": {
"type": "integer",
"format": "int64"
},
"location": {
"$ref": "#/definitions/Location"
},
"action": {
"type": "string"
},
"show": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniGetArticleBackupResponse",
"required": [
"id",
"title",
"content",
"images",
"videos",
"changeField",
"createdAt",
"location",
"action",
"show"
]
},
"MiniGetArticleCommentRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniGetArticleCommentRequest",
"required": [
"id"
]
... ... @@ -5114,6 +5483,9 @@
"size": {
"type": "integer",
"format": "int32"
},
"name": {
"type": "string"
}
},
"title": "MiniHomePageUserFollowerSearchRequest",
... ... @@ -5210,10 +5582,14 @@
"format": "int32",
"description": " 数量"
},
"orderByHotScore": {
"orderByKey": {
"type": "string",
"default": "desc",
"description": " 热度排序 升序 asc 降序 desc"
"description": " 按规则排序 (热度:HotScore All:时间排序 Time:时间排序)"
},
"orderByValue": {
"type": "string",
"description": " 排序值 升序 asc 降序 desc"
},
"keywords": {
"type": "string",
... ... @@ -5224,7 +5600,7 @@
"format": "int64",
"description": " 开始时间"
},
"beginTime": {
"endTime": {
"type": "integer",
"format": "int64",
"description": " 结束时间"
... ... @@ -5234,7 +5610,8 @@
"required": [
"authorId",
"size",
"orderByHotScore"
"orderByKey",
"orderByValue"
]
},
"MiniHomepageUserNewsResposne": {
... ... @@ -5250,12 +5627,17 @@
"type": "integer",
"format": "int64",
"description": " 最后文章ID"
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniHomepageUserNewsResposne",
"required": [
"list",
"lastArticleId"
"lastArticleId",
"total"
]
},
"MiniListArticleCommentRequest": {
... ... @@ -6080,6 +6462,25 @@
"comment"
]
},
"Operator": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 人员id"
},
"name": {
"type": "string",
"description": " 人员的名字"
}
},
"title": "Operator",
"required": [
"id",
"name"
]
},
"Position": {
"type": "object",
"properties": {
... ... @@ -6664,65 +7065,40 @@
"list"
]
},
"SystemArticleGetHistoryRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"": {
"type": "integer",
"format": "int64"
}
},
"title": "SystemArticleGetHistoryRequest",
"required": [
"id"
]
},
"SystemArticleGetHistoryResponse": {
"SystemArticleCreateRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " id"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章ID"
},
"title": {
"type": "string",
"description": " 标题"
"description": "标题"
},
"createdAt": {
"content": {
"type": "string",
"description": "文章的文本内容"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": " 文章的发布时间"
},
"section": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSection"
},
"description": " 文章的文本内容"
"description": "发布人id"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": " 图片"
"description": "图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
}
},
"description": " 视频"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"whoRead": {
"type": "array",
... ... @@ -6730,14 +7106,7 @@
"type": "integer",
"format": "int64"
},
"description": " 谁可查看"
},
"whoReadInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/UserShowName"
},
"description": " 谁可查看"
"description": "谁可查看"
},
"whoReview": {
"type": "array",
... ... @@ -6745,52 +7114,33 @@
"type": "integer",
"format": "int64"
},
"description": " 谁可评论"
},
"whoReviewInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/UserShowName"
},
"description": " 谁可评论"
"description": "谁可评论"
},
"location": {
"$ref": "#/definitions/Location",
"description": " 定位坐标"
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
},
"targetUser": {
"articleDraftId": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
"format": "int64",
"description": " 草稿ID"
},
"tags": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签"
"AccessToken": {
"type": "string",
"description": " 授权token"
}
},
"title": "SystemArticleGetHistoryResponse",
"title": "SystemArticleCreateRequest",
"required": [
"id",
"articleId",
"title",
"createdAt",
"section",
"images",
"video",
"whoRead",
"whoReadInfo",
"whoReview",
"whoReviewInfo",
"location",
"content",
"authorId",
"targetUser",
"tags"
"articleDraftId",
"x-mmm-accesstoken"
]
},
"SystemArticleGetRequest": {
"SystemArticleCreateResponse": {
"type": "object",
"properties": {
"id": {
... ... @@ -6798,46 +7148,942 @@
"format": "int64",
"description": "id"
},
"": {
"type": "integer",
"format": "int64"
}
},
"title": "SystemArticleGetRequest",
"required": [
"id"
]
},
"SystemArticleGetResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " id"
},
"title": {
"type": "string",
"description": " 标题"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": " 发布人id"
"description": "标题"
},
"author": {
"$ref": "#/definitions/ArticleAuthor",
"description": " 发布人"
"content": {
"type": "string",
"description": "文章的文本内容"
},
"createdAt": {
"authorId": {
"type": "integer",
"format": "int64",
"description": " 文章的发布时间"
"description": "发布人id"
},
"section": {
"images": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSection"
"type": "string"
},
"description": "图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
}
},
"title": "SystemArticleCreateResponse",
"required": [
"id",
"title",
"content",
"targetUser",
"matchUrl"
]
},
"SystemArticleDeleteRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
}
},
"title": "SystemArticleDeleteRequest",
"required": [
"id"
]
},
"SystemArticleDeleteResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"title": {
"type": "string",
"description": "标题"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
}
},
"title": "SystemArticleDeleteResponse",
"required": [
"id",
"title"
]
},
"SystemArticleDeletedRestoreRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
}
},
"title": "SystemArticleDeletedRestoreRequest",
"required": [
"id"
]
},
"SystemArticleDeletedRestoreResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
},
"title": {
"type": "string",
"description": "标题"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
}
},
"title": "SystemArticleDeletedRestoreResponse",
"required": [
"id",
"title",
"authorId"
]
},
"SystemArticleDraftCreateRequest": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "标题"
},
"content": {
"type": "string",
"description": "文章的文本内容"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
},
"tags": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签"
},
"AccessToken": {
"type": "string",
"description": " 授权token"
}
},
"title": "SystemArticleDraftCreateRequest",
"required": [
"title",
"content",
"authorId",
"targetUser",
"tags",
"x-mmm-accesstoken"
]
},
"SystemArticleDraftCreateResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
},
"title": {
"type": "string",
"description": "标题"
},
"content": {
"type": "string",
"description": "文章的文本内容"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
},
"tags": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签"
}
},
"title": "SystemArticleDraftCreateResponse",
"required": [
"id",
"title",
"content",
"authorId",
"targetUser",
"tags"
]
},
"SystemArticleDraftDeleteRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
}
},
"title": "SystemArticleDraftDeleteRequest",
"required": [
"id"
]
},
"SystemArticleDraftDeleteResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
},
"title": {
"type": "string",
"description": "标题"
},
"content": {
"type": "string",
"description": "文章的文本内容"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
},
"tags": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签"
}
},
"title": "SystemArticleDraftDeleteResponse",
"required": [
"id",
"title",
"content",
"authorId",
"targetUser",
"tags"
]
},
"SystemArticleDraftGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"": {
"type": "integer",
"format": "int64",
"description": "公司ID(前端不传)"
}
},
"title": "SystemArticleDraftGetRequest",
"required": [
"id"
]
},
"SystemArticleDraftGetResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
},
"title": {
"type": "string",
"description": "标题"
},
"content": {
"type": "string",
"description": "文章的文本内容"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
},
"tags": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签"
}
},
"title": "SystemArticleDraftGetResponse",
"required": [
"id",
"title",
"content",
"authorId",
"targetUser",
"tags"
]
},
"SystemArticleDraftSearch": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
},
"title": {
"type": "string",
"description": "标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"operator": {
"type": "string",
"description": "操作人"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"author": {
"type": "string",
"description": "发布人"
},
"updatedAt": {
"type": "integer",
"format": "int64",
"description": "编辑时间"
}
},
"title": "SystemArticleDraftSearch",
"required": [
"id",
"title",
"images",
"operator",
"authorId",
"author",
"updatedAt"
]
},
"SystemArticleDraftSearchRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32",
"description": "页码"
},
"size": {
"type": "integer",
"format": "int32",
"description": "每页行数"
},
"companyId": {
"type": "integer",
"format": "int64",
"description": "公司ID(前端不传)"
},
"title": {
"type": "string",
"description": "标题"
},
"operator": {
"type": "string",
"description": "编辑人"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": "开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": "结束时间"
}
},
"title": "SystemArticleDraftSearchRequest",
"required": [
"page",
"size"
]
},
"SystemArticleDraftSearchResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/SystemArticleDraftSearch"
}
}
},
"title": "SystemArticleDraftSearchResponse",
"required": [
"total",
"list"
]
},
"SystemArticleDraftUpdateRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " ID"
},
"title": {
"type": "string",
"description": "标题"
},
"content": {
"type": "string",
"description": "文章的文本内容"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
},
"tags": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签"
},
"AccessToken": {
"type": "string",
"description": " 授权token"
}
},
"title": "SystemArticleDraftUpdateRequest",
"required": [
"id",
"title",
"content",
"authorId",
"targetUser",
"tags",
"x-mmm-accesstoken"
]
},
"SystemArticleDraftUpdateResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
},
"title": {
"type": "string",
"description": "标题"
},
"content": {
"type": "string",
"description": "文章的文本内容"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
},
"tags": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签"
}
},
"title": "SystemArticleDraftUpdateResponse",
"required": [
"id",
"title",
"content",
"authorId",
"targetUser",
"tags"
]
},
"SystemArticleGetHistoryRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"": {
"type": "integer",
"format": "int64"
}
},
"title": "SystemArticleGetHistoryRequest",
"required": [
"id"
]
},
"SystemArticleGetHistoryResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " id"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章ID"
},
"title": {
"type": "string",
"description": " 标题"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": " 文章的发布时间"
},
"section": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSection"
},
"description": " 文章的文本内容"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": " 图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
}
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 谁可查看"
},
"whoReadInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/UserShowName"
},
"description": " 谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 谁可评论"
},
"whoReviewInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/UserShowName"
},
"description": " 谁可评论"
},
"location": {
"$ref": "#/definitions/Location",
"description": " 定位坐标"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"tags": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签"
}
},
"title": "SystemArticleGetHistoryResponse",
"required": [
"id",
"articleId",
"title",
"createdAt",
"section",
"images",
"video",
"whoRead",
"whoReadInfo",
"whoReview",
"whoReviewInfo",
"location",
"targetUser",
"tags"
]
},
"SystemArticleGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"": {
"type": "integer",
"format": "int64"
}
},
"title": "SystemArticleGetRequest",
"required": [
"id"
]
},
"SystemArticleGetResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " id"
},
"title": {
"type": "string",
"description": " 标题"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": " 发布人id"
},
"author": {
"$ref": "#/definitions/ArticleAuthor",
"description": " 发布人"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": " 文章的发布时间"
},
"section": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSection"
},
"description": " 文章的文本内容"
},
... ... @@ -7107,6 +8353,11 @@
"format": "int64",
"description": "文章的创建日期"
},
"updatedAt": {
"type": "integer",
"format": "int64",
"description": "文章的编辑日期"
},
"countLove": {
"type": "integer",
"format": "int32",
... ... @@ -7133,6 +8384,15 @@
"type": "integer",
"format": "int32",
"description": "分发方式 [0分发给所有人、1分发给指定的人]"
},
"operator": {
"$ref": "#/definitions/Operator",
"description": "运营操作人"
},
"source": {
"type": "integer",
"format": "int32",
"description": "来源[1用户发布、2运营发布]"
}
},
"title": "SystemArticleSearch",
... ... @@ -7143,11 +8403,134 @@
"author",
"images",
"createdAt",
"updatedAt",
"countLove",
"countComment",
"show",
"tags",
"targetUser"
"targetUser",
"operator",
"source"
]
},
"SystemArticleSearchDeletedItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "ID"
},
"title": {
"type": "string",
"description": "标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"author": {
"type": "string",
"description": "发布人"
},
"source": {
"type": "integer",
"format": "int32",
"description": "来源 1-用户发布 2-运营发布"
},
"deletedType": {
"type": "integer",
"format": "int32",
"description": "类型 1-运营删除 2-用户删除"
},
"deletedAt": {
"type": "integer",
"format": "int64",
"description": "删除时间"
}
},
"title": "SystemArticleSearchDeletedItem",
"required": [
"id",
"title",
"images",
"authorId",
"author",
"source",
"deletedType",
"deletedAt"
]
},
"SystemArticleSearchDeletedRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32",
"description": "页码"
},
"size": {
"type": "integer",
"format": "int32",
"description": "每页行数"
},
"title": {
"type": "string",
"description": "标题"
},
"author": {
"type": "integer",
"format": "int64",
"description": "发布人"
},
"deletedType": {
"type": "integer",
"format": "int32",
"description": "类型 1-运营删除 2-用户删除"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": "开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": "结束时间"
}
},
"title": "SystemArticleSearchDeletedRequest",
"required": [
"page",
"size"
]
},
"SystemArticleSearchDeletedResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/SystemArticleSearchDeletedItem"
}
}
},
"title": "SystemArticleSearchDeletedResponse",
"required": [
"total",
"list"
]
},
"SystemArticleSearchMeRequest": {
... ... @@ -7247,6 +8630,10 @@
"type": "integer",
"format": "int32",
"description": "每页行数"
},
"orderMode": {
"type": "string",
"description": "排序方式"
}
},
"title": "SystemArticleSearchRequest",
... ... @@ -7353,7 +8740,6 @@
"title": "SystemArticleUpdateRequest",
"required": [
"id",
"template",
"section",
"title",
"images",
... ...
... ... @@ -121,4 +121,40 @@ service Core {
@doc "管理后台文章恢复"
@handler SystemArticleRestore
post /article/restore (SystemArticleRestoreRequest) returns (SystemArticleRestoreResponse)
@doc "管理后台删除文章"
@handler SystemDeleteArticle
delete /article (SystemArticleDeleteRequest) returns (SystemArticleDeleteResponse)
@doc "管理后台新增文章"
@handler SystemCreateArticle
post /article (SystemArticleCreateRequest) returns (SystemArticleCreateResponse)
@doc "管理后台新增草稿"
@handler SystemCreateArticleDraft
post /article/draft (SystemArticleDraftCreateRequest) returns (SystemArticleDraftCreateResponse)
@doc "管理后台编辑草稿"
@handler SystemUpdateArticleDraft
put /article/draft (SystemArticleDraftUpdateRequest) returns (SystemArticleDraftUpdateResponse)
@doc "管理后台草稿列表"
@handler SystemSearchArticleDraft
post /article/draft/search (SystemArticleDraftSearchRequest) returns (SystemArticleDraftSearchResponse)
@doc "管理后台删除草稿"
@handler SystemDeleteArticleDraft
delete /article/draft (SystemArticleDraftDeleteRequest) returns (SystemArticleDraftDeleteResponse)
@doc "管理后台获取草稿"
@handler SystemGetArticleDraft
get /article/draft/:id (SystemArticleDraftGetRequest) returns (SystemArticleDraftGetResponse)
@doc "管理后台已删除列表"
@handler SystemArticleSearchDeleted
post /article/deleted/list (SystemArticleSearchDeletedRequest) returns (SystemArticleSearchDeletedResponse)
@doc "管理后台文章删除恢复"
@handler SystemRestoreArticleDeleted
put /article/deleted/restore (SystemArticleDeletedRestoreRequest) returns (SystemArticleDeletedRestoreResponse)
}
\ No newline at end of file
... ...
... ... @@ -25,6 +25,11 @@ type ArticleAuthor {
Company string `json:"company"` // 公司
}
type Operator {
Id int64 `json:"id,string"`// 人员id
Name string `json:"name"` // 人员的名字
}
//小程序端创建发布文章
type (
MiniArticleCreateRequest {
... ... @@ -431,11 +436,14 @@ type (
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
UpdatedAt int64 `json:"updatedAt"` //文章的编辑日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"countComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
Operator Operator `json:"operator"` //运营操作人
Source int `json:"source"` //来源[1用户发布、2运营发布]
}
)
// 管理后台编辑文章
... ... @@ -469,6 +477,45 @@ type (
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
)
// 管理后台新增文章
type (
SystemArticleCreateRequest {
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
}
SystemArticleCreateResponse {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId,optional"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
)
//管理后台删除文章
type (
SystemArticleDeleteRequest {
Id int64 `json:"id"` //id
}
SystemArticleDeleteResponse {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
AuthorId int64 `json:"authorId,optional"` //发布人id
}
)
// 管理后台编辑历史列表
type (
//历史
... ... @@ -578,4 +625,171 @@ type (
CreatedAt int64 `json:"createdAt"`
MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读]
}
)
//后台新增文章草稿
type (
SystemArticleDraftCreateRequest {
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
}
SystemArticleDraftCreateResponse {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
}
)
//后台编辑文章草稿
type (
SystemArticleDraftUpdateRequest {
Id int64 `json:"id"` // ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
}
SystemArticleDraftUpdateResponse {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
}
)
//管理后台文章草稿列表
type (
SystemArticleDraftSearchRequest {
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
CompanyId int64 `json:"companyId,optional"` //公司ID(前端不传)
Title string `json:"title,optional"` //标题
Operator string `json:"operator,optional"` //编辑人
BeginTime int64 `json:"beginTime,optional"`//开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
}
SystemArticleDraftSearchResponse {
Total int `json:"total"`
List []SystemArticleDraftSearch `json:"list"`
}
SystemArticleDraftSearch {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
Operator string `json:"operator"` //操作人
AuthorId int64 `json:"authorId"` //发布人id
Author string `json:"author"` //发布人
UpdatedAt int64 `json:"updatedAt"` //编辑时间
}
)
//管理后台删除草稿
type (
SystemArticleDraftDeleteRequest {
Id int64 `json:"id"` //ID
}
SystemArticleDraftDeleteResponse {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
}
)
//管理后台获取草稿
type (
SystemArticleDraftGetRequest {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"` //公司ID(前端不传)
}
SystemArticleDraftGetResponse {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
}
)
//管理后台已删除列表
type (
SystemArticleSearchDeletedRequest {
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
Title string `json:"title,optional"` //标题
Author int64 `json:"author,optional"` //发布人
DeletedType int `json:"deletedType,optional"`//类型 1-运营删除 2-用户删除
BeginTime int64 `json:"beginTime,optional"`//开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
}
SystemArticleSearchDeletedResponse {
Total int `json:"total"`
List []SystemArticleSearchDeletedItem `json:"list"`
}
SystemArticleSearchDeletedItem {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
AuthorId int64 `json:"authorId"` //发布人id
Author string `json:"author"` //发布人
Source int `json:"source"` //来源 1-用户发布 2-运营发布
DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除
DeletedAt int64 `json:"deletedAt"` //删除时间
}
)
//管理后台已删除文章恢复
type (
SystemArticleDeletedRestoreRequest {
Id int64 `json:"id"` //ID
}
SystemArticleDeletedRestoreResponse {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
AuthorId int64 `json:"authorId"` //发布人id
}
)
\ No newline at end of file
... ...
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 SystemArticleSearchDeletedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleSearchDeletedRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemArticleSearchDeletedLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleSearchDeleted(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
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 SystemCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleDraftCreateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemCreateArticleDraftLogic(r.Context(), svcCtx)
resp, err := l.SystemCreateArticleDraft(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
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 SystemCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleCreateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemCreateArticleLogic(r.Context(), svcCtx)
resp, err := l.SystemCreateArticle(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
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 SystemDeleteArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleDraftDeleteRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemDeleteArticleDraftLogic(r.Context(), svcCtx)
resp, err := l.SystemDeleteArticleDraft(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
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 SystemDeleteArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleDeleteRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemDeleteArticleLogic(r.Context(), svcCtx)
resp, err := l.SystemDeleteArticle(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
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 SystemGetArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleDraftGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemGetArticleDraftLogic(r.Context(), svcCtx)
resp, err := l.SystemGetArticleDraft(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
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 SystemRestoreArticleDeletedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleDeletedRestoreRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemRestoreArticleDeletedLogic(r.Context(), svcCtx)
resp, err := l.SystemRestoreArticleDeleted(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
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 SystemSearchArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleDraftSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemSearchArticleDraftLogic(r.Context(), svcCtx)
resp, err := l.SystemSearchArticleDraft(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
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 SystemUpdateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleDraftUpdateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemUpdateArticleDraftLogic(r.Context(), svcCtx)
resp, err := l.SystemUpdateArticleDraft(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -598,6 +598,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article/restore",
Handler: article.SystemArticleRestoreHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article",
Handler: article.SystemDeleteArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article",
Handler: article.SystemCreateArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/draft",
Handler: article.SystemCreateArticleDraftHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article/draft",
Handler: article.SystemUpdateArticleDraftHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/draft/search",
Handler: article.SystemSearchArticleDraftHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article/draft",
Handler: article.SystemDeleteArticleDraftHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article/draft/:id",
Handler: article.SystemGetArticleDraftHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/deleted/list",
Handler: article.SystemArticleSearchDeletedHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article/deleted/restore",
Handler: article.SystemRestoreArticleDeletedHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
... ...
package article
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"
"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 SystemArticleSearchDeletedLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemArticleSearchDeletedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleSearchDeletedLogic {
return &SystemArticleSearchDeletedLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemArticleSearchDeletedLogic) SystemArticleSearchDeleted(req *types.SystemArticleSearchDeletedRequest) (resp *types.SystemArticleSearchDeletedResponse, err error) {
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
WithKV("isDel", 1).
WithKV("title", req.Title).
WithKV("authorId", req.Author).
WithKV("beginDeletedAt", req.BeginTime).
WithKV("endDeletedAt", req.EndTime).
WithKV("deletedType", req.DeletedType).
WithKV("orderMode", "deletedAt descending")
userToken := contextdata.GetUserTokenFromCtx(l.ctx)
total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.conn, userToken.CompanyId, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("搜索已删除列表异常", err)
}
resp = &types.SystemArticleSearchDeletedResponse{
Total: int(total),
List: make([]types.SystemArticleSearchDeletedItem, 0),
}
authorIds := make([]int64, 0)
lo.ForEach(articles, func(item *domain.Article, index int) {
authorIds = append(authorIds, item.AuthorId)
})
//查询用户数据,重新赋值更新用户名称
_, users, _ := l.svcCtx.UserRepository.Find(l.ctx, l.conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds))
lo.ForEach(articles, func(item *domain.Article, index int) {
//图片
images := make([]string, 0)
lo.ForEach(item.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
//发布人
author := item.Author.Name
for _, user := range users {
if user.Id == item.AuthorId {
author = user.Name
}
}
resp.List = append(resp.List, types.SystemArticleSearchDeletedItem{
Id: item.Id,
Title: item.Title,
Images: images,
AuthorId: item.AuthorId,
Author: author,
Source: item.Source,
DeletedType: item.DeletedType,
DeletedAt: item.DeletedAt,
})
})
return
}
... ...
package article
import (
"context"
"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/authlib"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"strconv"
"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 SystemCreateArticleDraftLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCreateArticleDraftLogic {
return &SystemCreateArticleDraftLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemCreateArticleDraftLogic) SystemCreateArticleDraft(req *types.SystemArticleDraftCreateRequest) (resp *types.SystemArticleDraftCreateResponse, err error) {
// 检查发布人
author, err := l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, req.AuthorId)
if err != nil {
return nil, xerr.NewErrMsgErr("创建草稿失败", err)
}
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.conn, author.CompanyId)
if err != nil {
return nil, xerr.NewErrMsgErr("创建草稿失败", err)
}
//图片
images, err := getImages(req.Images)
if err != nil {
return nil, xerr.NewErrMsg(err.Error())
}
//视频
videos, err := getVideos(req.Videos)
if err != nil {
return nil, xerr.NewErrMsg(err.Error())
}
userToken := contextdata.GetUserTokenFromCtx(l.ctx)
// 获取当前用户信息
userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken})
if err != nil {
return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err)
}
articleDraft := &domain.ArticleDraftOperation{
CompanyId: companyInfo.Id,
AuthorId: req.AuthorId,
Title: req.Title,
Content: req.Content,
Images: images,
Videos: videos,
TargetUser: domain.ArticleTarget(req.TargetUser),
WhoRead: req.WhoRead,
WhoReview: req.WhoReview,
MatchUrl: req.MatchUrl,
Source: domain.ArticleSourceOperator,
Operator: domain.Operator{
Id: userToken.UserId,
Name: userMe.User.NickName,
},
Tags: req.Tags,
}
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err := l.svcCtx.ArticleDraftOperationRepository.Insert(ctx, conn, articleDraft)
if err != nil {
return err
}
return nil
}, true)
resp = &types.SystemArticleDraftCreateResponse{
Id: articleDraft.Id,
Title: articleDraft.Title,
Content: articleDraft.Content,
AuthorId: articleDraft.AuthorId,
Images: req.Images,
Videos: req.Videos,
TargetUser: req.TargetUser,
WhoRead: req.WhoRead,
WhoReview: req.WhoReview,
MatchUrl: req.MatchUrl,
Tags: req.Tags,
}
return
}
// getImages 获取图片信息
func getImages(imgs []string) ([]domain.Image, error) {
// 获取图片的尺寸大小
images := make([]domain.Image, 0)
if len(imgs) <= 0 {
return images, nil
}
for _, val := range imgs {
fInfo, err := oss.GetImageInfo(val)
if err != nil {
return images, xerr.NewErrMsg("获取图片失败")
}
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
images = append(images, domain.Image{
Url: val,
Width: w,
Height: h,
})
}
return images, nil
}
// getVideos 获取视频信息
func getVideos(list []types.Video) ([]domain.Video, error) {
videos := make([]domain.Video, 0)
if len(list) <= 0 {
return videos, nil
}
if len(list) > 0 {
for _, item := range list {
cover, w, h, err := oss.GetVideoCover(item.Url)
if err != nil {
return videos, xerr.NewErrMsg("获取视频信息失败")
}
videos = append(videos, domain.Video{
Url: item.Url,
Cover: cover,
Width: w,
Height: h,
})
}
}
return videos, nil
}
... ...
package article
import (
"context"
"github.com/pkg/errors"
"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/cmd/discuss/interanl/pkg/gateway/authlib"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"strconv"
"strings"
"unicode/utf8"
"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 SystemCreateArticleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCreateArticleLogic {
return &SystemCreateArticleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemCreateArticleLogic) SystemCreateArticle(req *types.SystemArticleCreateRequest) (resp *types.SystemArticleCreateResponse, err error) {
err = l.validate(req)
if err != nil {
return nil, xerr.NewErrMsg(err.Error())
}
// 检查发布人
author, err := l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, req.AuthorId)
if err != nil {
return nil, xerr.NewErrMsgErr("创建文章内容失败", err)
}
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.conn, author.CompanyId)
if err != nil {
return nil, xerr.NewErrMsgErr("创建文章内容失败", err)
}
//文章作者
articleAuthor := domain.UserSimple{
Id: author.Id,
Name: author.Name,
Avatar: author.Avatar,
Position: author.Position,
Company: companyInfo.Name,
CompanyId: author.CompanyId,
}
//图片
images, err := l.getImages(req)
if err != nil {
return nil, xerr.NewErrMsg(err.Error())
}
//视频
videos, err := l.getVideos(req)
if err != nil {
return nil, xerr.NewErrMsg(err.Error())
}
userToken := contextdata.GetUserTokenFromCtx(l.ctx)
// 获取当前用户信息
userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken})
if err != nil {
return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err)
}
article := &domain.Article{
CompanyId: companyInfo.Id,
AuthorId: req.AuthorId,
Author: articleAuthor,
Title: req.Title,
Images: images,
Videos: videos,
WhoRead: make([]int64, 0),
WhoReview: make([]int64, 0),
Location: domain.Location{},
TargetUser: domain.ArticleTarget(req.TargetUser),
Show: domain.ArticleShowEnable,
Tags: make([]int64, 0),
MatchUrl: make(map[string]string),
Source: domain.ArticleSourceOperator,
Operator: domain.Operator{
Id: userToken.UserId,
Name: userMe.User.NickName,
},
}
if len(req.MatchUrl) > 0 {
article.MatchUrl = req.MatchUrl
}
//检查文章可被哪些人查看
whoRead, err := l.validateAndGetWhoRead(req, article)
if err != nil {
return nil, err
}
//检查文章可被哪些人评论
whoReview := []int64{}
if len(req.WhoReview) > 0 {
whoReview = lo.Uniq(req.WhoReview)
}
//验证可评论
if err = l.validateWhoReview(whoRead, whoReview, article); err != nil {
return nil, err
}
article.WhoRead = whoRead
article.WhoReview = whoReview
sections := l.getSections(req, article)
//设置内容摘要
article.SetSummary(sections)
//草稿ID
if req.ArticleDraftId > 0 {
articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.ArticleDraftId)
if err != nil {
return nil, xerr.NewErrMsg("草稿不存在")
}
if articleDraft.CompanyId != userToken.CompanyId {
return nil, xerr.NewErrMsg("您没有权限")
}
}
//保存数据
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err = l.svcCtx.ArticleRepository.Insert(ctx, conn, article)
if err != nil {
return xerr.NewErrMsgErr("创建文章失败", err)
}
for i := range sections {
sections[i].ArticleId = article.Id
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, conn, sections[i])
if err != nil {
return xerr.NewErrMsgErr("创建文章内容失败", err)
}
}
// 生成 备份数据
var backupData domain.ArticleBackup
backupData.MakeBackup(articleAuthor, article, sections, "原始版本")
_, err = l.svcCtx.ArticleBackupRepository.Insert(l.ctx, conn, &backupData)
if err != nil {
return xerr.NewErrMsgErr("创建文章失败", err)
}
//删除草稿
if req.ArticleDraftId > 0 {
_, err = l.svcCtx.ArticleDraftOperationRepository.Delete(l.ctx, conn, &domain.ArticleDraftOperation{Id: req.ArticleDraftId})
if err != nil {
return xerr.NewErrMsg("删除草稿失败")
}
}
return nil
}, true)
if err != nil {
return nil, xerr.NewErrMsgErr("创建文章失败", err)
}
resp = &types.SystemArticleCreateResponse{
Id: article.Id,
Title: article.Title,
Content: req.Content,
AuthorId: req.AuthorId,
Images: req.Images,
Videos: req.Videos,
TargetUser: req.TargetUser,
WhoRead: whoRead,
WhoReview: whoReview,
}
return
}
// validate 验证
func (l *SystemCreateArticleLogic) validate(req *types.SystemArticleCreateRequest) error {
//文章标题
if utf8.RuneCountInString(req.Title) > 64 {
return errors.New("标题最多只能输入64字")
}
//文章内容
if utf8.RuneCountInString(req.Content) > 1000 {
return errors.New("内容最多只能输入1000字")
}
//图片
if len(req.Images) > 9 {
return errors.New("图片数量最多9张")
}
return nil
}
// getImages 获取图片信息
func (l *SystemCreateArticleLogic) getImages(req *types.SystemArticleCreateRequest) ([]domain.Image, error) {
// 获取图片的尺寸大小
images := make([]domain.Image, 0)
for _, val := range req.Images {
fInfo, err := oss.GetImageInfo(val)
if err != nil {
return images, xerr.NewErrMsg("获取图片失败")
}
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
images = append(images, domain.Image{
Url: val,
Width: w,
Height: h,
})
}
return images, nil
}
// getVideo 获取视频信息
func (l *SystemCreateArticleLogic) getVideos(req *types.SystemArticleCreateRequest) ([]domain.Video, error) {
videos := make([]domain.Video, 0)
if len(req.Videos) > 0 {
for _, item := range req.Videos {
cover, w, h, err := oss.GetVideoCover(item.Url)
if err != nil {
return videos, xerr.NewErrMsg("获取视频信息失败")
}
videos = append(videos, domain.Video{
Url: item.Url,
Cover: cover,
Width: w,
Height: h,
})
}
}
return videos, nil
}
// validateAndGetWhoRead 验证并获取可阅读
func (l *SystemCreateArticleLogic) validateAndGetWhoRead(req *types.SystemArticleCreateRequest, article *domain.Article) ([]int64, error) {
whoRead := make([]int64, 0)
if len(req.WhoRead) > 0 {
whoRead = lo.Uniq(req.WhoRead)
var u *domain.User
var err error
for _, val := range whoRead {
u, err = l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, val)
if err != nil {
return whoRead, xerr.NewErrMsgErr("文章可查看人设置错误", err)
}
if u.CompanyId != article.CompanyId {
return whoRead, xerr.NewErrMsg("文章可查看人设置错误")
}
}
}
return whoRead, nil
}
// validateWhoReview 验证可评论
func (l *SystemCreateArticleLogic) validateWhoReview(whoRead []int64, whoReview []int64, article *domain.Article) error {
//有指定可查看人的情况
if len(whoRead) > 0 {
if len(whoReview) > 0 {
// 检查 whoRead 是否 完全包含 whoReview
ok := lo.Every(whoRead, whoReview)
if !ok {
return xerr.NewErrMsg("文章可评论人设置错误")
}
}
if len(whoReview) == 0 {
//有指定可查看人 ,但未指定可评论人
return xerr.NewErrMsg("文章可评论人设置错误")
}
}
//没有指定可查看人的情况
if len(whoRead) == 0 {
if len(whoReview) > 0 {
// 未指定可查看人(全员可看),有指定可评论人,
var u *domain.User
var err error
for _, val := range whoReview {
u, err = l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, val)
if err != nil {
return xerr.NewErrMsgErr("文章可评论人设置错误", err)
}
if u.CompanyId != article.CompanyId {
return xerr.NewErrMsg("文章可评论人设置错误")
}
}
}
}
return nil
}
// getSections 文章内容
func (l *SystemCreateArticleLogic) getSections(req *types.SystemArticleCreateRequest, article *domain.Article) []*domain.ArticleSection {
articleSections := make([]*domain.ArticleSection, 0)
sortBy := 1
sections := strings.Split(req.Content, "\n")
lo.ForEach(sections, func(item string, index int) {
section := domain.ArticleSection{
CompanyId: article.CompanyId,
Version: article.Version,
ArticleId: article.Id,
Content: item,
SortBy: sortBy,
}
articleSections = append(articleSections, &section)
sortBy++
})
return articleSections
}
... ...
package article
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"
"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 SystemDeleteArticleDraftLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemDeleteArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteArticleDraftLogic {
return &SystemDeleteArticleDraftLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemDeleteArticleDraftLogic) SystemDeleteArticleDraft(req *types.SystemArticleDraftDeleteRequest) (resp *types.SystemArticleDraftDeleteResponse, err error) {
// 草稿数据
articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsg("草稿不存在")
}
//操作人
userToken := contextdata.GetUserTokenFromCtx(l.ctx)
if userToken.CompanyId != articleDraft.CompanyId {
return nil, xerr.NewErrMsg("您没有权限删除")
}
_, err = l.svcCtx.ArticleDraftOperationRepository.Delete(l.ctx, l.conn, articleDraft)
if err != nil {
return nil, xerr.NewErrMsg("删除草稿失败")
}
//图片
images := make([]string, 0)
lo.ForEach(articleDraft.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
//视频
videos := make([]types.Video, 0)
lo.ForEach(articleDraft.Videos, func(video domain.Video, n int) {
videos = append(videos, types.Video{
Url: video.Url,
Cover: video.Cover,
Width: video.Width,
Height: video.Height,
})
})
resp = &types.SystemArticleDraftDeleteResponse{
Id: articleDraft.Id,
Title: articleDraft.Title,
Content: articleDraft.Content,
AuthorId: articleDraft.AuthorId,
Images: images,
Videos: videos,
TargetUser: int(articleDraft.TargetUser),
WhoRead: articleDraft.WhoRead,
WhoReview: articleDraft.WhoReview,
MatchUrl: articleDraft.MatchUrl,
Tags: articleDraft.Tags,
}
return
}
... ...
package article
import (
"context"
"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"
"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 SystemDeleteArticleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemDeleteArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteArticleLogic {
return &SystemDeleteArticleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemDeleteArticleLogic) SystemDeleteArticle(req *types.SystemArticleDeleteRequest) (resp *types.SystemArticleDeleteResponse, err error) {
// 文章数据
article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, l.conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("帖子不存在", err)
}
userToken := contextdata.GetUserTokenFromCtx(l.ctx)
if userToken.CompanyId != article.CompanyId {
return nil, xerr.NewErrMsg("您没有权限")
}
article.DeletedType = domain.ArticleDeletedTypeOperator
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
//更新删除类型
_, err = l.svcCtx.ArticleRepository.Update(l.ctx, conn, article)
if err != nil {
return err
}
_, err = l.svcCtx.ArticleRepository.Delete(l.ctx, l.conn, article)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
return nil, xerr.NewErrMsgErr("删除失败", err)
}
resp = &types.SystemArticleDeleteResponse{
Id: article.Id,
Title: article.Title,
AuthorId: article.AuthorId,
}
return
}
... ...
package article
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"
"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 SystemGetArticleDraftLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemGetArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetArticleDraftLogic {
return &SystemGetArticleDraftLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemGetArticleDraftLogic) SystemGetArticleDraft(req *types.SystemArticleDraftGetRequest) (resp *types.SystemArticleDraftGetResponse, err error) {
// 草稿数据
articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsg("草稿不存在")
}
//操作人
userToken := contextdata.GetUserTokenFromCtx(l.ctx)
//不同公司不能获取数据
if userToken.CompanyId != articleDraft.CompanyId {
return nil, xerr.NewErrMsg("您没有权限查看该数据")
}
//图片
images := make([]string, 0)
lo.ForEach(articleDraft.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
//视频
videos := make([]types.Video, 0)
lo.ForEach(articleDraft.Videos, func(video domain.Video, n int) {
videos = append(videos, types.Video{
Url: video.Url,
Cover: video.Cover,
Width: video.Width,
Height: video.Height,
})
})
resp = &types.SystemArticleDraftGetResponse{
Id: articleDraft.Id,
Title: articleDraft.Title,
Content: articleDraft.Content,
AuthorId: articleDraft.AuthorId,
Images: images,
Videos: videos,
TargetUser: int(articleDraft.TargetUser),
WhoRead: articleDraft.WhoRead,
WhoReview: articleDraft.WhoReview,
MatchUrl: articleDraft.MatchUrl,
Tags: articleDraft.Tags,
}
return
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"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 SystemRestoreArticleDeletedLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemRestoreArticleDeletedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemRestoreArticleDeletedLogic {
return &SystemRestoreArticleDeletedLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemRestoreArticleDeletedLogic) SystemRestoreArticleDeleted(req *types.SystemArticleDeletedRestoreRequest) (resp *types.SystemArticleDeletedRestoreResponse, err error) {
// 文章数据
article, err := l.svcCtx.ArticleRepository.FindOneWithUnscoped(l.ctx, l.conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("帖子不存在", err)
}
_, err = l.svcCtx.ArticleRepository.Restore(l.ctx, l.conn, article)
if err != nil {
return nil, xerr.NewErrMsg("恢复帖子失败")
}
resp = &types.SystemArticleDeletedRestoreResponse{
Id: article.Id,
Title: article.Title,
AuthorId: article.AuthorId,
}
return
}
... ...
package article
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/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 SystemSearchArticleDraftLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemSearchArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemSearchArticleDraftLogic {
return &SystemSearchArticleDraftLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemSearchArticleDraftLogic) SystemSearchArticleDraft(req *types.SystemArticleDraftSearchRequest) (resp *types.SystemArticleDraftSearchResponse, err error) {
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
WithKV("companyId", req.CompanyId).
WithKV("title", req.Title).
WithKV("operator", req.Operator).
WithKV("beginTime", req.BeginTime).
WithKV("endTime", req.EndTime)
total, articleDrafts, err := l.svcCtx.ArticleDraftOperationRepository.Find(l.ctx, l.conn, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("搜索草稿异常", err)
}
resp = &types.SystemArticleDraftSearchResponse{
Total: int(total),
List: make([]types.SystemArticleDraftSearch, 0),
}
authorIds := make([]int64, 0)
lo.ForEach(articleDrafts, func(item *domain.ArticleDraftOperation, index int) {
authorIds = append(authorIds, item.AuthorId)
})
//查询用户数据,重新赋值更新用户名称
_, users, _ := l.svcCtx.UserRepository.Find(l.ctx, l.conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds))
lo.ForEach(articleDrafts, func(item *domain.ArticleDraftOperation, index int) {
//图片
images := make([]string, 0)
lo.ForEach(item.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
//发布人
author := ""
for _, user := range users {
if user.Id == item.AuthorId {
author = user.Name
}
}
resp.List = append(resp.List, types.SystemArticleDraftSearch{
Id: item.Id,
Title: item.Title,
Images: images,
Operator: item.Operator.Name,
AuthorId: item.AuthorId,
Author: author,
UpdatedAt: item.UpdatedAt,
})
})
return
}
... ...
... ... @@ -82,11 +82,17 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
Author: author,
Images: images,
CreatedAt: item.CreatedAt,
UpdatedAt: item.UpdatedAt,
CountLove: item.CountLove,
CountComment: item.CountComment,
Show: int(item.Show),
Tags: articleTags,
TargetUser: int(item.TargetUser),
Source: item.Source,
Operator: types.Operator{
Id: item.Operator.Id,
Name: item.Operator.Name,
},
})
})
return
... ...
package article
import (
"context"
"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/authlib"
"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 SystemUpdateArticleDraftLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
conn transaction.Conn
}
func NewSystemUpdateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUpdateArticleDraftLogic {
return &SystemUpdateArticleDraftLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
conn: svcCtx.DefaultDBConn(),
}
}
func (l *SystemUpdateArticleDraftLogic) SystemUpdateArticleDraft(req *types.SystemArticleDraftUpdateRequest) (resp *types.SystemArticleDraftUpdateResponse, err error) {
// 草稿数据
articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("草稿不存在", err)
}
articleDraft.Title = req.Title
articleDraft.Content = req.Content
articleDraft.AuthorId = req.AuthorId
articleDraft.TargetUser = domain.ArticleTarget(req.TargetUser)
articleDraft.WhoRead = req.WhoRead
articleDraft.WhoReview = req.WhoReview
articleDraft.Tags = req.Tags
articleDraft.Source = domain.ArticleSourceOperator
articleDraft.MatchUrl = req.MatchUrl
//图片
images, err := getImages(req.Images)
if err != nil {
return nil, xerr.NewErrMsg(err.Error())
}
articleDraft.Images = images
//视频
videos, err := getVideos(req.Videos)
if err != nil {
return nil, xerr.NewErrMsg(err.Error())
}
articleDraft.Videos = videos
//操作人
userToken := contextdata.GetUserTokenFromCtx(l.ctx)
// 获取当前用户信息
userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken})
if err != nil {
return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err)
}
articleDraft.Operator = domain.Operator{
Id: userToken.UserId,
Name: userMe.User.NickName,
}
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err := l.svcCtx.ArticleDraftOperationRepository.Update(ctx, conn, articleDraft)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
return nil, xerr.NewErrMsg("保存草稿失败")
}
resp = &types.SystemArticleDraftUpdateResponse{
Id: articleDraft.Id,
Title: articleDraft.Title,
Content: articleDraft.Content,
AuthorId: articleDraft.AuthorId,
Images: req.Images,
Videos: req.Videos,
TargetUser: int(articleDraft.TargetUser),
WhoRead: articleDraft.WhoRead,
WhoReview: articleDraft.WhoReview,
MatchUrl: articleDraft.MatchUrl,
Tags: articleDraft.Tags,
}
return
}
... ...
... ... @@ -27,13 +27,14 @@ type ServiceContext struct {
DB *gorm.DB
Redis *redis.Redis
ArticleBackupRepository domain.ArticleBackupRepository
ArticleCommentRepository domain.ArticleCommentRepository
ArticleDraftRepository domain.ArticleDraftRepository
ArticleRepository domain.ArticleRepository
ArticleSectionRepository domain.ArticleSectionRepository
ArticleTagRepository domain.ArticleTagRepository
ArticleAndTagRepository domain.ArticleAndTagRepository
ArticleBackupRepository domain.ArticleBackupRepository
ArticleCommentRepository domain.ArticleCommentRepository
ArticleDraftRepository domain.ArticleDraftRepository
ArticleRepository domain.ArticleRepository
ArticleSectionRepository domain.ArticleSectionRepository
ArticleTagRepository domain.ArticleTagRepository
ArticleAndTagRepository domain.ArticleAndTagRepository
ArticleDraftOperationRepository domain.ArticleDraftOperationRepository
CompanyRepository domain.CompanyRepository
DepartmentRepository domain.DepartmentRepository
... ... @@ -81,12 +82,13 @@ func NewServiceContext(c config.Config) *ServiceContext {
LogRequest: middleware.NewLogRequestMiddleware(c.LogRequest).Handle,
MiniProgram: miniProgram,
ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)),
ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)),
ArticleDraftRepository: repository.NewArticleDraftRepository(cache.NewCachedRepository(mlCache)),
ArticleRepository: repository.NewArticleRepository(cache.NewCachedRepository(mlCache)),
ArticleSectionRepository: repository.NewArticleSectionRepository(cache.NewCachedRepository(mlCache)),
ArticleAndTagRepository: repository.NewArticleAndTagRepository(cache.NewCachedRepository(mlCache)),
ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)),
ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)),
ArticleDraftRepository: repository.NewArticleDraftRepository(cache.NewCachedRepository(mlCache)),
ArticleRepository: repository.NewArticleRepository(cache.NewCachedRepository(mlCache)),
ArticleSectionRepository: repository.NewArticleSectionRepository(cache.NewCachedRepository(mlCache)),
ArticleAndTagRepository: repository.NewArticleAndTagRepository(cache.NewCachedRepository(mlCache)),
ArticleDraftOperationRepository: repository.NewArticleDraftOperationRepository(cache.NewCachedRepository(mlCache)),
CompanyRepository: repository.NewCompanyRepository(cache.NewCachedRepository(mlCache)),
DepartmentRepository: repository.NewDepartmentRepository(cache.NewCachedRepository(mlCache)),
... ...
... ... @@ -895,6 +895,11 @@ type ArticleAuthor struct {
Company string `json:"company"` // 公司
}
type Operator struct {
Id int64 `json:"id,string"` // 人员id
Name string `json:"name"` // 人员的名字
}
type MiniArticleCreateRequest struct {
Title string `json:"title"` //标题
Section []string `json:"section"` //文章的文本内容
... ... @@ -1263,11 +1268,14 @@ type SystemArticleSearch struct {
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
UpdatedAt int64 `json:"updatedAt"` //文章的编辑日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"countComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
Operator Operator `json:"operator"` //运营操作人
Source int `json:"source"` //来源[1用户发布、2运营发布]
}
type SystemArticleUpdateRequest struct {
... ... @@ -1299,6 +1307,43 @@ type SystemArticleUpdateResponse struct {
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type SystemArticleCreateRequest struct {
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
}
type SystemArticleCreateResponse struct {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId,optional"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
}
type SystemArticleDeleteRequest struct {
Id int64 `json:"id"` //id
}
type SystemArticleDeleteResponse struct {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
AuthorId int64 `json:"authorId,optional"` //发布人id
}
type SystemArticleHistoryRequest struct {
ArticleId int64 `json:"articleId"` //文章ID
Author string `json:"author,optional"` //发布人
... ... @@ -1401,6 +1446,161 @@ type MiniSearchArticleItem struct {
MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读]
}
type SystemArticleDraftCreateRequest struct {
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
}
type SystemArticleDraftCreateResponse struct {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
}
type SystemArticleDraftUpdateRequest struct {
Id int64 `json:"id"` // ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
}
type SystemArticleDraftUpdateResponse struct {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
}
type SystemArticleDraftSearchRequest struct {
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
CompanyId int64 `json:"companyId,optional"` //公司ID(前端不传)
Title string `json:"title,optional"` //标题
Operator string `json:"operator,optional"` //编辑人
BeginTime int64 `json:"beginTime,optional"` //开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
}
type SystemArticleDraftSearchResponse struct {
Total int `json:"total"`
List []SystemArticleDraftSearch `json:"list"`
}
type SystemArticleDraftSearch struct {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
Operator string `json:"operator"` //操作人
AuthorId int64 `json:"authorId"` //发布人id
Author string `json:"author"` //发布人
UpdatedAt int64 `json:"updatedAt"` //编辑时间
}
type SystemArticleDraftDeleteRequest struct {
Id int64 `json:"id"` //ID
}
type SystemArticleDraftDeleteResponse struct {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
}
type SystemArticleDraftGetRequest struct {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"` //公司ID(前端不传)
}
type SystemArticleDraftGetResponse struct {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Content string `json:"content"` //文章的文本内容
AuthorId int64 `json:"authorId"` //发布人id
Images []string `json:"images,optional"` //图片
Videos []Video `json:"video,optional"` // 视频
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
}
type SystemArticleSearchDeletedRequest struct {
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
Title string `json:"title,optional"` //标题
Author int64 `json:"author,optional"` //发布人
DeletedType int `json:"deletedType,optional"` //类型 1-运营删除 2-用户删除
BeginTime int64 `json:"beginTime,optional"` //开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
}
type SystemArticleSearchDeletedResponse struct {
Total int `json:"total"`
List []SystemArticleSearchDeletedItem `json:"list"`
}
type SystemArticleSearchDeletedItem struct {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
AuthorId int64 `json:"authorId"` //发布人id
Author string `json:"author"` //发布人
Source int `json:"source"` //来源 1-用户发布 2-运营发布
DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除
DeletedAt int64 `json:"deletedAt"` //删除时间
}
type SystemArticleDeletedRestoreRequest struct {
Id int64 `json:"id"` //ID
}
type SystemArticleDeletedRestoreResponse struct {
Id int64 `json:"id"` //ID
Title string `json:"title"` //标题
AuthorId int64 `json:"authorId"` //发布人id
}
type RoleGetRequest struct {
Id int64 `path:"id"`
}
... ...
syntax = "v1"
info(
title: "xx实例"
desc: "xx实例"
author: "author"
email: "email"
version: "v1"
)
@server(
prefix: article_draft_operation/v1
group: article_draft_operation
jwt: JwtAuth
)
service Core {
@handler getArticleDraftOperation
post /article_draft_operation/:id (ArticleDraftOperationGetRequest) returns (ArticleDraftOperationGetResponse)
@handler saveArticleDraftOperation
post /article_draft_operation (ArticleDraftOperationSaveRequest) returns (ArticleDraftOperationSaveResponse)
@handler deleteArticleDraftOperation
delete /article_draft_operation/:id (ArticleDraftOperationDeleteRequest) returns (ArticleDraftOperationDeleteResponse)
@handler updateArticleDraftOperation
put /article_draft_operation/:id (ArticleDraftOperationUpdateRequest) returns (ArticleDraftOperationUpdateResponse)
@handler searchArticleDraftOperation
post /article_draft_operation/search (ArticleDraftOperationSearchRequest) returns (ArticleDraftOperationSearchResponse)
}
type (
ArticleDraftOperationGetRequest {
Id int64 `path:"id"`
}
ArticleDraftOperationGetResponse struct{
ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"`
}
ArticleDraftOperationSaveRequest struct{
ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"`
}
ArticleDraftOperationSaveResponse struct{}
ArticleDraftOperationDeleteRequest struct{
Id int64 `path:"id"`
}
ArticleDraftOperationDeleteResponse struct{}
ArticleDraftOperationUpdateRequest struct{
Id int64 `path:"id"`
ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"`
}
ArticleDraftOperationUpdateResponse struct{}
ArticleDraftOperationSearchRequest struct{
Page int `json:"page"`
Size int `json:"size"`
}
ArticleDraftOperationSearchResponse{
List []ArticleDraftOperationItem `json:"list"`
Total int64 `json:"total"`
}
ArticleDraftOperationItem struct{
}
)
... ...
syntax = "proto3";
option go_package ="./pb";
package pb;
message ArticleDraftOperationGetReq {
int64 Id = 1;
}
message ArticleDraftOperationGetResp{
ArticleDraftOperationItem User = 1;
}
message ArticleDraftOperationSaveReq {
}
message ArticleDraftOperationSaveResp{
}
message ArticleDraftOperationDeleteReq {
int64 Id = 1;
}
message ArticleDraftOperationDeleteResp{
}
message ArticleDraftOperationUpdateReq {
int64 Id = 1;
}
message ArticleDraftOperationUpdateResp{
}
message ArticleDraftOperationSearchReq {
int64 PageNumber = 1;
int64 PageSize = 2;
}
message ArticleDraftOperationSearchResp{
repeated ArticleDraftOperationItem List =1;
int64 Total =2;
}
message ArticleDraftOperationItem {
}
service ArticleDraftOperationService {
rpc ArticleDraftOperationGet(ArticleDraftOperationGetReq) returns(ArticleDraftOperationGetResp);
rpc ArticleDraftOperationSave(ArticleDraftOperationSaveReq) returns(ArticleDraftOperationSaveResp);
rpc ArticleDraftOperationDelete(ArticleDraftOperationDeleteReq) returns(ArticleDraftOperationDeleteResp);
rpc ArticleDraftOperationUpdate(ArticleDraftOperationUpdateReq) returns(ArticleDraftOperationUpdateResp);
rpc ArticleDraftOperationSearch(ArticleDraftOperationSearchReq) returns(ArticleDraftOperationSearchResp);
}
... ...
... ... @@ -24,6 +24,7 @@ func Migrate(db *gorm.DB) {
&models.MessageBusiness{},
&models.Department{},
&models.ArticleAndTag{},
&models.ArticleDraftOperation{},
}
db.AutoMigrate(modelsList...)
... ...
... ... @@ -2,11 +2,10 @@ package models
import (
"fmt"
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
"gorm.io/plugin/soft_delete"
"time"
)
type Article struct {
... ... @@ -33,6 +32,9 @@ type Article struct {
Show int // 评论的展示状态(1显示、2不显示)
Summary string // 内容概要
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
Source int `gorm:"default:1"` // 来源 1-用户发布 2-运营发布
Operator domain.Operator `gorm:"type:jsonb;serializer:json"` // 运营操作人
DeletedType int `json:"deletedType"` // 删除类型 1-运营删除 2-用户删除
}
func (m *Article) TableName() string {
... ...
package models
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
"gorm.io/plugin/soft_delete"
"time"
)
// ArticleDraftOperation 运营草稿
type ArticleDraftOperation struct {
Id int64 `gorm:"primaryKey"` // 唯一标识
CompanyId int64 `gorm:"comment:公司ID"` // 公司ID
AuthorId int64 `gorm:"comment:发布人ID"` // 发布人
Title string `gorm:"comment:标题"` // 文章标题
Content string `json:"content"` // 文章内容
Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频
TargetUser domain.ArticleTarget `gorm:"comment:分发方式 0所有人 1指定人"` // 分发方式 0 分发给所有人 1 分发给指定的人
WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
Source int `gorm:"default:1"` // 来源 1-用户发布 2-运营发布
Operator domain.Operator `gorm:"type:jsonb;serializer:json"` // 运营操作人
Version int `gorm:"comment:版本号"` // 版本号
CreatedAt int64 `gorm:"comment:创建时间"` // 创建时间
UpdatedAt int64 `gorm:"comment:编辑时间"` // 编辑时间
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` // 删除标记
DeletedAt int64 `gorm:"comment:删除时间"` // 删除时间
}
func (m *ArticleDraftOperation) TableName() string {
return "article_draft_operation"
}
func (m *ArticleDraftOperation) BeforeCreate(tx *gorm.DB) (err error) {
nowTime := time.Now().Unix()
m.CreatedAt = nowTime
m.UpdatedAt = nowTime
return
}
func (m *ArticleDraftOperation) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now().Unix()
m.Version += 1
return
}
func (m *ArticleDraftOperation) CacheKeyFunc() string {
if m.Id == 0 {
return ""
}
return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id)
}
func (m *ArticleDraftOperation) CacheKeyFuncByObject(obj interface{}) string {
if v, ok := obj.(*ArticleDraftOperation); ok {
return v.CacheKeyFunc()
}
return ""
}
func (m *ArticleDraftOperation) CachePrimaryKeyFunc() string {
if len("") == 0 {
return ""
}
return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
}
... ...
package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
"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"
"gorm.io/gorm"
)
type ArticleDraftOperationRepository struct {
*cache.CachedRepository
}
func (repository *ArticleDraftOperationRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) {
var (
err error
m = &models.ArticleDraftOperation{}
tx = conn.DB()
)
if m, err = repository.DomainModelToModel(dm); err != nil {
return nil, err
}
if tx = tx.Model(m).Save(m); tx.Error != nil {
return nil, tx.Error
}
dm.Id = m.Id
return repository.ModelToDomainModel(m)
}
func (repository *ArticleDraftOperationRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) {
var (
err error
m *models.ArticleDraftOperation
tx = conn.DB()
)
if m, err = repository.DomainModelToModel(dm); err != nil {
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleDraftOperationRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) {
var (
err error
m *models.ArticleDraftOperation
tx = transaction.DB()
)
if m, err = repository.DomainModelToModel(dm); err != nil {
return nil, err
}
oldVersion := dm.Version
m.Version += 1
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m)
if tx.RowsAffected == 0 {
return nil, domain.ErrUpdateFail
}
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleDraftOperationRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) {
var (
tx = conn.DB()
m = &models.ArticleDraftOperation{Id: dm.Identify().(int64)}
)
queryFunc := func() (interface{}, error) {
tx = tx.Where("id = ?", m.Id).Delete(m)
return m, tx.Error
}
if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return dm, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleDraftOperationRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleDraftOperation, error) {
var (
err error
tx = conn.DB()
m = new(models.ArticleDraftOperation)
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Where("id = ?", id).First(m)
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
return nil, domain.ErrNotFound
}
return m, tx.Error
}
cacheModel := new(models.ArticleDraftOperation)
cacheModel.Id = id
if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleDraftOperationRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.ArticleDraftOperation, error) {
var (
tx = conn.DB()
ms []*models.ArticleDraftOperation
dms = make([]*domain.ArticleDraftOperation, 0)
total int64
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("updated_at desc")
//标题
if v, ok := queryOptions["title"]; ok {
tx = tx.Where("title like ?", "%"+v.(string)+"%")
}
//公司ID
if v, ok := queryOptions["companyId"]; ok {
tx = tx.Where("company_id = ?", v)
}
//最近修改时间
if v, ok := queryOptions["beginTime"]; ok {
tx = tx.Where("updated_at >= ?", v)
}
if v, ok := queryOptions["endTime"]; ok {
tx = tx.Where("updated_at <= ?", v)
}
//操作人
if v, ok := queryOptions["operator"]; ok {
tx = tx.Where(`"operator" ->> 'name' like ?`, "%"+v.(string)+"%")
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
return dms, nil
}
if _, err := repository.Query(queryFunc); err != nil {
return 0, nil, err
}
for _, item := range ms {
if dm, err := repository.ModelToDomainModel(item); err != nil {
return 0, dms, err
} else {
dms = append(dms, dm)
}
}
return total, dms, nil
}
func (repository *ArticleDraftOperationRepository) ModelToDomainModel(from *models.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) {
to := &domain.ArticleDraftOperation{}
err := copier.Copy(to, from)
return to, err
}
func (repository *ArticleDraftOperationRepository) DomainModelToModel(from *domain.ArticleDraftOperation) (*models.ArticleDraftOperation, error) {
to := &models.ArticleDraftOperation{}
err := copier.Copy(to, from)
return to, err
}
func NewArticleDraftOperationRepository(cache *cache.CachedRepository) domain.ArticleDraftOperationRepository {
return &ArticleDraftOperationRepository{CachedRepository: cache}
}
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"context"
"fmt"
"gorm.io/plugin/soft_delete"
"strings"
"github.com/pkg/errors"
... ... @@ -53,6 +54,28 @@ func (repository *ArticleRepository) Update(ctx context.Context, conn transactio
return repository.ModelToDomainModel(m)
}
func (repository *ArticleRepository) Restore(ctx context.Context, conn transaction.Conn, dm *domain.Article) (*domain.Article, error) {
var (
err error
m *models.Article
tx = conn.DB()
)
if m, err = repository.DomainModelToModel(dm); err != nil {
return nil, err
}
m.DeletedAt = 0
m.IsDel = soft_delete.DeletedAt(soft_delete.FlagActived)
m.DeletedType = 0
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Unscoped().Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.Article) (*domain.Article, error) {
var (
err error
... ... @@ -113,6 +136,27 @@ func (repository *ArticleRepository) FindOne(ctx context.Context, conn transacti
return repository.ModelToDomainModel(m)
}
func (repository *ArticleRepository) FindOneWithUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*domain.Article, error) {
var (
err error
tx = conn.DB()
m = new(models.Article)
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Unscoped().Where("id = ?", id).First(m)
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
return nil, domain.ErrNotFound
}
return m, tx.Error
}
cacheModel := new(models.Article)
cacheModel.Id = id
if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.Article, error) {
var (
tx = conn.DB()
... ... @@ -133,6 +177,8 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
tx = tx.Order("count_love asc")
case "countLove descending":
tx = tx.Order("count_love desc")
case "deletedAt descending":
tx = tx.Order("deleted_at desc")
default:
tx = tx.Order("created_at desc")
}
... ... @@ -154,6 +200,20 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
if v, ok := queryOptions["authorId"]; ok {
tx = tx.Where("author_id=?", v)
}
if v, ok := queryOptions["deletedType"]; ok {
tx = tx.Where("deleted_type = ?", v)
}
//删除
if v, ok := queryOptions["isDel"]; ok {
tx = tx.Unscoped().Where("is_del = ?", v)
}
//删除时间
if v, ok := queryOptions["beginDeletedAt"]; ok {
tx = tx.Where("deleted_at >= ?", v)
}
if v, ok := queryOptions["endDeletedAt"]; ok {
tx = tx.Where("deleted_at < ?", v)
}
if v, ok := queryOptions["tags"]; ok && len(v.([]int64)) > 0 {
values := make([]string, 0)
for _, item := range v.([]int64) {
... ... @@ -384,6 +444,9 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (*
Summary: from.Summary,
MatchUrl: from.MatchUrl,
Videos: from.Videos,
Source: from.Source,
Operator: from.Operator,
DeletedType: from.DeletedType,
}
return to, nil
}
... ... @@ -413,6 +476,9 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (*
Summary: from.Summary,
MatchUrl: from.MatchUrl,
Videos: from.Videos,
Source: from.Source,
Operator: from.Operator,
DeletedType: from.DeletedType,
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -15,22 +15,25 @@ type Article struct {
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
AuthorId int64 `json:"authorId"` // 发布人
Author UserSimple `json:"author"` // 发布人
Title string `json:"title"` // 文章标题
Images []Image `json:"images"` // 图片
Videos []Video `json:"videos"` // 视频
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show ArticleShow `json:"show"` // 评论的展示状态(1显示,2不显示、)
Tags []int64 `json:"tags"` // 定性标签
Summary string `json:"summary"` // 内容概要
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
AuthorId int64 `json:"authorId"` // 发布人
Author UserSimple `json:"author"` // 发布人
Title string `json:"title"` // 文章标题
Images []Image `json:"images"` // 图片
Videos []Video `json:"videos"` // 视频
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show ArticleShow `json:"show"` // 评论的展示状态(1显示,2不显示、)
Tags []int64 `json:"tags"` // 定性标签
Summary string `json:"summary"` // 内容概要
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Source int `gorm:"default:1"` // 来源 1-用户发布 2-运营发布
Operator Operator `gorm:"type:jsonb;serializer:json"` // 运营操作人
DeletedType int `json:"deletedType"` // 删除类型 1-运营删除 2-用户删除
// ...more
}
... ... @@ -38,8 +41,10 @@ type ArticleRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
Update(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
Delete(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
Restore(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Article, error)
FindOneWithUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*Article, error)
Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*Article, error)
FindAuthorsLatestFirstArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error)
FindAuthorsLatestFirstUnreadArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error)
... ... @@ -65,6 +70,12 @@ type ArticleTarget int
const (
ArticleTargetAll ArticleTarget = 0 //内容分发给所有人
ArticleTargetLimit ArticleTarget = 1 //分发给指定的人
ArticleSourceUser int = 1 //文章来源 用户发布
ArticleSourceOperator int = 2 //文章来源 运营发布
ArticleDeletedTypeOperator int = 1 // 文章删除类型 运营删除
ArticleDeletedTypeUser int = 2 // 文章删除类型 用户删除
)
func (a ArticleTarget) Named() string {
... ...
package domain
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gorm.io/plugin/soft_delete"
)
// ArticleDraftOperation 运营草稿
type ArticleDraftOperation struct {
Id int64 `json:"id"` // 唯一标识
CompanyId int64 `json:"companyId,string"` // 公司ID
AuthorId int64 `json:"authorId"` // 发布人
Title string `json:"title"` // 文章标题
Content string `json:"content"` // 文章内容
Images []Image `json:"images"` // 图片
Videos []Video `json:"videos"` // 视频
TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Tags []int64 `json:"tags"` //定性标签
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Source int `json:"source"` // 来源 1-用户发布 2-运营发布
Operator Operator `json:"operator"` // 运营操作人
Version int `json:"version,omitempty"` // 版本号
CreatedAt int64 `json:"createdAt,omitempty"` // 创建时间
UpdatedAt int64 `json:"updatedAt,omitempty"` // 编辑时间
IsDel soft_delete.DeletedAt `json:"isDel,omitempty"` // 删除标记
DeletedAt int64 `json:"deletedAt,omitempty"` // 删除时间
}
type ArticleDraftOperationRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraftOperation) (*ArticleDraftOperation, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleDraftOperation) (*ArticleDraftOperation, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleDraftOperation) (*ArticleDraftOperation, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleDraftOperation) (*ArticleDraftOperation, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleDraftOperation, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleDraftOperation, error)
}
func (m *ArticleDraftOperation) Identify() interface{} {
if m.Id == 0 {
return nil
}
return m.Id
}
... ...
... ... @@ -45,10 +45,8 @@ type UserSimple struct {
CompanyId int64 `json:"companyId"`
}
// 记录数据的操作人
// type Operator struct {
// From string `json:"from"` // 操作来源
// Id int `json:"id"` // 人员id
// Name string `json:"name"` // 人员名字
// UpdatedAt int64 `json:"updatedAt"` // 时间
// }
// 运营操作人
type Operator struct {
Id int64 `json:"id,string"` // 人员id
Name string `json:"name"` // 人员名字
}
... ...
... ... @@ -26,4 +26,9 @@ CREATE TABLE `company` (
CREATE TABLE `user_follow` (
`id` int(0) NOT NULL COMMENT '唯一标识',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
CREATE TABLE `article_draft_operation` (
`id` int(0) NOT NULL COMMENT '唯一标识',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
\ No newline at end of file
... ...