正在显示
20 个修改的文件
包含
332 行增加
和
135 行删除
| @@ -293,34 +293,6 @@ | @@ -293,34 +293,6 @@ | ||
| 293 | ] | 293 | ] |
| 294 | } | 294 | } |
| 295 | }, | 295 | }, |
| 296 | - "v1/mini/article_comment/at_user/select": { | ||
| 297 | - "post": { | ||
| 298 | - "summary": "小程序获取回复@人可选列表", | ||
| 299 | - "operationId": "MiniArticleCommentAtUser", | ||
| 300 | - "responses": { | ||
| 301 | - "200": { | ||
| 302 | - "description": "A successful response.", | ||
| 303 | - "schema": { | ||
| 304 | - "$ref": "#/definitions/MiniArticleCommentAtUserResponse" | ||
| 305 | - } | ||
| 306 | - } | ||
| 307 | - }, | ||
| 308 | - "parameters": [ | ||
| 309 | - { | ||
| 310 | - "name": "body", | ||
| 311 | - "in": "body", | ||
| 312 | - "required": true, | ||
| 313 | - "schema": { | ||
| 314 | - "$ref": "#/definitions/MiniArticleCommentAtUserRequest" | ||
| 315 | - } | ||
| 316 | - } | ||
| 317 | - ], | ||
| 318 | - "requestBody": {}, | ||
| 319 | - "tags": [ | ||
| 320 | - "comment" | ||
| 321 | - ] | ||
| 322 | - } | ||
| 323 | - }, | ||
| 324 | "v1/mini/article_comment/at_who/list": { | 296 | "v1/mini/article_comment/at_who/list": { |
| 325 | "post": { | 297 | "post": { |
| 326 | "summary": "小程序展示评论时@人可选列表", | 298 | "summary": "小程序展示评论时@人可选列表", |
| @@ -2978,23 +2950,6 @@ | @@ -2978,23 +2950,6 @@ | ||
| 2978 | "list" | 2950 | "list" |
| 2979 | ] | 2951 | ] |
| 2980 | }, | 2952 | }, |
| 2981 | - "MiniArticleCommentAtUserRequest": { | ||
| 2982 | - "type": "object", | ||
| 2983 | - "properties": { | ||
| 2984 | - "articleId": { | ||
| 2985 | - "type": "integer", | ||
| 2986 | - "format": "int64" | ||
| 2987 | - } | ||
| 2988 | - }, | ||
| 2989 | - "title": "MiniArticleCommentAtUserRequest", | ||
| 2990 | - "required": [ | ||
| 2991 | - "articleId" | ||
| 2992 | - ] | ||
| 2993 | - }, | ||
| 2994 | - "MiniArticleCommentAtUserResponse": { | ||
| 2995 | - "type": "object", | ||
| 2996 | - "title": "MiniArticleCommentAtUserResponse" | ||
| 2997 | - }, | ||
| 2998 | "MiniArticleCommentAtWhoRequest": { | 2953 | "MiniArticleCommentAtWhoRequest": { |
| 2999 | "type": "object", | 2954 | "type": "object", |
| 3000 | "properties": { | 2955 | "properties": { |
| @@ -5069,55 +5024,94 @@ | @@ -5069,55 +5024,94 @@ | ||
| 5069 | "show" | 5024 | "show" |
| 5070 | ] | 5025 | ] |
| 5071 | }, | 5026 | }, |
| 5072 | - "SystemArticleHistoryRequest": { | 5027 | + "SystemArticleHistory": { |
| 5073 | "type": "object", | 5028 | "type": "object", |
| 5074 | "properties": { | 5029 | "properties": { |
| 5075 | - "articleId": { | 5030 | + "id": { |
| 5076 | "type": "integer", | 5031 | "type": "integer", |
| 5077 | "format": "int64", | 5032 | "format": "int64", |
| 5078 | - "description": "文章ID" | 5033 | + "description": "id" |
| 5079 | }, | 5034 | }, |
| 5080 | "author": { | 5035 | "author": { |
| 5081 | "type": "string", | 5036 | "type": "string", |
| 5082 | - "description": "发布人" | 5037 | + "description": "编辑人" |
| 5083 | }, | 5038 | }, |
| 5084 | - "updatedAt": { | 5039 | + "action": { |
| 5085 | "type": "string", | 5040 | "type": "string", |
| 5086 | - "description": "修改日期" | 5041 | + "description": "编辑类型" |
| 5042 | + }, | ||
| 5043 | + "updatedAt": { | ||
| 5044 | + "type": "integer", | ||
| 5045 | + "format": "int64", | ||
| 5046 | + "description": "编辑时间" | ||
| 5087 | } | 5047 | } |
| 5088 | }, | 5048 | }, |
| 5089 | - "title": "SystemArticleHistoryRequest", | 5049 | + "title": "SystemArticleHistory", |
| 5090 | "required": [ | 5050 | "required": [ |
| 5091 | - "articleId" | 5051 | + "id", |
| 5052 | + "author", | ||
| 5053 | + "action", | ||
| 5054 | + "updatedAt" | ||
| 5092 | ] | 5055 | ] |
| 5093 | }, | 5056 | }, |
| 5094 | - "SystemArticleHistoryResponse": { | 5057 | + "SystemArticleHistoryRequest": { |
| 5095 | "type": "object", | 5058 | "type": "object", |
| 5096 | "properties": { | 5059 | "properties": { |
| 5097 | - "id": { | 5060 | + "articleId": { |
| 5098 | "type": "integer", | 5061 | "type": "integer", |
| 5099 | "format": "int64", | 5062 | "format": "int64", |
| 5100 | - "description": "id" | 5063 | + "description": "文章ID" |
| 5101 | }, | 5064 | }, |
| 5102 | "author": { | 5065 | "author": { |
| 5103 | "type": "string", | 5066 | "type": "string", |
| 5104 | - "description": "编辑人" | 5067 | + "description": "发布人" |
| 5105 | }, | 5068 | }, |
| 5106 | - "action": { | ||
| 5107 | - "type": "string", | ||
| 5108 | - "description": "编辑类型" | 5069 | + "beginTime": { |
| 5070 | + "type": "integer", | ||
| 5071 | + "format": "int64", | ||
| 5072 | + "description": "开始时间" | ||
| 5109 | }, | 5073 | }, |
| 5110 | - "updatedAt": { | ||
| 5111 | - "type": "string", | ||
| 5112 | - "description": "编辑时间" | 5074 | + "endTime": { |
| 5075 | + "type": "integer", | ||
| 5076 | + "format": "int64", | ||
| 5077 | + "description": "结束时间" | ||
| 5078 | + }, | ||
| 5079 | + "page": { | ||
| 5080 | + "type": "integer", | ||
| 5081 | + "format": "int32", | ||
| 5082 | + "description": "页码" | ||
| 5083 | + }, | ||
| 5084 | + "size": { | ||
| 5085 | + "type": "integer", | ||
| 5086 | + "format": "int32", | ||
| 5087 | + "description": "每页行数" | ||
| 5088 | + } | ||
| 5089 | + }, | ||
| 5090 | + "title": "SystemArticleHistoryRequest", | ||
| 5091 | + "required": [ | ||
| 5092 | + "articleId", | ||
| 5093 | + "page", | ||
| 5094 | + "size" | ||
| 5095 | + ] | ||
| 5096 | + }, | ||
| 5097 | + "SystemArticleHistoryResponse": { | ||
| 5098 | + "type": "object", | ||
| 5099 | + "properties": { | ||
| 5100 | + "total": { | ||
| 5101 | + "type": "integer", | ||
| 5102 | + "format": "int32" | ||
| 5103 | + }, | ||
| 5104 | + "list": { | ||
| 5105 | + "type": "array", | ||
| 5106 | + "items": { | ||
| 5107 | + "$ref": "#/definitions/SystemArticleHistory" | ||
| 5108 | + } | ||
| 5113 | } | 5109 | } |
| 5114 | }, | 5110 | }, |
| 5115 | "title": "SystemArticleHistoryResponse", | 5111 | "title": "SystemArticleHistoryResponse", |
| 5116 | "required": [ | 5112 | "required": [ |
| 5117 | - "id", | ||
| 5118 | - "author", | ||
| 5119 | - "action", | ||
| 5120 | - "updatedAt" | 5113 | + "total", |
| 5114 | + "list" | ||
| 5121 | ] | 5115 | ] |
| 5122 | }, | 5116 | }, |
| 5123 | "SystemArticleSearch": { | 5117 | "SystemArticleSearch": { |
| @@ -5259,16 +5253,22 @@ | @@ -5259,16 +5253,22 @@ | ||
| 5259 | "type": "string", | 5253 | "type": "string", |
| 5260 | "description": "发布人" | 5254 | "description": "发布人" |
| 5261 | }, | 5255 | }, |
| 5262 | - "publishDate": { | ||
| 5263 | - "type": "string", | ||
| 5264 | - "description": "发布日期" | 5256 | + "beginTime": { |
| 5257 | + "type": "integer", | ||
| 5258 | + "format": "int64", | ||
| 5259 | + "description": "开始时间" | ||
| 5265 | }, | 5260 | }, |
| 5266 | - "pageNumber": { | 5261 | + "endTime": { |
| 5262 | + "type": "integer", | ||
| 5263 | + "format": "int64", | ||
| 5264 | + "description": "结束时间" | ||
| 5265 | + }, | ||
| 5266 | + "page": { | ||
| 5267 | "type": "integer", | 5267 | "type": "integer", |
| 5268 | "format": "int32", | 5268 | "format": "int32", |
| 5269 | "description": "页码" | 5269 | "description": "页码" |
| 5270 | }, | 5270 | }, |
| 5271 | - "pageSize": { | 5271 | + "size": { |
| 5272 | "type": "integer", | 5272 | "type": "integer", |
| 5273 | "format": "int32", | 5273 | "format": "int32", |
| 5274 | "description": "每页行数" | 5274 | "description": "每页行数" |
| @@ -5276,8 +5276,8 @@ | @@ -5276,8 +5276,8 @@ | ||
| 5276 | }, | 5276 | }, |
| 5277 | "title": "SystemArticleSearchRequest", | 5277 | "title": "SystemArticleSearchRequest", |
| 5278 | "required": [ | 5278 | "required": [ |
| 5279 | - "pageNumber", | ||
| 5280 | - "pageSize" | 5279 | + "page", |
| 5280 | + "size" | ||
| 5281 | ] | 5281 | ] |
| 5282 | }, | 5282 | }, |
| 5283 | "SystemArticleSearchResponse": { | 5283 | "SystemArticleSearchResponse": { |
| @@ -97,6 +97,10 @@ service Core { | @@ -97,6 +97,10 @@ service Core { | ||
| 97 | @handler SystemHistoryArticle | 97 | @handler SystemHistoryArticle |
| 98 | post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse) | 98 | post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse) |
| 99 | 99 | ||
| 100 | + @doc "管理后台帖子历史详情" | ||
| 101 | + @handler SystemArticleGetHistory | ||
| 102 | + get /article/history/:id (SystemArticleGetHistoryRequest) returns (SystemArticleGetHistoryResponse) | ||
| 103 | + | ||
| 100 | @doc "管理后台获取我发布的文章" | 104 | @doc "管理后台获取我发布的文章" |
| 101 | @handler SystemArticleSearchMe | 105 | @handler SystemArticleSearchMe |
| 102 | post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse) | 106 | post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse) |
| @@ -36,7 +36,7 @@ type ( | @@ -36,7 +36,7 @@ type ( | ||
| 36 | type ( | 36 | type ( |
| 37 | MiniArticleGetRequest { | 37 | MiniArticleGetRequest { |
| 38 | Id int64 `path:"id"` //id | 38 | Id int64 `path:"id"` //id |
| 39 | - CompanyId int64 `path:",optional"`//当前公司 | 39 | + CompanyId int64 `path:",optional"` //当前公司 |
| 40 | UserId int `path:",optional"` //当前用户 | 40 | UserId int `path:",optional"` //当前用户 |
| 41 | } | 41 | } |
| 42 | MiniArticleGetResponse { | 42 | MiniArticleGetResponse { |
| @@ -293,25 +293,24 @@ type ( | @@ -293,25 +293,24 @@ type ( | ||
| 293 | 293 | ||
| 294 | //小程序端设置文章的定性标签 | 294 | //小程序端设置文章的定性标签 |
| 295 | type ( | 295 | type ( |
| 296 | - MiniArticleSetTagRequest{ | 296 | + MiniArticleSetTagRequest { |
| 297 | CompanyId int64 `json:",optional"` // 公司id | 297 | CompanyId int64 `json:",optional"` // 公司id |
| 298 | UserId int64 `json:",optional"` // 公司id | 298 | UserId int64 `json:",optional"` // 公司id |
| 299 | ArticleId int64 `json:"articleId"` // 文章id | 299 | ArticleId int64 `json:"articleId"` // 文章id |
| 300 | TagId int64 `json:"tagId"` // 标签id | 300 | TagId int64 `json:"tagId"` // 标签id |
| 301 | } | 301 | } |
| 302 | - MiniArticleSetTagResponse{ | 302 | + MiniArticleSetTagResponse { |
| 303 | Id int64 `json:"id"` | 303 | Id int64 `json:"id"` |
| 304 | } | 304 | } |
| 305 | ) | 305 | ) |
| 306 | 306 | ||
| 307 | - | ||
| 308 | //小程序端获取所有的定性标签 | 307 | //小程序端获取所有的定性标签 |
| 309 | type ( | 308 | type ( |
| 310 | - MiniAllArticleTagRequest{ | 309 | + MiniAllArticleTagRequest { |
| 311 | CompanyId int64 `json:",optional"` // 公司id | 310 | CompanyId int64 `json:",optional"` // 公司id |
| 312 | UserId int64 `json:",optional"` // 公司id | 311 | UserId int64 `json:",optional"` // 公司id |
| 313 | } | 312 | } |
| 314 | - MiniAllArticleTagResponse{ | 313 | + MiniAllArticleTagResponse { |
| 315 | TagGroup []ArticleTagGroup `json:"tagGroup"` | 314 | TagGroup []ArticleTagGroup `json:"tagGroup"` |
| 316 | } | 315 | } |
| 317 | ArticleTagGroup { | 316 | ArticleTagGroup { |
| @@ -326,8 +325,6 @@ type ( | @@ -326,8 +325,6 @@ type ( | ||
| 326 | } | 325 | } |
| 327 | ) | 326 | ) |
| 328 | 327 | ||
| 329 | - | ||
| 330 | - | ||
| 331 | //管理后台获取文章详情 | 328 | //管理后台获取文章详情 |
| 332 | type ( | 329 | type ( |
| 333 | SystemArticleGetRequest { | 330 | SystemArticleGetRequest { |
| @@ -357,6 +354,7 @@ type ( | @@ -357,6 +354,7 @@ type ( | ||
| 357 | CountComment int `json:"countComment"` // 评论数量 | 354 | CountComment int `json:"countComment"` // 评论数量 |
| 358 | CountRead int `json:"countRead"` // 浏览数量 | 355 | CountRead int `json:"countRead"` // 浏览数量 |
| 359 | Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | 356 | Show int `json:"show"` // 评论的展示状态(0显示、1不显示) |
| 357 | + Tags []ArticleTagItem `json:"tags"` //标签 | ||
| 360 | } | 358 | } |
| 361 | ) | 359 | ) |
| 362 | 360 | ||
| @@ -366,9 +364,11 @@ type ( | @@ -366,9 +364,11 @@ type ( | ||
| 366 | CompanyId int64 `json:"companyId,optional"` | 364 | CompanyId int64 `json:"companyId,optional"` |
| 367 | Title string `json:"title,optional"` //标题 | 365 | Title string `json:"title,optional"` //标题 |
| 368 | Author string `json:"author,optional"` //发布人 | 366 | Author string `json:"author,optional"` //发布人 |
| 369 | - PublishDate string `json:"publishDate,optional"` //发布日期 | ||
| 370 | - PageNumber int `json:"pageNumber"` //页码 | ||
| 371 | - PageSize int `json:"pageSize"` //每页行数 | 367 | + BeginTime int64 `json:"beginTime,optional"` //开始时间 |
| 368 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
| 369 | + Tags []int64 `json:"tags,optional"` //标签 | ||
| 370 | + Page int `json:"page"` //页码 | ||
| 371 | + Size int `json:"size"` //每页行数 | ||
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | SystemArticleSearchResponse { | 374 | SystemArticleSearchResponse { |
| @@ -399,6 +399,7 @@ type ( | @@ -399,6 +399,7 @@ type ( | ||
| 399 | WhoReview []int64 `json:"whoReview"` // 评论人 | 399 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 400 | Location Location `json:"location"` // 坐标 | 400 | Location Location `json:"location"` // 坐标 |
| 401 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 401 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| 402 | + Tags []int64 `json:"tags"` // 标签 | ||
| 402 | } | 403 | } |
| 403 | SystemArticleUpdateResponse { | 404 | SystemArticleUpdateResponse { |
| 404 | Id int64 `json:"id"` //id | 405 | Id int64 `json:"id"` //id |
| @@ -409,19 +410,50 @@ type ( | @@ -409,19 +410,50 @@ type ( | ||
| 409 | CountLove int `json:"countLove"` //点赞数量 | 410 | CountLove int `json:"countLove"` //点赞数量 |
| 410 | CountComment int `json:"CountComment"` //评论数量 | 411 | CountComment int `json:"CountComment"` //评论数量 |
| 411 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 412 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 412 | - Tags []string `json:"tags"` //标签 | 413 | + Tags []int64 `json:"tags"` //标签 |
| 413 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 414 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| 414 | } | 415 | } |
| 415 | //历史 | 416 | //历史 |
| 416 | SystemArticleHistoryRequest { | 417 | SystemArticleHistoryRequest { |
| 417 | ArticleId int64 `json:"articleId"` //文章ID | 418 | ArticleId int64 `json:"articleId"` //文章ID |
| 418 | Author string `json:"author,optional"` //发布人 | 419 | Author string `json:"author,optional"` //发布人 |
| 419 | - UpdatedAt string `json:"updatedAt,optional"` //修改日期 | 420 | + BeginTime int64 `json:"beginTime,optional"` //开始时间 |
| 421 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
| 422 | + Page int `json:"page"` //页码 | ||
| 423 | + Size int `json:"size"` //每页行数 | ||
| 420 | } | 424 | } |
| 421 | SystemArticleHistoryResponse { | 425 | SystemArticleHistoryResponse { |
| 426 | + Total int `json:"total"` | ||
| 427 | + List []SystemArticleHistory `json:"list"` | ||
| 428 | + } | ||
| 429 | + SystemArticleHistory { | ||
| 422 | Id int64 `json:"id"` //id | 430 | Id int64 `json:"id"` //id |
| 423 | Author string `json:"author"` //编辑人 | 431 | Author string `json:"author"` //编辑人 |
| 424 | Action string `json:"action"` //编辑类型 | 432 | Action string `json:"action"` //编辑类型 |
| 425 | - UpdatedAt string `json:"updatedAt"` //编辑时间 | 433 | + UpdatedAt int64 `json:"updatedAt"` //编辑时间 |
| 434 | + } | ||
| 435 | + SystemArticleGetHistoryRequest { | ||
| 436 | + Id int64 `path:"id"` //id | ||
| 437 | + CompanyId int64 `path:",optional"` | ||
| 438 | + } | ||
| 439 | + SystemArticleGetHistoryResponse { | ||
| 440 | + Id int64 `json:"id"` // id | ||
| 441 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
| 442 | + Title string `json:"title"` // 标题 | ||
| 443 | + AuthorId int64 `json:"authorId"` // 发布人id | ||
| 444 | + Author ArticleAuthor `json:"author"` // 发布人 | ||
| 445 | + CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | ||
| 446 | + Section []ArticleSection `json:"section"` // 文章的文本内容 | ||
| 447 | + Images []string `json:"images"` // 图片 | ||
| 448 | + WhoRead []int64 `json:"whoRead"` // 谁可查看 | ||
| 449 | + WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | ||
| 450 | + WhoReview []int64 `json:"whoReview"` // 谁可评论 | ||
| 451 | + WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 | ||
| 452 | + Location Location `json:"location"` // 定位坐标 | ||
| 453 | + CountLove int `json:"countLove"` // 点赞数量 | ||
| 454 | + CountComment int `json:"countComment"` // 评论数量 | ||
| 455 | + CountRead int `json:"countRead"` // 浏览数量 | ||
| 456 | + Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | ||
| 457 | + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
| 426 | } | 458 | } |
| 427 | ) | 459 | ) |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemArticleGetHistoryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleGetHistoryRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + result.ParamErrorResult(r, w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemArticleGetHistoryLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleGetHistory(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| @@ -15,7 +15,7 @@ func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 15 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
| 16 | var req types.SystemArticleGetRequest | 16 | var req types.SystemArticleGetRequest |
| 17 | if err := httpx.Parse(r, &req); err != nil { | 17 | if err := httpx.Parse(r, &req); err != nil { |
| 18 | - httpx.ErrorCtx(r.Context(), w, err) | 18 | + result.ParamErrorResult(r, w, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| 1 | package article | 1 | package article |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 4 | "net/http" | 5 | "net/http" |
| 5 | 6 | ||
| 6 | "github.com/zeromicro/go-zero/rest/httpx" | 7 | "github.com/zeromicro/go-zero/rest/httpx" |
| @@ -13,16 +14,12 @@ func SystemHistoryArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -13,16 +14,12 @@ func SystemHistoryArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | return func(w http.ResponseWriter, r *http.Request) { | 14 | return func(w http.ResponseWriter, r *http.Request) { |
| 14 | var req types.SystemArticleHistoryRequest | 15 | var req types.SystemArticleHistoryRequest |
| 15 | if err := httpx.Parse(r, &req); err != nil { | 16 | if err := httpx.Parse(r, &req); err != nil { |
| 16 | - httpx.ErrorCtx(r.Context(), w, err) | 17 | + result.ParamErrorResult(r, w, err) |
| 17 | return | 18 | return |
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | l := article.NewSystemHistoryArticleLogic(r.Context(), svcCtx) | 21 | l := article.NewSystemHistoryArticleLogic(r.Context(), svcCtx) |
| 21 | resp, err := l.SystemHistoryArticle(&req) | 22 | resp, err := l.SystemHistoryArticle(&req) |
| 22 | - if err != nil { | ||
| 23 | - httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | - } else { | ||
| 25 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | - } | 23 | + result.HttpResult(r, w, resp, err) |
| 27 | } | 24 | } |
| 28 | } | 25 | } |
| @@ -15,7 +15,7 @@ func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 15 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
| 16 | var req types.SystemArticleSearchRequest | 16 | var req types.SystemArticleSearchRequest |
| 17 | if err := httpx.Parse(r, &req); err != nil { | 17 | if err := httpx.Parse(r, &req); err != nil { |
| 18 | - httpx.ErrorCtx(r.Context(), w, err) | 18 | + result.ParamErrorResult(r, w, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| 1 | package article | 1 | package article |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 4 | "net/http" | 5 | "net/http" |
| 5 | 6 | ||
| 6 | "github.com/zeromicro/go-zero/rest/httpx" | 7 | "github.com/zeromicro/go-zero/rest/httpx" |
| @@ -13,16 +14,11 @@ func SystemUpdateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -13,16 +14,11 @@ func SystemUpdateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | return func(w http.ResponseWriter, r *http.Request) { | 14 | return func(w http.ResponseWriter, r *http.Request) { |
| 14 | var req types.SystemArticleUpdateRequest | 15 | var req types.SystemArticleUpdateRequest |
| 15 | if err := httpx.Parse(r, &req); err != nil { | 16 | if err := httpx.Parse(r, &req); err != nil { |
| 16 | - httpx.ErrorCtx(r.Context(), w, err) | 17 | + result.ParamErrorResult(r, w, err) |
| 17 | return | 18 | return |
| 18 | } | 19 | } |
| 19 | - | ||
| 20 | l := article.NewSystemUpdateArticleLogic(r.Context(), svcCtx) | 20 | l := article.NewSystemUpdateArticleLogic(r.Context(), svcCtx) |
| 21 | - resp, err := l.SystemUpdateArticle(&req) | ||
| 22 | - if err != nil { | ||
| 23 | - httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | - } else { | ||
| 25 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | - } | 21 | + resp, err := l.SystemUpdateArticle(&req, r.Header.Get("x-mmm-accesstoken")) |
| 22 | + result.HttpResult(r, w, resp, err) | ||
| 27 | } | 23 | } |
| 28 | } | 24 | } |
| @@ -392,6 +392,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -392,6 +392,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 392 | Handler: article.SystemHistoryArticleHandler(serverCtx), | 392 | Handler: article.SystemHistoryArticleHandler(serverCtx), |
| 393 | }, | 393 | }, |
| 394 | { | 394 | { |
| 395 | + Method: http.MethodGet, | ||
| 396 | + Path: "/article/history/:id", | ||
| 397 | + Handler: article.SystemArticleGetHistoryHandler(serverCtx), | ||
| 398 | + }, | ||
| 399 | + { | ||
| 395 | Method: http.MethodPost, | 400 | Method: http.MethodPost, |
| 396 | Path: "/article/search/me", | 401 | Path: "/article/search/me", |
| 397 | Handler: article.SystemArticleSearchMeHandler(serverCtx), | 402 | Handler: article.SystemArticleSearchMeHandler(serverCtx), |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type SystemArticleGetHistoryLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewSystemArticleGetHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleGetHistoryLogic { | ||
| 19 | + return &SystemArticleGetHistoryLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.SystemArticleGetHistoryRequest) (resp *types.SystemArticleGetHistoryResponse, err error) { | ||
| 27 | + //var conn = l.svcCtx.DefaultDBConn() | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| @@ -63,6 +63,21 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ | @@ -63,6 +63,21 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ | ||
| 63 | CountComment: article.CountComment, | 63 | CountComment: article.CountComment, |
| 64 | CountRead: article.CountRead, | 64 | CountRead: article.CountRead, |
| 65 | Show: int(article.Show), | 65 | Show: int(article.Show), |
| 66 | + Tags: make([]types.ArticleTagItem, 0), | ||
| 67 | + } | ||
| 68 | + //标签 | ||
| 69 | + if len(article.Tags) > 0 { | ||
| 70 | + _, tags, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, article.CompanyId, domain.NewQueryOptions().WithKV("ids", article.Tags)) | ||
| 71 | + if err == nil && len(tags) > 0 { | ||
| 72 | + lo.ForEach(tags, func(tag *domain.ArticleTag, index int) { | ||
| 73 | + resp.Tags = append(resp.Tags, types.ArticleTagItem{ | ||
| 74 | + Id: tag.Id, | ||
| 75 | + Group: tag.Category, | ||
| 76 | + Name: tag.Name, | ||
| 77 | + Image: tag.Image.Url, | ||
| 78 | + }) | ||
| 79 | + }) | ||
| 80 | + } | ||
| 66 | } | 81 | } |
| 67 | //文章段落 | 82 | //文章段落 |
| 68 | _, articleSections, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithKV("articleId", req.Id)) | 83 | _, articleSections, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithKV("articleId", req.Id)) |
| @@ -2,7 +2,9 @@ package article | @@ -2,7 +2,9 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "github.com/samber/lo" | ||
| 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 6 | 8 | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| @@ -26,13 +28,30 @@ func NewSystemHistoryArticleLogic(ctx context.Context, svcCtx *svc.ServiceContex | @@ -26,13 +28,30 @@ func NewSystemHistoryArticleLogic(ctx context.Context, svcCtx *svc.ServiceContex | ||
| 26 | 28 | ||
| 27 | func (l *SystemHistoryArticleLogic) SystemHistoryArticle(req *types.SystemArticleHistoryRequest) (resp *types.SystemArticleHistoryResponse, err error) { | 29 | func (l *SystemHistoryArticleLogic) SystemHistoryArticle(req *types.SystemArticleHistoryRequest) (resp *types.SystemArticleHistoryResponse, err error) { |
| 28 | var conn = l.svcCtx.DefaultDBConn() | 30 | var conn = l.svcCtx.DefaultDBConn() |
| 29 | - l.svcCtx.ArticleBackupRepository.Find( | 31 | + total, list, err := l.svcCtx.ArticleBackupRepository.Find( |
| 30 | l.ctx, | 32 | l.ctx, |
| 31 | conn, | 33 | conn, |
| 32 | domain.NewQueryOptions(). | 34 | domain.NewQueryOptions(). |
| 35 | + WithOffsetLimit(req.Page, req.Size). | ||
| 33 | WithKV("articleId", req.ArticleId). | 36 | WithKV("articleId", req.ArticleId). |
| 34 | - WithKV("author", req.Author). | ||
| 35 | - WithKV("updatedAt", req.UpdatedAt), | 37 | + WithKV("operator", req.Author). |
| 38 | + WithKV("beginCreatedAt", req.BeginTime). | ||
| 39 | + WithKV("endCreatedAt", req.EndTime), | ||
| 36 | ) | 40 | ) |
| 41 | + if err != nil { | ||
| 42 | + return nil, xerr.NewErrMsgErr("搜索编辑历史异常", err) | ||
| 43 | + } | ||
| 44 | + resp = &types.SystemArticleHistoryResponse{ | ||
| 45 | + Total: int(total), | ||
| 46 | + List: make([]types.SystemArticleHistory, 0), | ||
| 47 | + } | ||
| 48 | + lo.ForEach(list, func(item *domain.ArticleBackup, index int) { | ||
| 49 | + resp.List = append(resp.List, types.SystemArticleHistory{ | ||
| 50 | + Id: item.Id, | ||
| 51 | + Author: item.Operator.Name, | ||
| 52 | + Action: item.Action, | ||
| 53 | + UpdatedAt: item.CreatedAt, | ||
| 54 | + }) | ||
| 55 | + }) | ||
| 37 | return | 56 | return |
| 38 | } | 57 | } |
| @@ -2,14 +2,11 @@ package article | @@ -2,14 +2,11 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | - "github.com/jinzhu/now" | ||
| 6 | "github.com/samber/lo" | 5 | "github.com/samber/lo" |
| 7 | - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 9 | - "time" | ||
| 10 | - | ||
| 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 13 | 10 | ||
| 14 | "github.com/zeromicro/go-zero/core/logx" | 11 | "github.com/zeromicro/go-zero/core/logx" |
| 15 | ) | 12 | ) |
| @@ -30,14 +27,12 @@ func NewSystemSearchArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext | @@ -30,14 +27,12 @@ func NewSystemSearchArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext | ||
| 30 | 27 | ||
| 31 | func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleSearchRequest) (resp *types.SystemArticleSearchResponse, err error) { | 28 | func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleSearchRequest) (resp *types.SystemArticleSearchResponse, err error) { |
| 32 | var conn = l.svcCtx.DefaultDBConn() | 29 | var conn = l.svcCtx.DefaultDBConn() |
| 33 | - queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.PageNumber, req.PageSize).WithKV("title", req.Title).WithKV("author", req.Author) | ||
| 34 | - if req.PublishDate != "" { | ||
| 35 | - publishTime, err := now.ParseInLocation(time.Local, req.PublishDate) | ||
| 36 | - if err == nil { | ||
| 37 | - queryOptions.WithKV("beginCreatedAt", now.With(publishTime).BeginningOfDay().Unix()) | ||
| 38 | - queryOptions.WithKV("endCreatedAt", now.With(publishTime).EndOfDay().Unix()) | ||
| 39 | - } | ||
| 40 | - } | 30 | + queryOptions := domain.NewQueryOptions(). |
| 31 | + WithOffsetLimit(req.Page, req.Size). | ||
| 32 | + WithKV("title", req.Title). | ||
| 33 | + WithKV("author", req.Author). | ||
| 34 | + WithKV("beginCreatedAt", req.BeginTime). | ||
| 35 | + WithKV("endCreatedAt", req.EndTime) | ||
| 41 | total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) | 36 | total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) |
| 42 | if err != nil { | 37 | if err != nil { |
| 43 | return nil, xerr.NewErrMsgErr("搜索帖子异常", err) | 38 | return nil, xerr.NewErrMsgErr("搜索帖子异常", err) |
| @@ -5,6 +5,8 @@ import ( | @@ -5,6 +5,8 @@ import ( | ||
| 5 | "github.com/samber/lo" | 5 | "github.com/samber/lo" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| 9 | 11 | ||
| 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| @@ -27,8 +29,9 @@ func NewSystemUpdateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext | @@ -27,8 +29,9 @@ func NewSystemUpdateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext | ||
| 27 | } | 29 | } |
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | -func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleUpdateRequest) (resp *types.SystemArticleUpdateResponse, err error) { | 32 | +func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleUpdateRequest, accessToken string) (resp *types.SystemArticleUpdateResponse, err error) { |
| 31 | var conn = l.svcCtx.DefaultDBConn() | 33 | var conn = l.svcCtx.DefaultDBConn() |
| 34 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 32 | article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id) | 35 | article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id) |
| 33 | if err != nil { | 36 | if err != nil { |
| 34 | return nil, xerr.NewErrMsgErr("帖子不存在", err) | 37 | return nil, xerr.NewErrMsgErr("帖子不存在", err) |
| @@ -53,6 +56,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -53,6 +56,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
| 53 | Latitude: req.Location.Latitude, | 56 | Latitude: req.Location.Latitude, |
| 54 | Descript: req.Location.Descript, | 57 | Descript: req.Location.Descript, |
| 55 | } | 58 | } |
| 59 | + article.Tags = req.Tags | ||
| 56 | //文章内容 | 60 | //文章内容 |
| 57 | articleSections := []domain.ArticleSection{} | 61 | articleSections := []domain.ArticleSection{} |
| 58 | lo.ForEach(req.Section, func(item types.ArticleSection, index int) { | 62 | lo.ForEach(req.Section, func(item types.ArticleSection, index int) { |
| @@ -79,8 +83,13 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -79,8 +83,13 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
| 79 | } | 83 | } |
| 80 | article.Summary = req.Section[0].Content[0:stringIndex] | 84 | article.Summary = req.Section[0].Content[0:stringIndex] |
| 81 | } | 85 | } |
| 86 | + //获取当前用户信息 | ||
| 87 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: accessToken}) | ||
| 88 | + if err != nil { | ||
| 89 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
| 90 | + } | ||
| 82 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 91 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
| 83 | - _, err = l.svcCtx.ArticleRepository.Update(l.ctx, conn, article) | 92 | + _, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article) |
| 84 | if err != nil { | 93 | if err != nil { |
| 85 | return xerr.NewErrMsgErr("保存文章失败", err) | 94 | return xerr.NewErrMsgErr("保存文章失败", err) |
| 86 | } | 95 | } |
| @@ -116,7 +125,13 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -116,7 +125,13 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
| 116 | } | 125 | } |
| 117 | } | 126 | } |
| 118 | //备份数据 | 127 | //备份数据 |
| 119 | - backup := article.MakeBackup(article.Author, articleSections) | 128 | + backup := article.MakeBackup(domain.UserSimple{ |
| 129 | + Id: userToken.UserId, | ||
| 130 | + Name: userMe.User.NickName, | ||
| 131 | + Avatar: userMe.User.Avatar, | ||
| 132 | + CompanyId: userToken.CompanyId, | ||
| 133 | + Company: userMe.CurrentCompany.Name, | ||
| 134 | + }, articleSections) | ||
| 120 | backup.Action = "编辑" | 135 | backup.Action = "编辑" |
| 121 | _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) | 136 | _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) |
| 122 | if err != nil { | 137 | if err != nil { |
| @@ -124,5 +139,16 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -124,5 +139,16 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
| 124 | } | 139 | } |
| 125 | return nil | 140 | return nil |
| 126 | }, true) | 141 | }, true) |
| 142 | + resp = &types.SystemArticleUpdateResponse{ | ||
| 143 | + Id: article.Id, | ||
| 144 | + Title: article.Title, | ||
| 145 | + Images: req.Images, | ||
| 146 | + CreatedAt: article.CreatedAt, | ||
| 147 | + CountLove: article.CountLove, | ||
| 148 | + CountComment: article.CountComment, | ||
| 149 | + Show: int(article.Show), | ||
| 150 | + TargetUser: int(article.TargetUser), | ||
| 151 | + Tags: article.Tags, | ||
| 152 | + } | ||
| 127 | return | 153 | return |
| 128 | } | 154 | } |
| @@ -890,15 +890,18 @@ type SystemArticleGetResponse struct { | @@ -890,15 +890,18 @@ type SystemArticleGetResponse struct { | ||
| 890 | CountComment int `json:"countComment"` // 评论数量 | 890 | CountComment int `json:"countComment"` // 评论数量 |
| 891 | CountRead int `json:"countRead"` // 浏览数量 | 891 | CountRead int `json:"countRead"` // 浏览数量 |
| 892 | Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | 892 | Show int `json:"show"` // 评论的展示状态(0显示、1不显示) |
| 893 | + Tags []ArticleTagItem `json:"tags"` //标签 | ||
| 893 | } | 894 | } |
| 894 | 895 | ||
| 895 | type SystemArticleSearchRequest struct { | 896 | type SystemArticleSearchRequest struct { |
| 896 | - CompanyId int64 `json:",optional"` | ||
| 897 | - Title string `json:"title"` //标题 | ||
| 898 | - Author string `json:"author"` //发布人 | ||
| 899 | - PublishDate string `json:"publishDate"` //发布日期 | ||
| 900 | - PageNumber int `json:"pageNumber"` //页码 | ||
| 901 | - PageSize int `json:"pageSize"` //每页行数 | 897 | + CompanyId int64 `json:"companyId,optional"` |
| 898 | + Title string `json:"title,optional"` //标题 | ||
| 899 | + Author string `json:"author,optional"` //发布人 | ||
| 900 | + BeginTime int64 `json:"beginTime,optional"` //开始时间 | ||
| 901 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
| 902 | + Tags []int64 `json:"tags,optional"` //标签 | ||
| 903 | + Page int `json:"page"` //页码 | ||
| 904 | + Size int `json:"size"` //每页行数 | ||
| 902 | } | 905 | } |
| 903 | 906 | ||
| 904 | type SystemArticleSearchResponse struct { | 907 | type SystemArticleSearchResponse struct { |
| @@ -921,7 +924,7 @@ type SystemArticleSearch struct { | @@ -921,7 +924,7 @@ type SystemArticleSearch struct { | ||
| 921 | 924 | ||
| 922 | type SystemArticleUpdateRequest struct { | 925 | type SystemArticleUpdateRequest struct { |
| 923 | Id int64 `json:"id"` | 926 | Id int64 `json:"id"` |
| 924 | - CompanyId int64 `json:",optional"` | 927 | + CompanyId int64 `json:"companyId,optional"` |
| 925 | Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | 928 | Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 |
| 926 | Section []ArticleSection `json:"section"` // 填写的内容 | 929 | Section []ArticleSection `json:"section"` // 填写的内容 |
| 927 | Title string `json:"title"` // 标题 | 930 | Title string `json:"title"` // 标题 |
| @@ -930,6 +933,7 @@ type SystemArticleUpdateRequest struct { | @@ -930,6 +933,7 @@ type SystemArticleUpdateRequest struct { | ||
| 930 | WhoReview []int64 `json:"whoReview"` // 评论人 | 933 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 931 | Location Location `json:"location"` // 坐标 | 934 | Location Location `json:"location"` // 坐标 |
| 932 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 935 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| 936 | + Tags []int64 `json:"tags"` // 标签 | ||
| 933 | } | 937 | } |
| 934 | 938 | ||
| 935 | type SystemArticleUpdateResponse struct { | 939 | type SystemArticleUpdateResponse struct { |
| @@ -941,21 +945,55 @@ type SystemArticleUpdateResponse struct { | @@ -941,21 +945,55 @@ type SystemArticleUpdateResponse struct { | ||
| 941 | CountLove int `json:"countLove"` //点赞数量 | 945 | CountLove int `json:"countLove"` //点赞数量 |
| 942 | CountComment int `json:"CountComment"` //评论数量 | 946 | CountComment int `json:"CountComment"` //评论数量 |
| 943 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 947 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 944 | - Tags []string `json:"tags"` //标签 | 948 | + Tags []int64 `json:"tags"` //标签 |
| 945 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 949 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| 946 | } | 950 | } |
| 947 | 951 | ||
| 948 | type SystemArticleHistoryRequest struct { | 952 | type SystemArticleHistoryRequest struct { |
| 949 | ArticleId int64 `json:"articleId"` //文章ID | 953 | ArticleId int64 `json:"articleId"` //文章ID |
| 950 | Author string `json:"author,optional"` //发布人 | 954 | Author string `json:"author,optional"` //发布人 |
| 951 | - UpdatedAt string `json:"updatedAt,optional"` //修改日期 | 955 | + BeginTime int64 `json:"beginTime,optional"` //开始时间 |
| 956 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
| 957 | + Page int `json:"page"` //页码 | ||
| 958 | + Size int `json:"size"` //每页行数 | ||
| 952 | } | 959 | } |
| 953 | 960 | ||
| 954 | type SystemArticleHistoryResponse struct { | 961 | type SystemArticleHistoryResponse struct { |
| 962 | + Total int `json:"total"` | ||
| 963 | + List []SystemArticleHistory `json:"list"` | ||
| 964 | +} | ||
| 965 | + | ||
| 966 | +type SystemArticleHistory struct { | ||
| 955 | Id int64 `json:"id"` //id | 967 | Id int64 `json:"id"` //id |
| 956 | Author string `json:"author"` //编辑人 | 968 | Author string `json:"author"` //编辑人 |
| 957 | Action string `json:"action"` //编辑类型 | 969 | Action string `json:"action"` //编辑类型 |
| 958 | - UpdatedAt string `json:"updatedAt"` //编辑时间 | 970 | + UpdatedAt int64 `json:"updatedAt"` //编辑时间 |
| 971 | +} | ||
| 972 | + | ||
| 973 | +type SystemArticleGetHistoryRequest struct { | ||
| 974 | + Id int64 `path:"id"` //id | ||
| 975 | + CompanyId int64 `path:",optional"` | ||
| 976 | +} | ||
| 977 | + | ||
| 978 | +type SystemArticleGetHistoryResponse struct { | ||
| 979 | + Id int64 `json:"id"` // id | ||
| 980 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
| 981 | + Title string `json:"title"` // 标题 | ||
| 982 | + AuthorId int64 `json:"authorId"` // 发布人id | ||
| 983 | + Author ArticleAuthor `json:"author"` // 发布人 | ||
| 984 | + CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | ||
| 985 | + Section []ArticleSection `json:"section"` // 文章的文本内容 | ||
| 986 | + Images []string `json:"images"` // 图片 | ||
| 987 | + WhoRead []int64 `json:"whoRead"` // 谁可查看 | ||
| 988 | + WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | ||
| 989 | + WhoReview []int64 `json:"whoReview"` // 谁可评论 | ||
| 990 | + WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 | ||
| 991 | + Location Location `json:"location"` // 定位坐标 | ||
| 992 | + CountLove int `json:"countLove"` // 点赞数量 | ||
| 993 | + CountComment int `json:"countComment"` // 评论数量 | ||
| 994 | + CountRead int `json:"countRead"` // 浏览数量 | ||
| 995 | + Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | ||
| 996 | + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
| 959 | } | 997 | } |
| 960 | 998 | ||
| 961 | type RoleGetRequest struct { | 999 | type RoleGetRequest struct { |
| @@ -120,6 +120,18 @@ func (repository *ArticleBackupRepository) Find(ctx context.Context, conn transa | @@ -120,6 +120,18 @@ func (repository *ArticleBackupRepository) Find(ctx context.Context, conn transa | ||
| 120 | ) | 120 | ) |
| 121 | queryFunc := func() (interface{}, error) { | 121 | queryFunc := func() (interface{}, error) { |
| 122 | tx = tx.Model(&ms).Order("id desc") | 122 | tx = tx.Model(&ms).Order("id desc") |
| 123 | + if v, ok := queryOptions["beginCreatedAt"]; ok { | ||
| 124 | + tx = tx.Where("created_at >= ?", v) | ||
| 125 | + } | ||
| 126 | + if v, ok := queryOptions["endCreatedAt"]; ok { | ||
| 127 | + tx = tx.Where("created_at < ?", v) | ||
| 128 | + } | ||
| 129 | + if v, ok := queryOptions["articleId"]; ok { | ||
| 130 | + tx = tx.Where("article_id = ?", v) | ||
| 131 | + } | ||
| 132 | + if v, ok := queryOptions["operator"]; ok && v.(string) != "" { | ||
| 133 | + tx = tx.Where(`operator #>> '{"name"}' like ?`, "%"+v.(string)+"%") | ||
| 134 | + } | ||
| 123 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 135 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
| 124 | return dms, tx.Error | 136 | return dms, tx.Error |
| 125 | } | 137 | } |
| @@ -126,7 +126,7 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -126,7 +126,7 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
| 126 | if v, ok := queryOptions["title"]; ok && v.(string) != "" { | 126 | if v, ok := queryOptions["title"]; ok && v.(string) != "" { |
| 127 | tx = tx.Where("title like ?", "%"+v.(string)+"%") | 127 | tx = tx.Where("title like ?", "%"+v.(string)+"%") |
| 128 | } | 128 | } |
| 129 | - if v, ok := queryOptions["author"]; ok { | 129 | + if v, ok := queryOptions["author"]; ok && v.(string) != "" { |
| 130 | tx = tx.Where(`author #>> '{"name"}' like ?`, "%"+v.(string)+"%") | 130 | tx = tx.Where(`author #>> '{"name"}' like ?`, "%"+v.(string)+"%") |
| 131 | } | 131 | } |
| 132 | if v, ok := queryOptions["beginCreatedAt"]; ok { | 132 | if v, ok := queryOptions["beginCreatedAt"]; ok { |
| @@ -130,6 +130,9 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti | @@ -130,6 +130,9 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti | ||
| 130 | if v, ok := queryOptions["category"]; ok { | 130 | if v, ok := queryOptions["category"]; ok { |
| 131 | tx = tx.Where("category like ?", v) | 131 | tx = tx.Where("category like ?", v) |
| 132 | } | 132 | } |
| 133 | + if v, ok := queryOptions["ids"]; ok { | ||
| 134 | + tx = tx.Where("id in (?)", v) | ||
| 135 | + } | ||
| 133 | 136 | ||
| 134 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 137 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
| 135 | return dms, tx.Error | 138 | return dms, tx.Error |
| @@ -86,7 +86,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *Art | @@ -86,7 +86,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *Art | ||
| 86 | CreatedAt: 0, | 86 | CreatedAt: 0, |
| 87 | UpdatedAt: 0, | 87 | UpdatedAt: 0, |
| 88 | DeletedAt: 0, | 88 | DeletedAt: 0, |
| 89 | - Version: 0, | 89 | + Version: m.Version, |
| 90 | Operator: operator, | 90 | Operator: operator, |
| 91 | ArticleId: m.Id, | 91 | ArticleId: m.Id, |
| 92 | Title: m.Title, | 92 | Title: m.Title, |
-
请 注册 或 登录 后发表评论