作者 庄敏学

文章列表、详情

... ... @@ -43,6 +43,34 @@
]
}
},
"v1/mini/article/mark/list": {
"post": {
"summary": "小程序获取文章浏览记录",
"operationId": "MiniArticleMarkList",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleMarkListResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleMarkListRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/mini/article/mark/user_read": {
"post": {
"summary": "小程序标记当前人员查看的文章",
... ... @@ -209,6 +237,62 @@
]
}
},
"v1/mini/article_comment": {
"post": {
"summary": "小程序填写文章的评论",
"operationId": "MiniCreateArticleComment",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniCreateArticleCommentResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniCreateArticleCommentRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/mini/article_comment/at_user/select": {
"post": {
"summary": "小程序获取回复@人可选列表",
"operationId": "MiniArticleCommentAtUser",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleCommentAtUserResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleCommentAtUserRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/mini/article_draft": {
"post": {
"summary": "小程序创建文章进草稿箱",
... ... @@ -217,7 +301,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleSearchMeResponse"
"$ref": "#/definitions/MiniArticleDraftCreateResponse"
}
}
},
... ... @@ -227,7 +311,33 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleSearchMeRequest"
"$ref": "#/definitions/MiniArticleDraftCreateRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
},
"put": {
"summary": "小程序更新文章草稿",
"operationId": "MiniUpdateArticleDraft",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleDraftUpdateResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleDraftUpdateRequest"
}
}
],
... ... @@ -237,21 +347,89 @@
]
}
},
"v1/mini/comment": {
"v1/mini/article_draft/me/{id}": {
"get": {
"summary": "小程序评论",
"operationId": "miniComment",
"summary": "小程序获取我的草稿内容",
"operationId": "MiniGetArticleDraftMe",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/CommentResposne"
"$ref": "#/definitions/MiniArticleDraftGetMeResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"comment"
"article"
]
},
"delete": {
"summary": "小程序删除我的草稿内容",
"operationId": "MiniDeleteArticleDraftMe",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleDraftDeleteMeResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleDraftDeleteMeRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/mini/article_draft/search/me": {
"post": {
"summary": "小程序获取我的草稿箱列表",
"operationId": "MiniSearchArticleDraftMe",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleDraftSearchMeResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleDraftSearchMeRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
... ... @@ -811,6 +989,64 @@
]
}
},
"v1/system/article": {
"put": {
"summary": "管理后台编辑帖子",
"operationId": "SystemUpdateArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleUpdateResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": "编辑",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleUpdateRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/history": {
"post": {
"summary": "管理后台编辑历史",
"operationId": "SystemHistoryArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleHistoryResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": "历史",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleHistoryRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/search": {
"post": {
"summary": "管理后台获取文章列表",
... ... @@ -1005,24 +1241,6 @@
]
}
},
"v1/system/comment": {
"get": {
"summary": "系统评论",
"operationId": "systemComment",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/CommentResposne"
}
}
},
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/system/company/search": {
"post": {
"summary": "公司搜索",
... ... @@ -1051,14 +1269,15 @@
]
}
},
"v1/system/role": {
"v1/system/department/add": {
"post": {
"operationId": "systemSaveRole",
"summary": "部门-新增",
"operationId": "systemAdd",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleSaveResponse"
"$ref": "#/definitions/DepartmentGetResponse"
}
}
},
... ... @@ -1068,24 +1287,25 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleSaveRequest"
"$ref": "#/definitions/DepartmentAddRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
"department"
]
}
},
"v1/system/role/search": {
"v1/system/department/list": {
"post": {
"operationId": "systemSearchRole",
"summary": "部门列表",
"operationId": "systemList",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleSearchResponse"
"$ref": "#/definitions/DepartmentListResponse"
}
}
},
... ... @@ -1095,24 +1315,25 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleSearchRequest"
"$ref": "#/definitions/DepartmentListRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
"department"
]
}
},
"v1/system/role/{id}": {
"v1/system/department/{id}": {
"get": {
"operationId": "systemGetRole",
"summary": "部门-详情",
"operationId": "systemGet",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleGetResponse"
"$ref": "#/definitions/DepartmentGetResponse"
}
}
},
... ... @@ -1126,16 +1347,17 @@
],
"requestBody": {},
"tags": [
"role"
"department"
]
},
"delete": {
"operationId": "systemDeleteRole",
"put": {
"summary": "部门-更新",
"operationId": "systemUpdate",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleDeleteResponse"
"$ref": "#/definitions/DepartmentGetResponse"
}
}
},
... ... @@ -1151,38 +1373,34 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleDeleteRequest"
"$ref": "#/definitions/DepartmentUpdateRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
"department"
]
},
"put": {
"operationId": "systemUpdateRole",
}
},
"v1/system/role": {
"post": {
"operationId": "systemSaveRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleUpdateResponse"
"$ref": "#/definitions/RoleSaveResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleUpdateRequest"
"$ref": "#/definitions/RoleSaveRequest"
}
}
],
... ... @@ -1192,10 +1410,124 @@
]
}
},
"v1/system/user/info": {
"v1/system/role/search": {
"post": {
"summary": "系统用户信息",
"operationId": "systemUserInfo",
"operationId": "systemSearchRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
]
}
},
"v1/system/role/{id}": {
"get": {
"operationId": "systemGetRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"role"
]
},
"delete": {
"operationId": "systemDeleteRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleDeleteResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
]
},
"put": {
"operationId": "systemUpdateRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleUpdateResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleUpdateRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
]
}
},
"v1/system/user/info": {
"post": {
"summary": "系统用户信息",
"operationId": "systemUserInfo",
"responses": {
"200": {
"description": "A successful response.",
... ... @@ -1404,6 +1736,40 @@
"position"
]
},
"ArticleAuthor": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 人员id"
},
"name": {
"type": "string",
"description": " 人员的名字"
},
"avatar": {
"type": "string",
"description": " 人员头像URL"
},
"position": {
"type": "string",
"description": " 职位"
},
"company": {
"type": "string",
"description": " 公司"
}
},
"title": "ArticleAuthor",
"required": [
"id",
"name",
"avatar",
"position",
"company"
]
},
"ArticleSearchMe": {
"type": "object",
"properties": {
... ... @@ -1510,7 +1876,7 @@
"code"
]
},
"Author": {
"CommentAuthor": {
"type": "object",
"properties": {
"id": {
... ... @@ -1526,10 +1892,6 @@
"type": "string",
"description": " 人员头像URL"
},
"group": {
"type": "string",
"description": " 人员的分组"
},
"position": {
"type": "string",
"description": " 职位"
... ... @@ -1539,39 +1901,15 @@
"description": " 公司"
}
},
"title": "Author",
"title": "CommentAuthor",
"required": [
"id",
"name",
"avatar",
"group",
"position",
"company"
]
},
"Comment": {
"type": "object",
"title": "Comment"
},
"CommentRequest": {
"type": "object",
"title": "CommentRequest"
},
"CommentResposne": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/Comment"
}
}
},
"title": "CommentResposne",
"required": [
"list"
]
},
"Company": {
"type": "object",
"properties": {
... ... @@ -1680,6 +2018,108 @@
"name"
]
},
"DepartmentAddRequest": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": " 分组名称"
},
"ids": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 用户ID"
}
},
"title": "DepartmentAddRequest",
"required": [
"name",
"ids"
]
},
"DepartmentGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "DepartmentGetRequest",
"required": [
"id"
]
},
"DepartmentGetResponse": {
"type": "object",
"properties": {
"department": {
"$ref": "#/definitions/Department"
}
},
"title": "DepartmentGetResponse",
"required": [
"department"
]
},
"DepartmentListRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "DepartmentListRequest",
"required": [
"page",
"size"
]
},
"DepartmentListResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/Department"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "DepartmentListResponse",
"required": [
"list",
"total"
]
},
"DepartmentUpdateRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"title": "DepartmentUpdateRequest",
"required": [
"id",
"name"
]
},
"FollowRequest": {
"type": "object",
"properties": {
... ... @@ -2008,12 +2448,29 @@
"list"
]
},
"MiniArticleCreateRequest": {
"MiniArticleCommentAtUserRequest": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "标题"
"articleId": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleCommentAtUserRequest",
"required": [
"articleId"
]
},
"MiniArticleCommentAtUserResponse": {
"type": "object",
"title": "MiniArticleCommentAtUserResponse"
},
"MiniArticleCreateRequest": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "标题"
},
"section": {
"type": "array",
... ... @@ -2077,12 +2534,21 @@
"MiniArticleDraftCreateRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64",
"description": " 发布人"
},
"template": {
"type": "integer",
"format": "int32",
"description": " 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式"
},
"content": {
"section": {
"type": "array",
"items": {
"type": "string"
... ... @@ -2091,27 +2557,359 @@
},
"title": {
"type": "string",
"description": "标题"
"description": " 标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
"description": " 图片"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 谁可以看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 评论人"
},
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
}
},
"title": "MiniArticleDraftCreateRequest",
"required": [
"template",
"content",
"section",
"title",
"images"
"images",
"whoRead",
"whoReview",
"location"
]
},
"MiniArticleDraftCreateResponse": {
"type": "object",
"title": "MiniArticleDraftCreateResponse"
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleDraftCreateResponse",
"required": [
"id"
]
},
"MiniArticleDraftDeleteMeRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64",
"description": " 公司id"
},
"": {
"type": "integer",
"format": "int64",
"description": " 发布人"
},
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleDraftDeleteMeRequest",
"required": [
"id"
]
},
"MiniArticleDraftDeleteMeResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleDraftDeleteMeResponse",
"required": [
"id"
]
},
"MiniArticleDraftGetMeRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64",
"description": " 公司id"
},
"": {
"type": "integer",
"format": "int64",
"description": " 发布人"
},
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleDraftGetMeRequest",
"required": [
"id"
]
},
"MiniArticleDraftGetMeResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"template": {
"type": "integer",
"format": "int32",
"description": " 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式"
},
"Section": {
"type": "array",
"items": {
"type": "string"
},
"description": " 填写的内容"
},
"title": {
"type": "string",
"description": " 标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": " 图片"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 谁可以看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 评论人"
},
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
}
},
"title": "MiniArticleDraftGetMeResponse",
"required": [
"id",
"template",
"Section",
"title",
"images",
"whoRead",
"whoReview",
"location"
]
},
"MiniArticleDraftItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"template": {
"type": "integer",
"format": "int32",
"description": " 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式"
},
"section": {
"type": "array",
"items": {
"type": "string"
},
"description": " 填写的内容"
},
"title": {
"type": "string",
"description": " 标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": " 图片"
},
"createdAt": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleDraftItem",
"required": [
"id",
"template",
"section",
"title",
"images",
"createdAt"
]
},
"MiniArticleDraftSearchMeRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64",
"description": " 公司id"
},
"": {
"type": "integer",
"format": "int64",
"description": " 发布人"
},
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniArticleDraftSearchMeRequest",
"required": [
"page",
"size"
]
},
"MiniArticleDraftSearchMeResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int64"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/MiniArticleDraftItem"
}
}
},
"title": "MiniArticleDraftSearchMeResponse",
"required": [
"total",
"list"
]
},
"MiniArticleDraftUpdateRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64",
"description": " 发布人"
},
"template": {
"type": "integer",
"format": "int32",
"description": " 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式"
},
"section": {
"type": "array",
"items": {
"type": "string"
},
"description": " 填写的内容"
},
"title": {
"type": "string",
"description": " 标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": " 图片"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 谁可以看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 评论人"
},
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
}
},
"title": "MiniArticleDraftUpdateRequest",
"required": [
"id",
"template",
"section",
"title",
"images",
"whoRead",
"whoReview",
"location"
]
},
"MiniArticleDraftUpdateResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleDraftUpdateResponse",
"required": [
"id"
]
},
"MiniArticleGetRequest": {
"type": "object",
... ... @@ -2123,7 +2921,13 @@
},
"": {
"type": "integer",
"format": "int64"
"format": "int64",
"description": "当前公司"
},
"": {
"type": "integer",
"format": "int32",
"description": "当前用户"
}
},
"title": "MiniArticleGetRequest",
... ... @@ -2149,7 +2953,7 @@
"description": "发布人id"
},
"author": {
"$ref": "#/definitions/Author",
"$ref": "#/definitions/ArticleAuthor",
"description": "发布人"
},
"createdAt": {
... ... @@ -2215,6 +3019,11 @@
"type": "integer",
"format": "int32",
"description": " 文章是否存在变更记录 (0 不存在 1存在)"
},
"meLoveFlag": {
"type": "integer",
"format": "int32",
"description": "当前人员对文章的点赞标识"
}
},
"title": "MiniArticleGetResponse",
... ... @@ -2233,7 +3042,88 @@
"countComment",
"countRead",
"show",
"edit"
"edit",
"meLoveFlag"
]
},
"MiniArticleMarkItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"companyId": {
"type": "integer",
"format": "int64"
},
"userId": {
"type": "integer",
"format": "int64"
},
"articleId": {
"type": "integer",
"format": "int64"
},
"title": {
"type": "string"
},
"author": {
"$ref": "#/definitions/SimpleUser",
"description": " 发布人"
},
"updatedAt": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleMarkItem",
"required": [
"id",
"companyId",
"userId",
"articleId",
"title",
"author",
"updatedAt"
]
},
"MiniArticleMarkListRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniArticleMarkListRequest",
"required": [
"page",
"size"
]
},
"MiniArticleMarkListResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int64"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/MiniArticleMarkItem"
}
}
},
"title": "MiniArticleMarkListResponse",
"required": [
"total",
"list"
]
},
"MiniArticleMarkUserReadRequest": {
... ... @@ -2273,50 +3163,188 @@
"id"
]
},
"MiniArticleSearchMeRequest": {
"MiniArticleSearchMeRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniArticleSearchMeRequest",
"required": [
"page",
"size"
]
},
"MiniArticleSearchMeResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSearchMe"
}
}
},
"title": "MiniArticleSearchMeResponse",
"required": [
"total",
"list"
]
},
"MiniCreateArticleCommentRequest": {
"type": "object",
"properties": {
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"sectionId": {
"type": "integer",
"format": "int64",
"description": " 段落id"
},
"": {
"type": "integer",
"format": "int64",
"description": " 填写文章的人,服务端自动获取"
},
"": {
"type": "integer",
"format": "int64",
"description": " 服务端自动获取"
},
"commnet": {
"type": "integer",
"format": "int64",
"description": " 回复那个评论的id"
},
"content": {
"type": "string",
"description": " 评论的内容"
},
"atWho": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 填写评论时@的人"
}
},
"title": "MiniCreateArticleCommentRequest",
"required": [
"articleId",
"sectionId",
"commnet",
"content",
"atWho"
]
},
"MiniCreateArticleCommentResponse": {
"type": "object",
"properties": {
"": {
"id": {
"type": "integer",
"format": "int64"
},
"": {
"pid": {
"type": "integer",
"format": "int64"
},
"page": {
"topId": {
"type": "integer",
"format": "int32"
"format": "int64"
},
"size": {
"articleId": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniArticleSearchMeRequest",
"required": [
"page",
"size"
]
},
"MiniArticleSearchMeResponse": {
"type": "object",
"properties": {
"total": {
"format": "int64",
"description": " 文章id"
},
"sectionId": {
"type": "integer",
"format": "int32"
"format": "int64",
"description": " 段落id"
},
"list": {
"fromUserId": {
"type": "integer",
"format": "int64",
"description": " 填写评论的人"
},
"fromUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 填写评论的人"
},
"toUserId": {
"type": "integer",
"format": "int64",
"description": " 回复哪个人"
},
"toUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 回复哪个人"
},
"sectionContent": {
"type": "string",
"description": " 引用的文章内容文本"
},
"countReply": {
"type": "integer",
"format": "int32",
"description": " 回复数量"
},
"countUserLove": {
"type": "integer",
"format": "int32",
"description": " 用户点赞数量"
},
"countAdminLove": {
"type": "integer",
"format": "int32",
"description": " 运营点赞数量"
},
"atWho": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSearchMe"
}
"$ref": "#/definitions/CommentAuthor"
},
"description": " 填写评论时@的人"
}
},
"title": "MiniArticleSearchMeResponse",
"title": "MiniCreateArticleCommentResponse",
"required": [
"total",
"list"
"id",
"pid",
"topId",
"articleId",
"sectionId",
"fromUserId",
"fromUser",
"toUserId",
"toUser",
"sectionContent",
"countReply",
"countUserLove",
"countAdminLove",
"atWho"
]
},
"MiniMyLikeRequest": {
... ... @@ -3122,7 +4150,7 @@
"description": " 发布人id"
},
"author": {
"$ref": "#/definitions/Author",
"$ref": "#/definitions/ArticleAuthor",
"description": " 发布人"
},
"createdAt": {
... ... @@ -3219,6 +4247,57 @@
"show"
]
},
"SystemArticleHistoryRequest": {
"type": "object",
"properties": {
"articleId": {
"type": "integer",
"format": "int64",
"description": "文章ID"
},
"author": {
"type": "string",
"description": "发布人"
},
"updatedAt": {
"type": "string",
"description": "修改日期"
}
},
"title": "SystemArticleHistoryRequest",
"required": [
"articleId"
]
},
"SystemArticleHistoryResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"author": {
"type": "string",
"description": "编辑人"
},
"action": {
"type": "string",
"description": "编辑类型"
},
"updatedAt": {
"type": "string",
"description": "编辑时间"
}
},
"title": "SystemArticleHistoryResponse",
"required": [
"id",
"author",
"action",
"updatedAt"
]
},
"SystemArticleSearch": {
"type": "object",
"properties": {
... ... @@ -3296,19 +4375,36 @@
"type": "integer",
"format": "int64"
},
"page": {
"title": {
"type": "string",
"description": "标题"
},
"author": {
"type": "string",
"description": "发布人"
},
"publishDate": {
"type": "string",
"description": "发布日期"
},
"pageNumber": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": "页码"
},
"size": {
"pageSize": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": "每页行数"
}
},
"title": "SystemArticleSearchRequest",
"required": [
"page",
"size"
"title",
"author",
"publishDate",
"pageNumber",
"pageSize"
]
},
"SystemArticleSearchResponse": {
... ... @@ -3331,6 +4427,149 @@
"list"
]
},
"SystemArticleUpdateRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"template": {
"type": "integer",
"format": "int32",
"description": " 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式"
},
"section": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSection"
},
"description": " 填写的内容"
},
"title": {
"type": "string",
"description": " 标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": " 图片"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 谁可以看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 评论人"
},
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": "分发方式 [0分发给所有人、1分发给指定的人]"
}
},
"title": "SystemArticleUpdateRequest",
"required": [
"id",
"template",
"section",
"title",
"images",
"whoRead",
"whoReview",
"location",
"targetUser"
]
},
"SystemArticleUpdateResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"title": {
"type": "string",
"description": "标题"
},
"author": {
"type": "string",
"description": "发布人"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": "文章的创建日期"
},
"countLove": {
"type": "integer",
"format": "int32",
"description": "点赞数量"
},
"CountComment": {
"type": "integer",
"format": "int32",
"description": "评论数量"
},
"show": {
"type": "integer",
"format": "int32",
"description": "是否隐藏 [0显示、1不显示]"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "标签"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": "分发方式 [0分发给所有人、1分发给指定的人]"
}
},
"title": "SystemArticleUpdateResponse",
"required": [
"id",
"title",
"author",
"images",
"createdAt",
"countLove",
"CountComment",
"show",
"tags",
"targetUser"
]
},
"SystemUser": {
"type": "object",
"properties": {
... ... @@ -4185,8 +5424,7 @@
"format": "int32"
},
"name": {
"type": "integer",
"format": "int32"
"type": "string"
}
},
"title": "UserShowName",
... ...
... ... @@ -69,7 +69,7 @@ service Core {
@server(
prefix: v1/system
group: article
jwt: MiniAuth
jwt: SystemAuth
)
service Core {
@doc "管理后台获取文章内容详情"
... ... @@ -79,4 +79,12 @@ service Core {
@doc "管理后台获取文章列表"
@handler SystemSearchArticle
post /article/search (SystemArticleSearchRequest) returns (SystemArticleSearchResponse)
@doc "管理后台编辑帖子"
@handler SystemUpdateArticle
put /article (SystemArticleUpdateRequest) returns (SystemArticleUpdateResponse)
@doc "管理后台编辑历史"
@handler SystemHistoryArticle
post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse)
}
\ No newline at end of file
... ...
... ... @@ -289,8 +289,8 @@ type (
}
UserShowName {
Id int `json:"id"`
Name int `json:"name"`
Id int `json:"id"`
Name string `json:"name"`
}
SystemArticleGetResponse {
... ... @@ -317,8 +317,11 @@ type (
type (
SystemArticleSearchRequest {
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
Title string `json:"title"` //标题
Author string `json:"author"` //发布人
PublishDate string `json:"publishDate"` //发布日期
PageNumber int `json:"pageNumber"` //页码
PageSize int `json:"pageSize"` //每页行数
}
SystemArticleSearchResponse {
... ... @@ -337,4 +340,41 @@ type (
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
//编辑
SystemArticleUpdateRequest {
Id int64 `json:"id"`
CompanyId int64 `json:",optional"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []ArticleSection `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
SystemArticleUpdateResponse {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
//历史
SystemArticleHistoryRequest {
ArticleId int64 `json:"articleId"` //文章ID
Author string `json:"author,optional"` //发布人
UpdatedAt string `json:"updatedAt,optional"` //修改日期
}
SystemArticleHistoryResponse {
Id int64 `json:"id"` //id
Author string `json:"author"` //编辑人
Action string `json:"action"` //编辑类型
UpdatedAt string `json:"updatedAt"` //编辑时间
}
)
\ No newline at end of file
... ...
syntax = "v1"
info(
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
)
// 小程序接口
@server(
prefix: v1
group: company
prefix: v1
group: company
)
service Core {
@doc "公司搜索(公开的)"
@handler miniCompanySearch
post /mini/company/search(CompanySearchRequest) returns (CompanySearchResponse)
@doc "公司搜索(公开的)"
@handler miniCompanySearch
post /mini/company/search(CompanySearchRequest) returns (CompanySearchResponse)
}
// 小程序接口
@server(
prefix: v1
group: company
jwt : MiniAuth
prefix: v1
group: company
jwt : MiniAuth
)
service Core {
@doc "搜索已加入的公司"
@handler miniCompanySearchJoined
post /mini/company/search-joined(CompanySearchRequest) returns (CompanySearchResponse)
@doc "搜索已加入的公司"
@handler miniCompanySearchJoined
post /mini/company/search-joined(CompanySearchRequest) returns (CompanySearchResponse)
}
// 小程序接口
@server(
prefix: v1
group: company
jwt : SystemAuth
prefix: v1
group: company
jwt : SystemAuth
)
service Core {
@doc "公司搜索"
@handler systemCompanySearch
post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse)
@doc "公司搜索"
@handler systemCompanySearch
post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse)
}
type (
CompanySearchRequest struct{
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Flag int `json:"flag,optional"` // 1:用户已加入的 2:用户未加入的公司
UserId int64 `json:"userId,optional"` // 按用户搜索(用户所加入的企业)
Code string `json:"code,optional"` // 按编码搜索
}
CompanySearchResponse{
List []Company `json:"list"`
Total int64 `json:"total"`
}
Company struct{
Id int64 `json:"id,omitempty"` // 唯一标识
Name string `json:"name,omitempty"` // 名称
Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)
Logo string `json:"logo,omitempty"` // 公司LOGO
}
CompanySearchRequest {
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Flag int `json:"flag,optional"` // 1:用户已加入的 2:用户未加入的公司
UserId int64 `json:"userId,optional"` // 按用户搜索(用户所加入的企业)
Code string `json:"code,optional"` // 按编码搜索
}
CompanySearchResponse {
List []Company `json:"list"`
Total int64 `json:"total"`
}
Company {
Id int64 `json:"id,omitempty"` // 唯一标识
Name string `json:"name,omitempty"` // 名称
Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)
Logo string `json:"logo,omitempty"` // 公司LOGO
}
)
\ No newline at end of file
... ...
syntax = "v1"
info(
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
)
@server(
prefix: v1
group: role
jwt: SystemAuth
prefix: v1
group: role
jwt: SystemAuth
)
service Core {
@handler systemGetRole
get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
@handler systemSaveRole
post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
@handler systemDeleteRole
delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
@handler systemUpdateRole
put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
@handler systemSearchRole
post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
@handler systemGetRole
get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
@handler systemSaveRole
post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
@handler systemDeleteRole
delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
@handler systemUpdateRole
put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
@handler systemSearchRole
post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
}
type (
RoleGetRequest {
Id int64 `path:"id"`
}
RoleGetResponse struct{
Role RoleItem `json:"role"`
AuthList []Auth `json:"authList"`
}
RoleGetRequest {
Id int64 `path:"id"`
}
RoleGetResponse {
Role RoleItem `json:"role"`
AuthList []Auth `json:"authList"`
}
RoleSaveRequest struct{
Role RoleItem `json:"role"`
}
RoleSaveResponse struct{}
RoleSaveRequest {
Role RoleItem `json:"role"`
}
RoleSaveResponse struct{}
RoleDeleteRequest struct{
Id int64 `path:"id"`
}
RoleDeleteResponse struct{}
RoleDeleteRequest {
Id int64 `path:"id"`
}
RoleDeleteResponse struct{}
RoleUpdateRequest struct{
Id int64 `path:"id"`
Role RoleItem `json:"role"`
}
RoleUpdateResponse struct{}
RoleUpdateRequest {
Id int64 `path:"id"`
Role RoleItem `json:"role"`
}
RoleUpdateResponse struct{}
RoleSearchRequest struct{
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Style string `json:"style,options=[simple,,full]"` // simple:只返回角色ID名称 full:所有字段都返回
}
RoleSearchResponse{
List []RoleItem `json:"list"`
Total int64 `json:"total"`
}
RoleItem struct{
Id int64 `json:"id,optional"` // 角色ID
CompanyId int64 `json:"companyId,optional,omitempty"` // 公司ID
Name string `json:"name"` // 角色名称
AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表
AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述
UsersDesc string `json:"usersDesc,optional,omitempty"` // 用户列表描述
Remark string `json:"remark,optional,omitempty"` // 备注
Users []RoleUser `json:"users,optional,omitempty"` // 绑定的用户
UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间
}
RoleUser {
Id int64 `json:"id"`
Name string `json:"name"`
}
Auth {
Id int64 `json:"id"` // ID
Name string `json:"name"` // 名称
Code string `json:"code"` // 编码
}
RoleSearchRequest {
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Style string `json:"style,options=[simple,,full]"` // simple:只返回角色ID名称 full:所有字段都返回
}
RoleSearchResponse {
List []RoleItem `json:"list"`
Total int64 `json:"total"`
}
RoleItem {
Id int64 `json:"id,optional"` // 角色ID
CompanyId int64 `json:"companyId,optional,omitempty"` // 公司ID
Name string `json:"name"` // 角色名称
AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表
AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述
UsersDesc string `json:"usersDesc,optional,omitempty"` // 用户列表描述
Remark string `json:"remark,optional,omitempty"` // 备注
Users []RoleUser `json:"users,optional,omitempty"` // 绑定的用户
UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间
}
RoleUser {
Id int64 `json:"id"`
Name string `json:"name"`
}
Auth {
Id int64 `json:"id"` // ID
Name string `json:"name"` // 名称
Code string `json:"code"` // 编码
}
)
\ No newline at end of file
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemHistoryArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleHistoryRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemHistoryArticleLogic(r.Context(), svcCtx)
resp, err := l.SystemHistoryArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemUpdateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleUpdateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemUpdateArticleLogic(r.Context(), svcCtx)
resp, err := l.SystemUpdateArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
... ... @@ -333,8 +333,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article/search",
Handler: article.SystemSearchArticleHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article",
Handler: article.SystemUpdateArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/history",
Handler: article.SystemHistoryArticleHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
... ...
... ... @@ -2,6 +2,9 @@ package article
import (
"context"
"github.com/samber/lo"
"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"
... ... @@ -24,7 +27,79 @@ func NewSystemGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}
func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequest) (resp *types.SystemArticleGetResponse, err error) {
// todo: add your logic here and delete this line
return
var conn = l.svcCtx.DefaultDBConn()
article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("获取帖子异常", err)
}
images := make([]string, 0)
lo.ForEach(article.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
resp = &types.SystemArticleGetResponse{
Id: article.Id,
Title: article.Title,
AuthorId: article.AuthorId,
Author: types.ArticleAuthor{
Id: article.Author.Id,
Name: article.Author.Name,
Avatar: article.Author.Avatar,
Position: article.Author.Position,
Company: article.Author.Company,
},
CreatedAt: article.CreatedAt,
Section: make([]types.ArticleSection, 0),
Images: images,
WhoRead: article.WhoRead,
WhoReadInfo: make([]types.UserShowName, 0),
WhoReview: article.WhoReview,
WhoReviewInfo: make([]types.UserShowName, 0),
Location: types.Location{
Longitude: article.Location.Longitude,
Latitude: article.Location.Latitude,
Descript: article.Location.Descript,
},
CountLove: article.CountLove,
CountComment: article.CountComment,
CountRead: article.CountRead,
Show: int(article.Show),
}
//文章段落
_, articleSections, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithKV("articleId", req.Id))
if err != nil {
return nil, xerr.NewErrMsgErr("获取帖子异常", err)
}
lo.ForEach(articleSections, func(item *domain.ArticleSection, index int) {
resp.Section = append(resp.Section, types.ArticleSection{
Id: item.Id,
Content: item.Content,
SortBy: item.SortBy,
TotalComment: item.TotalComment,
})
})
userIds := lo.Union(resp.WhoRead, resp.WhoReview)
if len(userIds) > 0 {
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithKV("ids", userIds))
if err != nil {
return nil, xerr.NewErrMsgErr("获取帖子异常", err)
}
userSlices := make(map[int64]types.UserShowName)
lo.ForEach(users, func(user *domain.User, index int) {
userSlices[user.Id] = types.UserShowName{
Id: int(user.Id),
Name: user.Name,
}
})
lo.ForEach(resp.WhoRead, func(userId int64, index int) {
if value, ok := userSlices[userId]; ok {
resp.WhoReadInfo = append(resp.WhoReadInfo, value)
}
})
lo.ForEach(resp.WhoReview, func(userId int64, index int) {
if value, ok := userSlices[userId]; ok {
resp.WhoReviewInfo = append(resp.WhoReviewInfo, value)
}
})
}
return resp, nil
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"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 SystemHistoryArticleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemHistoryArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemHistoryArticleLogic {
return &SystemHistoryArticleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemHistoryArticleLogic) SystemHistoryArticle(req *types.SystemArticleHistoryRequest) (resp *types.SystemArticleHistoryResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
l.svcCtx.ArticleBackupRepository.Find(
l.ctx,
conn,
domain.NewQueryOptions().
WithKV("articleId", req.ArticleId).
WithKV("author", req.Author).
WithKV("updatedAt", req.UpdatedAt),
)
return
}
... ...
... ... @@ -2,6 +2,9 @@ package article
import (
"context"
"github.com/samber/lo"
"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"
... ... @@ -24,7 +27,40 @@ func NewSystemSearchArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext
}
func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleSearchRequest) (resp *types.SystemArticleSearchResponse, err error) {
// todo: add your logic here and delete this line
return
var conn = l.svcCtx.DefaultDBConn()
total, articles, err := l.svcCtx.ArticleRepository.Find(
l.ctx,
conn,
req.CompanyId,
domain.NewQueryOptions().
WithOffsetLimit(req.PageNumber, req.PageSize).
WithKV("tile", req.Title).
WithKV("author", req.Author),
)
if err != nil {
return nil, xerr.NewErrMsgErr("搜索帖子异常", err)
}
resp = &types.SystemArticleSearchResponse{
Total: int(total),
List: make([]types.SystemArticleSearch, 0),
}
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)
})
resp.List = append(resp.List, types.SystemArticleSearch{
Id: item.Id,
Title: item.Title,
Author: item.Author.Name,
Images: images,
CreatedAt: item.CreatedAt,
CountLove: item.CountLove,
CountComment: item.CountComment,
Show: int(item.Show),
Tags: nil,
TargetUser: int(item.TargetUser),
})
})
return resp, nil
}
... ...
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 SystemUpdateArticleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemUpdateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUpdateArticleLogic {
return &SystemUpdateArticleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleUpdateRequest) (resp *types.SystemArticleUpdateResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("帖子不存在", err)
}
//TODO 获取图片的尺寸大小
images := []domain.Image{}
for _, val := range req.Images {
images = append(images, domain.Image{
Url: val,
Width: 0,
Height: 0,
})
}
article.Title = req.Title
article.Version = article.Version + 1
article.Images = images
article.WhoRead = req.WhoRead
article.WhoReview = req.WhoReview
article.TargetUser = domain.ArticleTarget(req.TargetUser)
article.Location = domain.Location{
Longitude: req.Location.Longitude,
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
}
//文章内容
articleSections := []domain.ArticleSection{}
lo.ForEach(req.Section, func(item types.ArticleSection, index int) {
articleSections = append(articleSections, domain.ArticleSection{
Id: item.Id,
CompanyId: article.CompanyId,
Version: article.Version,
ArticleId: article.Id,
Content: item.Content,
SortBy: index + 1,
})
})
//设置内容概要
if len(req.Section) > 0 {
// 截取内容 30个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
for i := range req.Section[0].Content {
if runeNumber > 30 {
break
}
runeNumber += 1
stringIndex = i
}
article.Summary = req.Section[0].Content[0:stringIndex]
}
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleRepository.Update(l.ctx, conn, article)
if err != nil {
return xerr.NewErrMsgErr("保存文章失败", err)
}
//文章内容
updateSectionIds := []int64{}
for _, item := range articleSections {
if item.Id > 0 {
section, err := l.svcCtx.ArticleSectionRepository.FindOne(ctx, c, item.Id)
if err != nil {
return xerr.NewErrMsgErr("获取文章段落内容失败", err)
}
section.Content = item.Content
section.ArticleId = item.ArticleId
section.Version = item.Version
section.SortBy = item.SortBy
section.CompanyId = item.CompanyId
_, err = l.svcCtx.ArticleSectionRepository.Update(ctx, c, section)
if err != nil {
return xerr.NewErrMsgErr("保存文章段落内容失败", err)
}
} else {
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, &item)
if err != nil {
return xerr.NewErrMsgErr("保存文章段落内容失败", err)
}
}
updateSectionIds = append(updateSectionIds, item.Id)
}
if len(updateSectionIds) > 0 {
err = l.svcCtx.ArticleSectionRepository.DeleteBy(ctx, c, domain.NewQueryOptions().WithKV("articleId", article.Id).WithKV("notIds", updateSectionIds))
if err != nil {
return xerr.NewErrMsgErr("保存文章内容失败", err)
}
}
//备份数据
backup := article.MakeBackup(article.Author, articleSections)
backup.Action = "编辑"
_, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup)
if err != nil {
return xerr.NewErrMsgErr("保存文章内容失败", err)
}
return nil
}, true)
return
}
... ...
... ... @@ -723,8 +723,8 @@ type SystemArticleGetRequest struct {
}
type UserShowName struct {
Id int `json:"id"`
Name int `json:"name"`
Id int `json:"id"`
Name string `json:"name"`
}
type SystemArticleGetResponse struct {
... ... @@ -747,9 +747,12 @@ type SystemArticleGetResponse struct {
}
type SystemArticleSearchRequest struct {
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:",optional"`
Title string `json:"title"` //标题
Author string `json:"author"` //发布人
PublishDate string `json:"publishDate"` //发布日期
PageNumber int `json:"pageNumber"` //页码
PageSize int `json:"pageSize"` //每页行数
}
type SystemArticleSearchResponse struct {
... ... @@ -770,6 +773,45 @@ type SystemArticleSearch struct {
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type SystemArticleUpdateRequest struct {
Id int64 `json:"id"`
CompanyId int64 `json:",optional"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []ArticleSection `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type SystemArticleUpdateResponse struct {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type SystemArticleHistoryRequest struct {
ArticleId int64 `json:"articleId"` //文章ID
Author string `json:"author,optional"` //发布人
UpdatedAt string `json:"updatedAt,optional"` //修改日期
}
type SystemArticleHistoryResponse struct {
Id int64 `json:"id"` //id
Author string `json:"author"` //编辑人
Action string `json:"action"` //编辑类型
UpdatedAt string `json:"updatedAt"` //编辑时间
}
type RoleGetRequest struct {
Id int64 `path:"id"`
}
... ...
... ... @@ -90,6 +90,28 @@ func (repository *ArticleSectionRepository) Delete(ctx context.Context, conn tra
return repository.ModelToDomainModel(m)
}
func (repository *ArticleSectionRepository) DeleteBy(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) error {
var (
tx = conn.DB()
m = &models.ArticleSection{}
)
queryFunc := func() (interface{}, error) {
tx = tx.Where("id = ?", m.Id)
if v, ok := queryOptions["articleId"]; ok {
tx = tx.Where("article_id = ?", v)
}
if v, ok := queryOptions["notIds"]; ok {
tx = tx.Where("id not in (?)", v)
}
tx.Delete(m)
return m, tx.Error
}
if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return err
}
return nil
}
func (repository *ArticleSectionRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleSection, error) {
var (
err error
... ...
... ... @@ -25,6 +25,7 @@ type ArticleSectionRepository interface {
Update(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
DeleteBy(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) error
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleSection, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleSection, error)
}
... ...