正在显示
61 个修改的文件
包含
950 行增加
和
234 行删除
| @@ -751,32 +751,6 @@ | @@ -751,32 +751,6 @@ | ||
| 751 | ] | 751 | ] |
| 752 | } | 752 | } |
| 753 | }, | 753 | }, |
| 754 | - "v1/mini/user/at-users-list": { | ||
| 755 | - "post": { | ||
| 756 | - "summary": "@用户列表", | ||
| 757 | - "operationId": "miniAtUsersList", | ||
| 758 | - "responses": { | ||
| 759 | - "200": { | ||
| 760 | - "description": "A successful response.", | ||
| 761 | - "schema": {} | ||
| 762 | - } | ||
| 763 | - }, | ||
| 764 | - "parameters": [ | ||
| 765 | - { | ||
| 766 | - "name": "body", | ||
| 767 | - "in": "body", | ||
| 768 | - "required": true, | ||
| 769 | - "schema": { | ||
| 770 | - "$ref": "#/definitions/MiniAtUsersListRequest" | ||
| 771 | - } | ||
| 772 | - } | ||
| 773 | - ], | ||
| 774 | - "requestBody": {}, | ||
| 775 | - "tags": [ | ||
| 776 | - "user" | ||
| 777 | - ] | ||
| 778 | - } | ||
| 779 | - }, | ||
| 780 | "v1/mini/user/audit": { | 754 | "v1/mini/user/audit": { |
| 781 | "post": { | 755 | "post": { |
| 782 | "summary": "用户审核", | 756 | "summary": "用户审核", |
| @@ -838,7 +812,9 @@ | @@ -838,7 +812,9 @@ | ||
| 838 | "responses": { | 812 | "responses": { |
| 839 | "200": { | 813 | "200": { |
| 840 | "description": "A successful response.", | 814 | "description": "A successful response.", |
| 841 | - "schema": {} | 815 | + "schema": { |
| 816 | + "$ref": "#/definitions/MiniUserInfoResponse" | ||
| 817 | + } | ||
| 842 | } | 818 | } |
| 843 | }, | 819 | }, |
| 844 | "parameters": [ | 820 | "parameters": [ |
| @@ -1275,6 +1251,34 @@ | @@ -1275,6 +1251,34 @@ | ||
| 1275 | ] | 1251 | ] |
| 1276 | } | 1252 | } |
| 1277 | }, | 1253 | }, |
| 1254 | + "v1/system/article/restore": { | ||
| 1255 | + "post": { | ||
| 1256 | + "summary": "管理后台文章恢复", | ||
| 1257 | + "operationId": "SystemArticleRestore", | ||
| 1258 | + "responses": { | ||
| 1259 | + "200": { | ||
| 1260 | + "description": "A successful response.", | ||
| 1261 | + "schema": { | ||
| 1262 | + "$ref": "#/definitions/SystemArticleRestoreResponse" | ||
| 1263 | + } | ||
| 1264 | + } | ||
| 1265 | + }, | ||
| 1266 | + "parameters": [ | ||
| 1267 | + { | ||
| 1268 | + "name": "body", | ||
| 1269 | + "in": "body", | ||
| 1270 | + "required": true, | ||
| 1271 | + "schema": { | ||
| 1272 | + "$ref": "#/definitions/SystemArticleRestoreRequest" | ||
| 1273 | + } | ||
| 1274 | + } | ||
| 1275 | + ], | ||
| 1276 | + "requestBody": {}, | ||
| 1277 | + "tags": [ | ||
| 1278 | + "article" | ||
| 1279 | + ] | ||
| 1280 | + } | ||
| 1281 | + }, | ||
| 1278 | "v1/system/article/search": { | 1282 | "v1/system/article/search": { |
| 1279 | "post": { | 1283 | "post": { |
| 1280 | "summary": "管理后台获取文章列表", | 1284 | "summary": "管理后台获取文章列表", |
| @@ -3823,17 +3827,6 @@ | @@ -3823,17 +3827,6 @@ | ||
| 3823 | "id" | 3827 | "id" |
| 3824 | ] | 3828 | ] |
| 3825 | }, | 3829 | }, |
| 3826 | - "MiniAtUsersListRequest": { | ||
| 3827 | - "type": "object", | ||
| 3828 | - "properties": { | ||
| 3829 | - "articleId": { | ||
| 3830 | - "type": "integer", | ||
| 3831 | - "format": "int64", | ||
| 3832 | - "description": " 按文章ID(返回文章可见的用户)" | ||
| 3833 | - } | ||
| 3834 | - }, | ||
| 3835 | - "title": "MiniAtUsersListRequest" | ||
| 3836 | - }, | ||
| 3837 | "MiniCreateArticleCommentRequest": { | 3830 | "MiniCreateArticleCommentRequest": { |
| 3838 | "type": "object", | 3831 | "type": "object", |
| 3839 | "properties": { | 3832 | "properties": { |
| @@ -4337,6 +4330,21 @@ | @@ -4337,6 +4330,21 @@ | ||
| 4337 | "$ref": "#/definitions/UserItem", | 4330 | "$ref": "#/definitions/UserItem", |
| 4338 | "description": " 用户信息" | 4331 | "description": " 用户信息" |
| 4339 | }, | 4332 | }, |
| 4333 | + "totalArticle": { | ||
| 4334 | + "type": "integer", | ||
| 4335 | + "format": "int64", | ||
| 4336 | + "description": " 累计信息发布" | ||
| 4337 | + }, | ||
| 4338 | + "totalLoved": { | ||
| 4339 | + "type": "integer", | ||
| 4340 | + "format": "int64", | ||
| 4341 | + "description": " 累计收到的赞" | ||
| 4342 | + }, | ||
| 4343 | + "totalAccepted": { | ||
| 4344 | + "type": "integer", | ||
| 4345 | + "format": "int64", | ||
| 4346 | + "description": " 累计被采纳" | ||
| 4347 | + }, | ||
| 4340 | "accounts": { | 4348 | "accounts": { |
| 4341 | "type": "array", | 4349 | "type": "array", |
| 4342 | "items": { | 4350 | "items": { |
| @@ -4355,6 +4363,9 @@ | @@ -4355,6 +4363,9 @@ | ||
| 4355 | "title": "MiniUserInfoResponse", | 4363 | "title": "MiniUserInfoResponse", |
| 4356 | "required": [ | 4364 | "required": [ |
| 4357 | "user", | 4365 | "user", |
| 4366 | + "totalArticle", | ||
| 4367 | + "totalLoved", | ||
| 4368 | + "totalAccepted", | ||
| 4358 | "accounts", | 4369 | "accounts", |
| 4359 | "auths" | 4370 | "auths" |
| 4360 | ] | 4371 | ] |
| @@ -4969,15 +4980,6 @@ | @@ -4969,15 +4980,6 @@ | ||
| 4969 | "type": "string", | 4980 | "type": "string", |
| 4970 | "description": " 标题" | 4981 | "description": " 标题" |
| 4971 | }, | 4982 | }, |
| 4972 | - "authorId": { | ||
| 4973 | - "type": "integer", | ||
| 4974 | - "format": "int64", | ||
| 4975 | - "description": " 发布人id" | ||
| 4976 | - }, | ||
| 4977 | - "author": { | ||
| 4978 | - "$ref": "#/definitions/ArticleAuthor", | ||
| 4979 | - "description": " 发布人" | ||
| 4980 | - }, | ||
| 4981 | "createdAt": { | 4983 | "createdAt": { |
| 4982 | "type": "integer", | 4984 | "type": "integer", |
| 4983 | "format": "int64", | 4985 | "format": "int64", |
| @@ -5031,30 +5033,18 @@ | @@ -5031,30 +5033,18 @@ | ||
| 5031 | "$ref": "#/definitions/Location", | 5033 | "$ref": "#/definitions/Location", |
| 5032 | "description": " 定位坐标" | 5034 | "description": " 定位坐标" |
| 5033 | }, | 5035 | }, |
| 5034 | - "countLove": { | ||
| 5035 | - "type": "integer", | ||
| 5036 | - "format": "int32", | ||
| 5037 | - "description": " 点赞数量" | ||
| 5038 | - }, | ||
| 5039 | - "countComment": { | ||
| 5040 | - "type": "integer", | ||
| 5041 | - "format": "int32", | ||
| 5042 | - "description": " 评论数量" | ||
| 5043 | - }, | ||
| 5044 | - "countRead": { | ||
| 5045 | - "type": "integer", | ||
| 5046 | - "format": "int32", | ||
| 5047 | - "description": " 浏览数量" | ||
| 5048 | - }, | ||
| 5049 | - "show": { | ||
| 5050 | - "type": "integer", | ||
| 5051 | - "format": "int32", | ||
| 5052 | - "description": " 评论的展示状态(0显示、1不显示)" | ||
| 5053 | - }, | ||
| 5054 | "targetUser": { | 5036 | "targetUser": { |
| 5055 | "type": "integer", | 5037 | "type": "integer", |
| 5056 | "format": "int32", | 5038 | "format": "int32", |
| 5057 | - "description": "分发方式 [0分发给所有人、1分发给指定的人]" | 5039 | + "description": " 分发方式 [0分发给所有人、1分发给指定的人]" |
| 5040 | + }, | ||
| 5041 | + "tags": { | ||
| 5042 | + "type": "array", | ||
| 5043 | + "items": { | ||
| 5044 | + "type": "integer", | ||
| 5045 | + "format": "int64" | ||
| 5046 | + }, | ||
| 5047 | + "description": " 标签" | ||
| 5058 | } | 5048 | } |
| 5059 | }, | 5049 | }, |
| 5060 | "title": "SystemArticleGetHistoryResponse", | 5050 | "title": "SystemArticleGetHistoryResponse", |
| @@ -5062,8 +5052,6 @@ | @@ -5062,8 +5052,6 @@ | ||
| 5062 | "id", | 5052 | "id", |
| 5063 | "articleId", | 5053 | "articleId", |
| 5064 | "title", | 5054 | "title", |
| 5065 | - "authorId", | ||
| 5066 | - "author", | ||
| 5067 | "createdAt", | 5055 | "createdAt", |
| 5068 | "section", | 5056 | "section", |
| 5069 | "images", | 5057 | "images", |
| @@ -5072,11 +5060,8 @@ | @@ -5072,11 +5060,8 @@ | ||
| 5072 | "whoReview", | 5060 | "whoReview", |
| 5073 | "whoReviewInfo", | 5061 | "whoReviewInfo", |
| 5074 | "location", | 5062 | "location", |
| 5075 | - "countLove", | ||
| 5076 | - "countComment", | ||
| 5077 | - "countRead", | ||
| 5078 | - "show", | ||
| 5079 | - "targetUser" | 5063 | + "targetUser", |
| 5064 | + "tags" | ||
| 5080 | ] | 5065 | ] |
| 5081 | }, | 5066 | }, |
| 5082 | "SystemArticleGetRequest": { | 5067 | "SystemArticleGetRequest": { |
| @@ -5310,6 +5295,45 @@ | @@ -5310,6 +5295,45 @@ | ||
| 5310 | "list" | 5295 | "list" |
| 5311 | ] | 5296 | ] |
| 5312 | }, | 5297 | }, |
| 5298 | + "SystemArticleRestoreRequest": { | ||
| 5299 | + "type": "object", | ||
| 5300 | + "properties": { | ||
| 5301 | + "id": { | ||
| 5302 | + "type": "integer", | ||
| 5303 | + "format": "int64", | ||
| 5304 | + "description": "ID" | ||
| 5305 | + }, | ||
| 5306 | + "AccessToken": { | ||
| 5307 | + "type": "string", | ||
| 5308 | + "description": " 授权token" | ||
| 5309 | + } | ||
| 5310 | + }, | ||
| 5311 | + "title": "SystemArticleRestoreRequest", | ||
| 5312 | + "required": [ | ||
| 5313 | + "id", | ||
| 5314 | + "x-mmm-accesstoken" | ||
| 5315 | + ] | ||
| 5316 | + }, | ||
| 5317 | + "SystemArticleRestoreResponse": { | ||
| 5318 | + "type": "object", | ||
| 5319 | + "properties": { | ||
| 5320 | + "id": { | ||
| 5321 | + "type": "integer", | ||
| 5322 | + "format": "int64", | ||
| 5323 | + "description": "ID" | ||
| 5324 | + }, | ||
| 5325 | + "articleId": { | ||
| 5326 | + "type": "integer", | ||
| 5327 | + "format": "int64", | ||
| 5328 | + "description": "文章ID" | ||
| 5329 | + } | ||
| 5330 | + }, | ||
| 5331 | + "title": "SystemArticleRestoreResponse", | ||
| 5332 | + "required": [ | ||
| 5333 | + "id", | ||
| 5334 | + "articleId" | ||
| 5335 | + ] | ||
| 5336 | + }, | ||
| 5313 | "SystemArticleSearch": { | 5337 | "SystemArticleSearch": { |
| 5314 | "type": "object", | 5338 | "type": "object", |
| 5315 | "properties": { | 5339 | "properties": { |
| @@ -72,6 +72,14 @@ service Core { | @@ -72,6 +72,14 @@ service Core { | ||
| 72 | @doc "小程序所有的定性标签" | 72 | @doc "小程序所有的定性标签" |
| 73 | @handler MiniAllArticleTag | 73 | @handler MiniAllArticleTag |
| 74 | get /article_tag/list/all (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse) | 74 | get /article_tag/list/all (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse) |
| 75 | + | ||
| 76 | + @doc "小程序首页数据展示" | ||
| 77 | + @handler MiniShowHomePage | ||
| 78 | + get /show/home_page (MiniHomePageRequest) returns (MiniHomePageResponse) | ||
| 79 | + | ||
| 80 | + @doc "小程序首页搜索文章" | ||
| 81 | + @handler MiniSearchArticlePage | ||
| 82 | + post /show/search_article (MiniSearchArticleRequest) returns (MiniSearchArticleResponse) | ||
| 75 | } | 83 | } |
| 76 | 84 | ||
| 77 | // 管理后台接口 | 85 | // 管理后台接口 |
| @@ -105,4 +113,7 @@ service Core { | @@ -105,4 +113,7 @@ service Core { | ||
| 105 | @handler SystemArticleSearchMe | 113 | @handler SystemArticleSearchMe |
| 106 | post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse) | 114 | post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse) |
| 107 | 115 | ||
| 116 | + @doc "管理后台文章恢复" | ||
| 117 | + @handler SystemArticleRestore | ||
| 118 | + post /article/restore (SystemArticleRestoreRequest) returns (SystemArticleRestoreResponse) | ||
| 108 | } | 119 | } |
| @@ -53,9 +53,10 @@ type ( | @@ -53,9 +53,10 @@ type ( | ||
| 53 | CountLove int `json:"countLove"` // 点赞数量 | 53 | CountLove int `json:"countLove"` // 点赞数量 |
| 54 | CountComment int `json:"countComment"` // 评论数量 | 54 | CountComment int `json:"countComment"` // 评论数量 |
| 55 | CountRead int `json:"countRead"` // 浏览数量 | 55 | CountRead int `json:"countRead"` // 浏览数量 |
| 56 | - Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | 56 | + Show int `json:"show"` // 评论的展示状态(1显示、2不显示) |
| 57 | Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) | 57 | Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) |
| 58 | MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞) | 58 | MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞) |
| 59 | + Tags []string `json:"tags"` //文章的标签 | ||
| 59 | } | 60 | } |
| 60 | ArticleSection { | 61 | ArticleSection { |
| 61 | Id int64 `json:"id"` //段落id | 62 | Id int64 `json:"id"` //段落id |
| @@ -281,13 +282,13 @@ type ( | @@ -281,13 +282,13 @@ type ( | ||
| 281 | } | 282 | } |
| 282 | 283 | ||
| 283 | MiniArticleMarkItem { | 284 | MiniArticleMarkItem { |
| 284 | - Id int64 `json:"id"` | ||
| 285 | - CompanyId int64 `json:"companyId"` | ||
| 286 | - UserId int64 `json:"userId"` | ||
| 287 | - ArticleId int64 `json:"articleId"` | ||
| 288 | - Title string `json:"title"` | 285 | + Id int64 `json:"id"` |
| 286 | + CompanyId int64 `json:"companyId"` | ||
| 287 | + UserId int64 `json:"userId"` | ||
| 288 | + ArticleId int64 `json:"articleId"` | ||
| 289 | + Title string `json:"title"` | ||
| 289 | Author SimpleUser `json:"author"` // 发布人 | 290 | Author SimpleUser `json:"author"` // 发布人 |
| 290 | - UpdatedAt int64 `json:"updatedAt"` | 291 | + UpdatedAt int64 `json:"updatedAt"` |
| 291 | } | 292 | } |
| 292 | ) | 293 | ) |
| 293 | 294 | ||
| @@ -314,14 +315,14 @@ type ( | @@ -314,14 +315,14 @@ type ( | ||
| 314 | TagGroup []ArticleTagGroup `json:"tagGroup"` | 315 | TagGroup []ArticleTagGroup `json:"tagGroup"` |
| 315 | } | 316 | } |
| 316 | ArticleTagGroup { | 317 | ArticleTagGroup { |
| 317 | - Group string `json:"group"` | 318 | + Category string `json:"category"` |
| 318 | Tags []ArticleTagItem `json:"tags"` | 319 | Tags []ArticleTagItem `json:"tags"` |
| 319 | } | 320 | } |
| 320 | ArticleTagItem { | 321 | ArticleTagItem { |
| 321 | - Id int64 `json:"id"` | ||
| 322 | - Group string `json:"group"` | ||
| 323 | - Name string `json:"name"` | ||
| 324 | - Image string `json:"image"` | 322 | + Id int64 `json:"id"` |
| 323 | + Category string `json:"category"` | ||
| 324 | + Name string `json:"name"` | ||
| 325 | + Image string `json:"image"` | ||
| 325 | } | 326 | } |
| 326 | ) | 327 | ) |
| 327 | 328 | ||
| @@ -389,17 +390,18 @@ type ( | @@ -389,17 +390,18 @@ type ( | ||
| 389 | } | 390 | } |
| 390 | //编辑 | 391 | //编辑 |
| 391 | SystemArticleUpdateRequest { | 392 | SystemArticleUpdateRequest { |
| 392 | - Id int64 `json:"id"` | ||
| 393 | - CompanyId int64 `json:"companyId,optional"` | ||
| 394 | - Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
| 395 | - Section []ArticleSection `json:"section"` // 填写的内容 | ||
| 396 | - Title string `json:"title"` // 标题 | ||
| 397 | - Images []string `json:"images"` // 图片 | ||
| 398 | - WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
| 399 | - WhoReview []int64 `json:"whoReview"` // 评论人 | ||
| 400 | - Location Location `json:"location"` // 坐标 | ||
| 401 | - TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
| 402 | - Tags []int64 `json:"tags"` // 标签 | 393 | + Id int64 `json:"id"` |
| 394 | + CompanyId int64 `json:"companyId,optional"` | ||
| 395 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
| 396 | + Section []ArticleSection `json:"section"` // 填写的内容 | ||
| 397 | + Title string `json:"title"` // 标题 | ||
| 398 | + Images []string `json:"images"` // 图片 | ||
| 399 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
| 400 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
| 401 | + Location Location `json:"location"` // 坐标 | ||
| 402 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 403 | + Tags []int64 `json:"tags"` // 标签 | ||
| 404 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 403 | } | 405 | } |
| 404 | SystemArticleUpdateResponse { | 406 | SystemArticleUpdateResponse { |
| 405 | Id int64 `json:"id"` //id | 407 | Id int64 `json:"id"` //id |
| @@ -408,7 +410,7 @@ type ( | @@ -408,7 +410,7 @@ type ( | ||
| 408 | Images []string `json:"images"` //图片 | 410 | Images []string `json:"images"` //图片 |
| 409 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 411 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
| 410 | CountLove int `json:"countLove"` //点赞数量 | 412 | CountLove int `json:"countLove"` //点赞数量 |
| 411 | - CountComment int `json:"CountComment"` //评论数量 | 413 | + CountComment int `json:"countComment"` //评论数量 |
| 412 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 414 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 413 | Tags []int64 `json:"tags"` //标签 | 415 | Tags []int64 `json:"tags"` //标签 |
| 414 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 416 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| @@ -440,8 +442,6 @@ type ( | @@ -440,8 +442,6 @@ type ( | ||
| 440 | Id int64 `json:"id"` // id | 442 | Id int64 `json:"id"` // id |
| 441 | ArticleId int64 `json:"articleId"` // 文章ID | 443 | ArticleId int64 `json:"articleId"` // 文章ID |
| 442 | Title string `json:"title"` // 标题 | 444 | Title string `json:"title"` // 标题 |
| 443 | - AuthorId int64 `json:"authorId"` // 发布人id | ||
| 444 | - Author ArticleAuthor `json:"author"` // 发布人 | ||
| 445 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | 445 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 |
| 446 | Section []ArticleSection `json:"section"` // 文章的文本内容 | 446 | Section []ArticleSection `json:"section"` // 文章的文本内容 |
| 447 | Images []string `json:"images"` // 图片 | 447 | Images []string `json:"images"` // 图片 |
| @@ -450,10 +450,66 @@ type ( | @@ -450,10 +450,66 @@ type ( | ||
| 450 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 450 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
| 451 | WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 | 451 | WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 |
| 452 | Location Location `json:"location"` // 定位坐标 | 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分发给指定的人] | 453 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
| 454 | + Tags []int64 `json:"tags"` // 标签 | ||
| 455 | + } | ||
| 456 | + SystemArticleRestoreRequest { | ||
| 457 | + Id int64 `json:"id"` //ID | ||
| 458 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 459 | + } | ||
| 460 | + SystemArticleRestoreResponse { | ||
| 461 | + Id int64 `json:"id"` //ID | ||
| 462 | + ArticleId int64 `json:"articleId"` //文章ID | ||
| 463 | + } | ||
| 464 | +) | ||
| 465 | + | ||
| 466 | +//小程序端 首页数据展示 | ||
| 467 | +// 统计各标签下的文章数量,和已被人员阅读的数量 | ||
| 468 | +type ( | ||
| 469 | + MiniHomePageRequest { | ||
| 470 | + CompanyId int64 `path:",optional"` | ||
| 471 | + UserId int64 `path:",optional"` | ||
| 472 | + } | ||
| 473 | + MiniHomePageResponse { | ||
| 474 | + TagCategory []string `json:"tagCategory"` | ||
| 475 | + Tags []ArticleTagCount `json:"tags"` | ||
| 476 | + } | ||
| 477 | + ArticleTagCount { | ||
| 478 | + TagCategory string `json:"tagCategory"` // 标签分组 | ||
| 479 | + TagId int64 `json:"tagId"` // 标签id | ||
| 480 | + TagImage string `json:"tagImage"` // 对应的图标 | ||
| 481 | + TagName string `json:"tagName"` // 标签名称 | ||
| 482 | + TagRemark string `json:"tagRemark"` // 标签备注 | ||
| 483 | + TotalArticle int `json:"totalArticle"` // 总的文章数量 | ||
| 484 | + ReadArticle int `json:"readArticle"` // 已读的标签数量 | ||
| 485 | + } | ||
| 486 | +) | ||
| 487 | + | ||
| 488 | +//小程序首页搜索文章 | ||
| 489 | +type ( | ||
| 490 | + MiniSearchArticleRequest { | ||
| 491 | + Page int `json:"page"` | ||
| 492 | + Size int `json:"size"` | ||
| 493 | + CompanyId int64 `json:",optional"` | ||
| 494 | + UserId int64 `json:",optional"` | ||
| 495 | + TagGroup string `json:"tagGroup"` | ||
| 496 | + TagId int64 `json:"tagId"` | ||
| 497 | + BeginTime int64 `json:"beginTime"` | ||
| 498 | + EndTime int `json:"endTime"` | ||
| 499 | + SearchWord string `json:"searchWord"` | ||
| 500 | + } | ||
| 501 | + // | ||
| 502 | + MiniSearchArticleResponse { | ||
| 503 | + Total int `json:"total"` | ||
| 504 | + List []MiniSearchArticleItem `json:"list"` | ||
| 505 | + } | ||
| 506 | + // | ||
| 507 | + MiniSearchArticleItem{ | ||
| 508 | + ArticleId int64 `json:"articleId"` | ||
| 509 | + Title string `json:"title"` | ||
| 510 | + Author string `json:"author"` // 发布人 | ||
| 511 | + Images []string `json:"images"` | ||
| 512 | + CreatedAt int64 `json:"createdAt"` | ||
| 513 | + MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] | ||
| 458 | } | 514 | } |
| 459 | ) | 515 | ) |
| @@ -15,7 +15,7 @@ func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func MiniAllArticleTagHandler(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.MiniAllArticleTagRequest | 16 | var req types.MiniAllArticleTagRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func MiniArticleBackupSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | @@ -15,7 +15,7 @@ func MiniArticleBackupSearchHandler(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.MiniArticleBackupSearchRequest | 16 | var req types.MiniArticleBackupSearchRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | token := contextdata.GetUserTokenFromCtx(r.Context()) | 21 | token := contextdata.GetUserTokenFromCtx(r.Context()) |
| 1 | package article | 1 | package article |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | "net/http" | 4 | "net/http" |
| 6 | 5 | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 7 | + | ||
| 7 | "github.com/zeromicro/go-zero/rest/httpx" | 8 | "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/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/svc" |
| @@ -14,7 +15,7 @@ func MiniArticleMarkListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -14,7 +15,7 @@ func MiniArticleMarkListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
| 15 | var req types.MiniArticleMarkListRequest | 16 | var req types.MiniArticleMarkListRequest |
| 16 | if err := httpx.Parse(r, &req); err != nil { | 17 | if err := httpx.Parse(r, &req); err != nil { |
| 17 | - httpx.ErrorCtx(r.Context(), w, err) | 18 | + result.HttpResult(r, w, nil, err) |
| 18 | return | 19 | return |
| 19 | } | 20 | } |
| 20 | 21 |
| @@ -16,7 +16,7 @@ func MiniArticleMarkUserReadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | @@ -16,7 +16,7 @@ func MiniArticleMarkUserReadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | ||
| 16 | return func(w http.ResponseWriter, r *http.Request) { | 16 | return func(w http.ResponseWriter, r *http.Request) { |
| 17 | var req types.MiniArticleMarkUserReadRequest | 17 | var req types.MiniArticleMarkUserReadRequest |
| 18 | if err := httpx.Parse(r, &req); err != nil { | 18 | if err := httpx.Parse(r, &req); err != nil { |
| 19 | - httpx.ErrorCtx(r.Context(), w, err) | 19 | + result.HttpResult(r, w, nil, err) |
| 20 | return | 20 | return |
| 21 | } | 21 | } |
| 22 | 22 |
| @@ -15,7 +15,7 @@ func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func MiniArticleSearchMeHandler(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.MiniArticleSearchMeRequest | 16 | var req types.MiniArticleSearchMeRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func MiniArticleSetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func MiniArticleSetTagHandler(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.MiniArticleSetTagRequest | 16 | var req types.MiniArticleSetTagRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func MiniCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | @@ -15,7 +15,7 @@ func MiniCreateArticleDraftHandler(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.MiniArticleDraftCreateRequest | 16 | var req types.MiniArticleDraftCreateRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func MiniCreateArticleHandler(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.MiniArticleCreateRequest | 16 | var req types.MiniArticleCreateRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | token := contextdata.GetUserTokenFromCtx(r.Context()) | 21 | token := contextdata.GetUserTokenFromCtx(r.Context()) |
| @@ -15,7 +15,7 @@ func MiniDeleteArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFun | @@ -15,7 +15,7 @@ func MiniDeleteArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFun | ||
| 15 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
| 16 | var req types.MiniArticleDraftDeleteMeRequest | 16 | var req types.MiniArticleDraftDeleteMeRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -7,22 +7,23 @@ import ( | @@ -7,22 +7,23 @@ import ( | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 10 | ) | 12 | ) |
| 11 | 13 | ||
| 12 | func MiniGetArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 14 | func MiniGetArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
| 13 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
| 14 | var req types.MiniArticleDraftGetMeRequest | 16 | var req types.MiniArticleDraftGetMeRequest |
| 15 | if err := httpx.Parse(r, &req); err != nil { | 17 | if err := httpx.Parse(r, &req); err != nil { |
| 16 | - httpx.ErrorCtx(r.Context(), w, err) | 18 | + result.HttpResult(r, w, nil, err) |
| 17 | return | 19 | return |
| 18 | } | 20 | } |
| 19 | 21 | ||
| 20 | l := article.NewMiniGetArticleDraftMeLogic(r.Context(), svcCtx) | 22 | l := article.NewMiniGetArticleDraftMeLogic(r.Context(), svcCtx) |
| 23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
| 24 | + req.AuthorId = token.UserId | ||
| 25 | + req.CompanyId = token.CompanyId | ||
| 21 | resp, err := l.MiniGetArticleDraftMe(&req) | 26 | resp, err := l.MiniGetArticleDraftMe(&req) |
| 22 | - if err != nil { | ||
| 23 | - httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | - } else { | ||
| 25 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | - } | 27 | + result.HttpResult(r, w, resp, err) |
| 27 | } | 28 | } |
| 28 | } | 29 | } |
| @@ -15,7 +15,7 @@ func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func MiniGetArticleHandler(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.MiniArticleGetRequest | 16 | var req types.MiniArticleGetRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func MiniSearchArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFun | @@ -15,7 +15,7 @@ func MiniSearchArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFun | ||
| 15 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
| 16 | var req types.MiniArticleDraftSearchMeRequest | 16 | var req types.MiniArticleDraftSearchMeRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func MiniSearchArticlePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.MiniSearchArticleRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := article.NewMiniSearchArticlePageLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.MiniSearchArticlePage(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -15,7 +15,7 @@ func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func MiniSetUserLikeHandler(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.MiniSetUserLikeRequset | 16 | var req types.MiniSetUserLikeRequset |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +// 展示小程序端首页的数据 | ||
| 14 | +func MiniShowHomePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 16 | + var req types.MiniHomePageRequest | ||
| 17 | + // if err := httpx.Parse(r, &req); err != nil { | ||
| 18 | + // httpx.ErrorCtx(r.Context(), w, err) | ||
| 19 | + // return | ||
| 20 | + // } | ||
| 21 | + | ||
| 22 | + l := article.NewMiniShowHomePageLogic(r.Context(), svcCtx) | ||
| 23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
| 24 | + req.UserId = token.UserId | ||
| 25 | + req.CompanyId = token.CompanyId | ||
| 26 | + resp, err := l.MiniShowHomePage(&req) | ||
| 27 | + result.HttpResult(r, w, resp, err) | ||
| 28 | + } | ||
| 29 | +} |
| @@ -15,7 +15,7 @@ func MiniUpdateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | @@ -15,7 +15,7 @@ func MiniUpdateArticleDraftHandler(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.MiniArticleDraftUpdateRequest | 16 | var req types.MiniArticleDraftUpdateRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | l := article.NewMiniUpdateArticleDraftLogic(r.Context(), svcCtx) | 21 | l := article.NewMiniUpdateArticleDraftLogic(r.Context(), svcCtx) |
| @@ -15,7 +15,7 @@ func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func MiniUserLikeArticleHandler(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.MiniUserLikeArticleRequest | 16 | var req types.MiniUserLikeArticleRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| 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 SystemArticleRestoreHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleRestoreRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + result.ParamErrorResult(r, w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemArticleRestoreLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleRestore(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| @@ -18,7 +18,7 @@ func SystemUpdateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -18,7 +18,7 @@ func SystemUpdateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 18 | return | 18 | return |
| 19 | } | 19 | } |
| 20 | l := article.NewSystemUpdateArticleLogic(r.Context(), svcCtx) | 20 | l := article.NewSystemUpdateArticleLogic(r.Context(), svcCtx) |
| 21 | - resp, err := l.SystemUpdateArticle(&req, r.Header.Get("x-mmm-accesstoken")) | 21 | + resp, err := l.SystemUpdateArticle(&req) |
| 22 | result.HttpResult(r, w, resp, err) | 22 | result.HttpResult(r, w, resp, err) |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| @@ -15,7 +15,7 @@ func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | @@ -15,7 +15,7 @@ func MiniArticleCommentAtWhoHandler(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.MiniArticleCommentAtWhoRequest | 16 | var req types.MiniArticleCommentAtWhoRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func MiniCreateArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFun | @@ -15,7 +15,7 @@ func MiniCreateArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFun | ||
| 15 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
| 16 | var req types.MiniCreateArticleCommentRequest | 16 | var req types.MiniCreateArticleCommentRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | l := comment.NewMiniCreateArticleCommentLogic(r.Context(), svcCtx) | 21 | l := comment.NewMiniCreateArticleCommentLogic(r.Context(), svcCtx) |
| @@ -15,7 +15,7 @@ func MiniDeleteArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFun | @@ -15,7 +15,7 @@ func MiniDeleteArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFun | ||
| 15 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
| 16 | var req types.MiniDeleteArticleCommentRequest | 16 | var req types.MiniDeleteArticleCommentRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func MiniGetArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func MiniGetArticleCommentHandler(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.MiniGetArticleCommentRequest | 16 | var req types.MiniGetArticleCommentRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func MiniListArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | @@ -15,7 +15,7 @@ func MiniListArticleCommentHandler(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.MiniListArticleCommentRequest | 16 | var req types.MiniListArticleCommentRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | l := comment.NewMiniListArticleCommentLogic(r.Context(), svcCtx) | 21 | l := comment.NewMiniListArticleCommentLogic(r.Context(), svcCtx) |
| @@ -15,7 +15,7 @@ func MiniTop5ArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | @@ -15,7 +15,7 @@ func MiniTop5ArticleCommentHandler(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.MiniTop5ArticleCommentRequest | 16 | var req types.MiniTop5ArticleCommentRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -379,6 +379,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -379,6 +379,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 379 | Path: "/article_tag/list/all", | 379 | Path: "/article_tag/list/all", |
| 380 | Handler: article.MiniAllArticleTagHandler(serverCtx), | 380 | Handler: article.MiniAllArticleTagHandler(serverCtx), |
| 381 | }, | 381 | }, |
| 382 | + { | ||
| 383 | + Method: http.MethodGet, | ||
| 384 | + Path: "/show/home_page", | ||
| 385 | + Handler: article.MiniShowHomePageHandler(serverCtx), | ||
| 386 | + }, | ||
| 387 | + { | ||
| 388 | + Method: http.MethodPost, | ||
| 389 | + Path: "/show/search_article", | ||
| 390 | + Handler: article.MiniSearchArticlePageHandler(serverCtx), | ||
| 391 | + }, | ||
| 382 | }, | 392 | }, |
| 383 | rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | 393 | rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), |
| 384 | rest.WithPrefix("/v1/mini"), | 394 | rest.WithPrefix("/v1/mini"), |
| @@ -416,6 +426,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -416,6 +426,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 416 | Path: "/article/search/me", | 426 | Path: "/article/search/me", |
| 417 | Handler: article.SystemArticleSearchMeHandler(serverCtx), | 427 | Handler: article.SystemArticleSearchMeHandler(serverCtx), |
| 418 | }, | 428 | }, |
| 429 | + { | ||
| 430 | + Method: http.MethodPost, | ||
| 431 | + Path: "/article/restore", | ||
| 432 | + Handler: article.SystemArticleRestoreHandler(serverCtx), | ||
| 433 | + }, | ||
| 419 | }, | 434 | }, |
| 420 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 435 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
| 421 | rest.WithPrefix("/v1/system"), | 436 | rest.WithPrefix("/v1/system"), |
| @@ -15,7 +15,7 @@ func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func CreateTagHandler(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.TagCreateRequest | 16 | var req types.TagCreateRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func DeleteTagHandler(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.TagDeleteRequest | 16 | var req types.TagDeleteRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func EditTagHandler(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.TagEditRequest | 16 | var req types.TagEditRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -15,7 +15,7 @@ func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func GetTagHandler(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.TagGetRequest | 16 | var req types.TagGetRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | token := contextdata.GetUserTokenFromCtx(r.Context()) | 21 | token := contextdata.GetUserTokenFromCtx(r.Context()) |
| @@ -15,7 +15,7 @@ func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -15,7 +15,7 @@ func SearchTagHandler(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.TagListRequest | 16 | var req types.TagListRequest |
| 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.HttpResult(r, w, nil, err) |
| 19 | return | 19 | return |
| 20 | } | 20 | } |
| 21 | 21 |
| @@ -38,20 +38,20 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR | @@ -38,20 +38,20 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR | ||
| 38 | for _, val := range tagList { | 38 | for _, val := range tagList { |
| 39 | if m, ok := tagMap[val.Category]; ok { | 39 | if m, ok := tagMap[val.Category]; ok { |
| 40 | m = append(m, types.ArticleTagItem{ | 40 | m = append(m, types.ArticleTagItem{ |
| 41 | - Id: val.Id, | ||
| 42 | - Group: val.Category, | ||
| 43 | - Name: val.Name, | ||
| 44 | - Image: val.Image.Url, | 41 | + Id: val.Id, |
| 42 | + Category: val.Category, | ||
| 43 | + Name: val.Name, | ||
| 44 | + Image: val.Image.Url, | ||
| 45 | }) | 45 | }) |
| 46 | tagMap[val.Category] = m | 46 | tagMap[val.Category] = m |
| 47 | } else { | 47 | } else { |
| 48 | group = append(group, val.Category) | 48 | group = append(group, val.Category) |
| 49 | tagMap[val.Category] = []types.ArticleTagItem{ | 49 | tagMap[val.Category] = []types.ArticleTagItem{ |
| 50 | { | 50 | { |
| 51 | - Id: val.Id, | ||
| 52 | - Group: val.Category, | ||
| 53 | - Name: val.Name, | ||
| 54 | - Image: val.Image.Url, | 51 | + Id: val.Id, |
| 52 | + Category: val.Category, | ||
| 53 | + Name: val.Name, | ||
| 54 | + Image: val.Image.Url, | ||
| 55 | }, | 55 | }, |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| @@ -61,8 +61,8 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR | @@ -61,8 +61,8 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR | ||
| 61 | } | 61 | } |
| 62 | for i := range group { | 62 | for i := range group { |
| 63 | resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{ | 63 | resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{ |
| 64 | - Group: group[i], | ||
| 65 | - Tags: tagMap[group[i]], | 64 | + Category: group[i], |
| 65 | + Tags: tagMap[group[i]], | ||
| 66 | }) | 66 | }) |
| 67 | } | 67 | } |
| 68 | return resp, nil | 68 | return resp, nil |
| @@ -2,6 +2,7 @@ package article | @@ -2,6 +2,7 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | ||
| 5 | 6 | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| @@ -80,6 +81,14 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR | @@ -80,6 +81,14 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR | ||
| 80 | if err != nil { | 81 | if err != nil { |
| 81 | return err | 82 | return err |
| 82 | } | 83 | } |
| 84 | + | ||
| 85 | + // 定性消息通知 | ||
| 86 | + messageLogic := message.NewMiniSystemLogic(ctx, l.svcCtx) | ||
| 87 | + err = messageLogic.ArticleDefined(c, articleInfo.CompanyId, articleInfo.AuthorId, articleInfo.Title) | ||
| 88 | + if err != nil { | ||
| 89 | + return err | ||
| 90 | + } | ||
| 91 | + | ||
| 83 | return nil | 92 | return nil |
| 84 | }, true) | 93 | }, true) |
| 85 | 94 |
| @@ -2,6 +2,7 @@ package article | @@ -2,6 +2,7 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "strconv" | ||
| 5 | "strings" | 6 | "strings" |
| 6 | "text/template" | 7 | "text/template" |
| 7 | 8 | ||
| @@ -9,6 +10,7 @@ import ( | @@ -9,6 +10,7 @@ import ( | ||
| 9 | "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" |
| 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | ||
| 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 14 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| 13 | 15 | ||
| 14 | "github.com/samber/lo" | 16 | "github.com/samber/lo" |
| @@ -52,13 +54,16 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -52,13 +54,16 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
| 52 | if len(req.Images) > 9 { | 54 | if len(req.Images) > 9 { |
| 53 | return nil, xerr.NewErrMsg("图片数量最多9张") | 55 | return nil, xerr.NewErrMsg("图片数量最多9张") |
| 54 | } | 56 | } |
| 55 | - //TODO 获取图片的尺寸大小 | 57 | + //获取图片的尺寸大小 |
| 56 | images := []domain.Image{} | 58 | images := []domain.Image{} |
| 57 | for _, val := range req.Images { | 59 | for _, val := range req.Images { |
| 60 | + fInfo, _ := oss.GetImageInfo(val) | ||
| 61 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
| 62 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
| 58 | images = append(images, domain.Image{ | 63 | images = append(images, domain.Image{ |
| 59 | Url: val, | 64 | Url: val, |
| 60 | - Width: 0, | ||
| 61 | - Height: 0, | 65 | + Width: w, |
| 66 | + Height: h, | ||
| 62 | }) | 67 | }) |
| 63 | } | 68 | } |
| 64 | 69 | ||
| @@ -157,7 +162,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -157,7 +162,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
| 157 | CountLove: 0, | 162 | CountLove: 0, |
| 158 | CountComment: 0, | 163 | CountComment: 0, |
| 159 | CountRead: 0, | 164 | CountRead: 0, |
| 160 | - Show: 0, | 165 | + Show: domain.ArticleShowEnable, |
| 161 | Tags: []int64{}, | 166 | Tags: []int64{}, |
| 162 | } | 167 | } |
| 163 | if len(whoRead) > 0 { | 168 | if len(whoRead) > 0 { |
| @@ -38,9 +38,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -38,9 +38,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
| 38 | if articleInfo.CompanyId != req.CompanyId { | 38 | if articleInfo.CompanyId != req.CompanyId { |
| 39 | return nil, xerr.NewErrMsg("没有查看权限") | 39 | return nil, xerr.NewErrMsg("没有查看权限") |
| 40 | } | 40 | } |
| 41 | - | ||
| 42 | //TODO 检查可查看人 | 41 | //TODO 检查可查看人 |
| 43 | - | ||
| 44 | if articleInfo.Show == domain.ArticleShowDisable { | 42 | if articleInfo.Show == domain.ArticleShowDisable { |
| 45 | // 文章内容不显示 | 43 | // 文章内容不显示 |
| 46 | resp = &types.MiniArticleGetResponse{ | 44 | resp = &types.MiniArticleGetResponse{ |
| @@ -71,6 +69,14 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -71,6 +69,14 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
| 71 | meLoveFlag = 1 | 69 | meLoveFlag = 1 |
| 72 | } | 70 | } |
| 73 | } | 71 | } |
| 72 | + tags := []string{} | ||
| 73 | + if len(articleInfo.Tags) > 0 { | ||
| 74 | + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.Tags) | ||
| 75 | + _, tagList, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption) | ||
| 76 | + for _, val := range tagList { | ||
| 77 | + tags = append(tags, val.Name) | ||
| 78 | + } | ||
| 79 | + } | ||
| 74 | 80 | ||
| 75 | sortBy := domain.SortArticleSection(sectionList) | 81 | sortBy := domain.SortArticleSection(sectionList) |
| 76 | sort.Sort(sortBy) | 82 | sort.Sort(sortBy) |
| @@ -111,6 +117,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -111,6 +117,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
| 111 | Show: int(articleInfo.Show), | 117 | Show: int(articleInfo.Show), |
| 112 | Edit: 0, | 118 | Edit: 0, |
| 113 | MeLoveFlag: meLoveFlag, | 119 | MeLoveFlag: meLoveFlag, |
| 120 | + Tags: tags, | ||
| 114 | } | 121 | } |
| 115 | if articleInfo.CreatedAt != articleInfo.UpdatedAt { | 122 | if articleInfo.CreatedAt != articleInfo.UpdatedAt { |
| 116 | resp.Edit = 1 | 123 | resp.Edit = 1 |
| 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 MiniSearchArticlePageLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSearchArticlePageLogic { | ||
| 19 | + return &MiniSearchArticlePageLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 10 | + | ||
| 11 | + "github.com/samber/lo" | ||
| 12 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type MiniShowHomePageLogic struct { | ||
| 16 | + logx.Logger | ||
| 17 | + ctx context.Context | ||
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewMiniShowHomePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniShowHomePageLogic { | ||
| 22 | + return &MiniShowHomePageLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) (resp *types.MiniHomePageResponse, err error) { | ||
| 30 | + // 获取所有的标签 | ||
| 31 | + var conn = l.svcCtx.DefaultDBConn() | ||
| 32 | + queryOption := domain.NewQueryOptions().WithFindOnly() | ||
| 33 | + _, allTags, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption) | ||
| 34 | + if err != nil { | ||
| 35 | + return nil, xerr.NewErrMsgErr("获取标签列表失败", err) | ||
| 36 | + } | ||
| 37 | + // 获取统计数据 | ||
| 38 | + countData, err := l.svcCtx.ArticleAndTagRepository.CountArticleReadGroupByTag(l.ctx, conn, req.UserId, req.CompanyId) | ||
| 39 | + if err != nil { | ||
| 40 | + return nil, xerr.NewErrMsgErr("获取文章汇总数量失败", err) | ||
| 41 | + } | ||
| 42 | + countDataMap := map[int64]*domain.CountArticleTagRead{} | ||
| 43 | + for _, val := range countData { | ||
| 44 | + countDataMap[val.TagId] = val | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + tagCategory := []string{} | ||
| 48 | + tagCount := []types.ArticleTagCount{} | ||
| 49 | + for _, val := range allTags { | ||
| 50 | + tagCategory = append(tagCategory, val.Category) | ||
| 51 | + m := types.ArticleTagCount{ | ||
| 52 | + TagCategory: val.Category, | ||
| 53 | + TagId: val.Id, | ||
| 54 | + TagImage: val.Image.Url, | ||
| 55 | + TagName: val.Name, | ||
| 56 | + TagRemark: val.Remark, | ||
| 57 | + TotalArticle: 0, | ||
| 58 | + ReadArticle: 0, | ||
| 59 | + } | ||
| 60 | + if count, ok := countDataMap[val.Id]; ok { | ||
| 61 | + m.TotalArticle = count.TotalArticle | ||
| 62 | + m.ReadArticle = count.ReadArticle | ||
| 63 | + } | ||
| 64 | + tagCount = append(tagCount, m) | ||
| 65 | + } | ||
| 66 | + tagCategory = lo.Uniq(tagCategory) | ||
| 67 | + resp = &types.MiniHomePageResponse{ | ||
| 68 | + TagCategory: tagCategory, | ||
| 69 | + Tags: tagCount, | ||
| 70 | + } | ||
| 71 | + return resp, nil | ||
| 72 | +} |
| @@ -2,6 +2,9 @@ package article | @@ -2,6 +2,9 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "github.com/samber/lo" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 5 | 8 | ||
| 6 | "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" |
| 7 | "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" |
| @@ -24,7 +27,67 @@ func NewSystemArticleGetHistoryLogic(ctx context.Context, svcCtx *svc.ServiceCon | @@ -24,7 +27,67 @@ func NewSystemArticleGetHistoryLogic(ctx context.Context, svcCtx *svc.ServiceCon | ||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.SystemArticleGetHistoryRequest) (resp *types.SystemArticleGetHistoryResponse, err error) { | 29 | func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.SystemArticleGetHistoryRequest) (resp *types.SystemArticleGetHistoryResponse, err error) { |
| 27 | - //var conn = l.svcCtx.DefaultDBConn() | ||
| 28 | - | 30 | + var conn = l.svcCtx.DefaultDBConn() |
| 31 | + backup, err := l.svcCtx.ArticleBackupRepository.FindOne(l.ctx, conn, req.Id) | ||
| 32 | + if err != nil { | ||
| 33 | + return nil, xerr.NewErrMsgErr("获取编辑历史记录失败", err) | ||
| 34 | + } | ||
| 35 | + resp = &types.SystemArticleGetHistoryResponse{ | ||
| 36 | + Id: backup.Id, | ||
| 37 | + ArticleId: backup.ArticleId, | ||
| 38 | + Title: backup.Title, | ||
| 39 | + CreatedAt: backup.CreatedAt, | ||
| 40 | + Section: make([]types.ArticleSection, 0), | ||
| 41 | + Images: make([]string, 0), | ||
| 42 | + WhoRead: backup.WhoRead, | ||
| 43 | + WhoReadInfo: make([]types.UserShowName, 0), | ||
| 44 | + WhoReview: backup.WhoReview, | ||
| 45 | + WhoReviewInfo: make([]types.UserShowName, 0), | ||
| 46 | + Location: types.Location{ | ||
| 47 | + Longitude: backup.Location.Longitude, | ||
| 48 | + Latitude: backup.Location.Latitude, | ||
| 49 | + Descript: backup.Location.Descript, | ||
| 50 | + }, | ||
| 51 | + TargetUser: int(backup.TargetUser), | ||
| 52 | + Tags: backup.Tags, | ||
| 53 | + } | ||
| 54 | + //文章段落内容 | ||
| 55 | + lo.ForEach(backup.Section, func(item domain.ArticleSection, index int) { | ||
| 56 | + resp.Section = append(resp.Section, types.ArticleSection{ | ||
| 57 | + Id: item.Id, | ||
| 58 | + Content: item.Content, | ||
| 59 | + SortBy: item.SortBy, | ||
| 60 | + TotalComment: item.TotalComment, | ||
| 61 | + }) | ||
| 62 | + }) | ||
| 63 | + //图片 | ||
| 64 | + lo.ForEach(backup.Images, func(item domain.Image, index int) { | ||
| 65 | + resp.Images = append(resp.Images, item.Url) | ||
| 66 | + }) | ||
| 67 | + //用户 | ||
| 68 | + userIds := lo.Union(resp.WhoRead, resp.WhoReview) | ||
| 69 | + if len(userIds) > 0 { | ||
| 70 | + _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithKV("ids", userIds)) | ||
| 71 | + if err != nil { | ||
| 72 | + return nil, xerr.NewErrMsgErr("获取帖子异常", err) | ||
| 73 | + } | ||
| 74 | + userSlices := make(map[int64]types.UserShowName) | ||
| 75 | + lo.ForEach(users, func(user *domain.User, index int) { | ||
| 76 | + userSlices[user.Id] = types.UserShowName{ | ||
| 77 | + Id: int(user.Id), | ||
| 78 | + Name: user.Name, | ||
| 79 | + } | ||
| 80 | + }) | ||
| 81 | + lo.ForEach(resp.WhoRead, func(userId int64, index int) { | ||
| 82 | + if value, ok := userSlices[userId]; ok { | ||
| 83 | + resp.WhoReadInfo = append(resp.WhoReadInfo, value) | ||
| 84 | + } | ||
| 85 | + }) | ||
| 86 | + lo.ForEach(resp.WhoReview, func(userId int64, index int) { | ||
| 87 | + if value, ok := userSlices[userId]; ok { | ||
| 88 | + resp.WhoReviewInfo = append(resp.WhoReviewInfo, value) | ||
| 89 | + } | ||
| 90 | + }) | ||
| 91 | + } | ||
| 29 | return | 92 | return |
| 30 | } | 93 | } |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/samber/lo" | ||
| 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" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 11 | + | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 14 | + | ||
| 15 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 16 | +) | ||
| 17 | + | ||
| 18 | +type SystemArticleRestoreLogic struct { | ||
| 19 | + logx.Logger | ||
| 20 | + ctx context.Context | ||
| 21 | + svcCtx *svc.ServiceContext | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func NewSystemArticleRestoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleRestoreLogic { | ||
| 25 | + return &SystemArticleRestoreLogic{ | ||
| 26 | + Logger: logx.WithContext(ctx), | ||
| 27 | + ctx: ctx, | ||
| 28 | + svcCtx: svcCtx, | ||
| 29 | + } | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticleRestoreRequest) (resp *types.SystemArticleRestoreResponse, err error) { | ||
| 33 | + var conn = l.svcCtx.DefaultDBConn() | ||
| 34 | + backup, err := l.svcCtx.ArticleBackupRepository.FindOne(l.ctx, conn, req.Id) | ||
| 35 | + if err != nil { | ||
| 36 | + return nil, xerr.NewErrMsgErr("获取编辑历史记录失败", err) | ||
| 37 | + } | ||
| 38 | + article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, backup.ArticleId) | ||
| 39 | + if err != nil { | ||
| 40 | + return nil, xerr.NewErrMsgErr("获取文章失败", err) | ||
| 41 | + } | ||
| 42 | + article.Version = article.Version + 1 | ||
| 43 | + article.Images = backup.Images | ||
| 44 | + article.Title = backup.Title | ||
| 45 | + articleSections := make([]domain.ArticleSection, 0) | ||
| 46 | + lo.ForEach(backup.Section, func(item domain.ArticleSection, index int) { | ||
| 47 | + articleSections = append(articleSections, domain.ArticleSection{ | ||
| 48 | + Id: item.Id, | ||
| 49 | + CompanyId: item.CompanyId, | ||
| 50 | + Version: article.Version, | ||
| 51 | + ArticleId: article.Id, | ||
| 52 | + Content: item.Content, | ||
| 53 | + SortBy: item.SortBy, | ||
| 54 | + }) | ||
| 55 | + }) | ||
| 56 | + //获取当前用户信息 | ||
| 57 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 58 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
| 59 | + if err != nil { | ||
| 60 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
| 61 | + } | ||
| 62 | + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | ||
| 63 | + //保存文章 | ||
| 64 | + _, err = l.svcCtx.ArticleRepository.Update(ctx, c, article) | ||
| 65 | + if err != nil { | ||
| 66 | + return xerr.NewErrMsgErr("恢复文章版本失败", err) | ||
| 67 | + } | ||
| 68 | + //保存段落 | ||
| 69 | + updateSectionIds := []int64{} | ||
| 70 | + for _, item := range articleSections { | ||
| 71 | + section, err := l.svcCtx.ArticleSectionRepository.FindOne(ctx, c, item.Id) | ||
| 72 | + if err == nil && section.Id > 0 { | ||
| 73 | + section.Content = item.Content | ||
| 74 | + section.SortBy = item.SortBy | ||
| 75 | + section.Version = item.Version | ||
| 76 | + _, err = l.svcCtx.ArticleSectionRepository.Update(ctx, c, section) | ||
| 77 | + if err != nil { | ||
| 78 | + return xerr.NewErrMsgErr("恢复文章版本失败", err) | ||
| 79 | + } | ||
| 80 | + } else { | ||
| 81 | + _, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, &item) | ||
| 82 | + if err != nil { | ||
| 83 | + return xerr.NewErrMsgErr("恢复文章版本失败", err) | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + updateSectionIds = append(updateSectionIds, item.Id) | ||
| 87 | + } | ||
| 88 | + if len(updateSectionIds) > 0 { | ||
| 89 | + err = l.svcCtx.ArticleSectionRepository.DeleteBy(ctx, c, domain.NewQueryOptions().WithKV("articleId", article.Id).WithKV("notIds", updateSectionIds)) | ||
| 90 | + if err != nil { | ||
| 91 | + return xerr.NewErrMsgErr("保存文章内容失败", err) | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + //备份数据 | ||
| 95 | + newBackUp := article.MakeBackup(domain.UserSimple{ | ||
| 96 | + Id: userToken.UserId, | ||
| 97 | + Name: userMe.User.NickName, | ||
| 98 | + Avatar: userMe.User.Avatar, | ||
| 99 | + CompanyId: userToken.CompanyId, | ||
| 100 | + Company: userMe.CurrentCompany.Name, | ||
| 101 | + }, articleSections) | ||
| 102 | + newBackUp.Action = "恢复" | ||
| 103 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, newBackUp) | ||
| 104 | + if err != nil { | ||
| 105 | + return xerr.NewErrMsgErr("恢复文章版本失败", err) | ||
| 106 | + } | ||
| 107 | + return nil | ||
| 108 | + }, true) | ||
| 109 | + resp = &types.SystemArticleRestoreResponse{ | ||
| 110 | + Id: req.Id, | ||
| 111 | + ArticleId: article.Id, | ||
| 112 | + } | ||
| 113 | + return | ||
| 114 | +} |
| @@ -2,6 +2,7 @@ package article | @@ -2,6 +2,7 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "github.com/samber/lo" | 6 | "github.com/samber/lo" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| @@ -71,10 +72,10 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ | @@ -71,10 +72,10 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ | ||
| 71 | if err == nil && len(tags) > 0 { | 72 | if err == nil && len(tags) > 0 { |
| 72 | lo.ForEach(tags, func(tag *domain.ArticleTag, index int) { | 73 | lo.ForEach(tags, func(tag *domain.ArticleTag, index int) { |
| 73 | resp.Tags = append(resp.Tags, types.ArticleTagItem{ | 74 | resp.Tags = append(resp.Tags, types.ArticleTagItem{ |
| 74 | - Id: tag.Id, | ||
| 75 | - Group: tag.Category, | ||
| 76 | - Name: tag.Name, | ||
| 77 | - Image: tag.Image.Url, | 75 | + Id: tag.Id, |
| 76 | + Category: tag.Category, | ||
| 77 | + Name: tag.Name, | ||
| 78 | + Image: tag.Image.Url, | ||
| 78 | }) | 79 | }) |
| 79 | }) | 80 | }) |
| 80 | } | 81 | } |
| @@ -2,11 +2,14 @@ package article | @@ -2,11 +2,14 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "strconv" | ||
| 6 | + | ||
| 5 | "github.com/samber/lo" | 7 | "github.com/samber/lo" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 9 | "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" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" |
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | ||
| 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| 11 | 14 | ||
| 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 15 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| @@ -29,20 +32,23 @@ func NewSystemUpdateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext | @@ -29,20 +32,23 @@ func NewSystemUpdateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext | ||
| 29 | } | 32 | } |
| 30 | } | 33 | } |
| 31 | 34 | ||
| 32 | -func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleUpdateRequest, accessToken string) (resp *types.SystemArticleUpdateResponse, err error) { | 35 | +func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleUpdateRequest) (resp *types.SystemArticleUpdateResponse, err error) { |
| 33 | var conn = l.svcCtx.DefaultDBConn() | 36 | var conn = l.svcCtx.DefaultDBConn() |
| 34 | userToken := contextdata.GetUserTokenFromCtx(l.ctx) | 37 | userToken := contextdata.GetUserTokenFromCtx(l.ctx) |
| 35 | article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id) | 38 | article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id) |
| 36 | if err != nil { | 39 | if err != nil { |
| 37 | return nil, xerr.NewErrMsgErr("帖子不存在", err) | 40 | return nil, xerr.NewErrMsgErr("帖子不存在", err) |
| 38 | } | 41 | } |
| 39 | - //TODO 获取图片的尺寸大小 | 42 | + //获取图片的尺寸大小 |
| 40 | images := []domain.Image{} | 43 | images := []domain.Image{} |
| 41 | for _, val := range req.Images { | 44 | for _, val := range req.Images { |
| 45 | + fInfo, _ := oss.GetImageInfo(val) | ||
| 46 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
| 47 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
| 42 | images = append(images, domain.Image{ | 48 | images = append(images, domain.Image{ |
| 43 | Url: val, | 49 | Url: val, |
| 44 | - Width: 0, | ||
| 45 | - Height: 0, | 50 | + Width: w, |
| 51 | + Height: h, | ||
| 46 | }) | 52 | }) |
| 47 | } | 53 | } |
| 48 | article.Title = req.Title | 54 | article.Title = req.Title |
| @@ -84,7 +90,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -84,7 +90,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
| 84 | article.Summary = req.Section[0].Content[0:stringIndex] | 90 | article.Summary = req.Section[0].Content[0:stringIndex] |
| 85 | } | 91 | } |
| 86 | //获取当前用户信息 | 92 | //获取当前用户信息 |
| 87 | - userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: accessToken}) | 93 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) |
| 88 | if err != nil { | 94 | if err != nil { |
| 89 | return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | 95 | return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) |
| 90 | } | 96 | } |
| @@ -130,7 +130,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | @@ -130,7 +130,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | ||
| 130 | CountReply: 0, | 130 | CountReply: 0, |
| 131 | CountUserLove: 0, | 131 | CountUserLove: 0, |
| 132 | CountAdminLove: 0, | 132 | CountAdminLove: 0, |
| 133 | - Show: 0, | 133 | + Show: domain.CommentShowEnable, |
| 134 | AtWho: []domain.UserSimple{}, | 134 | AtWho: []domain.UserSimple{}, |
| 135 | } | 135 | } |
| 136 | 136 |
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 9 | 10 | ||
| 10 | "github.com/zeromicro/go-zero/core/logx" | 11 | "github.com/zeromicro/go-zero/core/logx" |
| 11 | ) | 12 | ) |
| @@ -29,13 +30,13 @@ func (l *SystemDeleteLogic) SystemDelete(req *types.DepartmentGetRequest) (resp | @@ -29,13 +30,13 @@ func (l *SystemDeleteLogic) SystemDelete(req *types.DepartmentGetRequest) (resp | ||
| 29 | 30 | ||
| 30 | one, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id) | 31 | one, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id) |
| 31 | if err != nil { | 32 | if err != nil { |
| 32 | - return nil, err | 33 | + return nil, xerr.NewErrMsg("数据不存在") |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | // 获取公司下的所有用户 | 36 | // 获取公司下的所有用户 |
| 36 | _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions(). | 37 | _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions(). |
| 37 | WithFindOnly(). | 38 | WithFindOnly(). |
| 38 | - WithKV(" companyId", one.CompanyId)) | 39 | + WithKV("companyId", one.CompanyId)) |
| 39 | if err != nil { | 40 | if err != nil { |
| 40 | return nil, err | 41 | return nil, err |
| 41 | } | 42 | } |
| @@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
| 4 | "context" | 4 | "context" |
| 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 7 | 8 | ||
| 8 | "github.com/zeromicro/go-zero/core/logx" | 9 | "github.com/zeromicro/go-zero/core/logx" |
| 9 | ) | 10 | ) |
| @@ -26,7 +27,7 @@ func (l *SystemGetLogic) SystemGet(req *types.DepartmentGetRequest) (resp *types | @@ -26,7 +27,7 @@ func (l *SystemGetLogic) SystemGet(req *types.DepartmentGetRequest) (resp *types | ||
| 26 | var conn = l.svcCtx.DefaultDBConn() | 27 | var conn = l.svcCtx.DefaultDBConn() |
| 27 | department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id) | 28 | department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id) |
| 28 | if err != nil { | 29 | if err != nil { |
| 29 | - return nil, err | 30 | + return nil, xerr.NewErrMsg("数据不存在") |
| 30 | } | 31 | } |
| 31 | resp = &types.DepartmentGetResponse{ | 32 | resp = &types.DepartmentGetResponse{ |
| 32 | Department: types.Department{ | 33 | Department: types.Department{ |
| @@ -58,7 +58,7 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re | @@ -58,7 +58,7 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re | ||
| 58 | // 获取公司下的所有用户 | 58 | // 获取公司下的所有用户 |
| 59 | _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions(). | 59 | _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions(). |
| 60 | WithFindOnly(). | 60 | WithFindOnly(). |
| 61 | - WithKV(" companyId", one.CompanyId)) | 61 | + WithKV("companyId", one.CompanyId)) |
| 62 | if err != nil { | 62 | if err != nil { |
| 63 | return nil, err | 63 | return nil, err |
| 64 | } | 64 | } |
| @@ -83,7 +83,7 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re | @@ -83,7 +83,7 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re | ||
| 83 | if _, ok := newIdMap[user.Id]; ok { | 83 | if _, ok := newIdMap[user.Id]; ok { |
| 84 | var targetIndex = findIndex(user.Departments, req.Id) | 84 | var targetIndex = findIndex(user.Departments, req.Id) |
| 85 | if targetIndex == -1 { // 归属分组不存在,则新增 | 85 | if targetIndex == -1 { // 归属分组不存在,则新增 |
| 86 | - user.Departments = append(user.Departments) | 86 | + user.Departments = append(user.Departments, req.Id) |
| 87 | _, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user) | 87 | _, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user) |
| 88 | if err != nil { | 88 | if err != nil { |
| 89 | return err | 89 | return err |
| @@ -3,10 +3,12 @@ package tags | @@ -3,10 +3,12 @@ package tags | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + "strconv" | ||
| 6 | 7 | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | ||
| 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| 11 | 13 | ||
| 12 | "github.com/zeromicro/go-zero/core/logx" | 14 | "github.com/zeromicro/go-zero/core/logx" |
| @@ -41,8 +43,10 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | @@ -41,8 +43,10 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | ||
| 41 | if cnt > 0 { | 43 | if cnt > 0 { |
| 42 | return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name)) | 44 | return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name)) |
| 43 | } | 45 | } |
| 44 | - //TODO 获取图片的尺寸大小 | ||
| 45 | - | 46 | + //获取图片的尺寸大小 |
| 47 | + fInfo, _ := oss.GetImageInfo(req.Image) | ||
| 48 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
| 49 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
| 46 | newTag := &domain.ArticleTag{ | 50 | newTag := &domain.ArticleTag{ |
| 47 | Id: 0, | 51 | Id: 0, |
| 48 | CompanyId: req.CompanyId, | 52 | CompanyId: req.CompanyId, |
| @@ -52,8 +56,8 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | @@ -52,8 +56,8 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | ||
| 52 | Version: 0, | 56 | Version: 0, |
| 53 | Image: domain.Image{ | 57 | Image: domain.Image{ |
| 54 | Url: req.Image, | 58 | Url: req.Image, |
| 55 | - Width: 0, | ||
| 56 | - Height: 0, | 59 | + Width: w, |
| 60 | + Height: h, | ||
| 57 | }, | 61 | }, |
| 58 | Name: req.Name, | 62 | Name: req.Name, |
| 59 | Category: req.Category, | 63 | Category: req.Category, |
| @@ -3,10 +3,12 @@ package tags | @@ -3,10 +3,12 @@ package tags | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + "strconv" | ||
| 6 | 7 | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | ||
| 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| 11 | 13 | ||
| 12 | "github.com/zeromicro/go-zero/core/logx" | 14 | "github.com/zeromicro/go-zero/core/logx" |
| @@ -52,11 +54,16 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe | @@ -52,11 +54,16 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe | ||
| 52 | if oldTag.CompanyId != req.CompanyId { | 54 | if oldTag.CompanyId != req.CompanyId { |
| 53 | return nil, xerr.NewErrMsg("修改标签失败") | 55 | return nil, xerr.NewErrMsg("修改标签失败") |
| 54 | } | 56 | } |
| 55 | - | ||
| 56 | - //TODO 获取图片的尺寸大小 | ||
| 57 | - | 57 | + //获取图片的尺寸大小 |
| 58 | + fInfo, _ := oss.GetImageInfo(req.Image) | ||
| 59 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
| 60 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
| 58 | oldTag.Category = req.Category | 61 | oldTag.Category = req.Category |
| 59 | - oldTag.Image.Url = req.Image | 62 | + oldTag.Image = domain.Image{ |
| 63 | + Url: req.Image, | ||
| 64 | + Width: w, | ||
| 65 | + Height: h, | ||
| 66 | + } | ||
| 60 | oldTag.Name = req.Name | 67 | oldTag.Name = req.Name |
| 61 | oldTag.Remark = req.Remark | 68 | oldTag.Remark = req.Remark |
| 62 | oldTag.Other = req.Other | 69 | oldTag.Other = req.Other |
| @@ -621,9 +621,10 @@ type MiniArticleGetResponse struct { | @@ -621,9 +621,10 @@ type MiniArticleGetResponse struct { | ||
| 621 | CountLove int `json:"countLove"` // 点赞数量 | 621 | CountLove int `json:"countLove"` // 点赞数量 |
| 622 | CountComment int `json:"countComment"` // 评论数量 | 622 | CountComment int `json:"countComment"` // 评论数量 |
| 623 | CountRead int `json:"countRead"` // 浏览数量 | 623 | CountRead int `json:"countRead"` // 浏览数量 |
| 624 | - Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | 624 | + Show int `json:"show"` // 评论的展示状态(1显示、2不显示) |
| 625 | Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) | 625 | Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) |
| 626 | MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞) | 626 | MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞) |
| 627 | + Tags []string `json:"tags"` //文章的标签 | ||
| 627 | } | 628 | } |
| 628 | 629 | ||
| 629 | type ArticleSection struct { | 630 | type ArticleSection struct { |
| @@ -855,15 +856,15 @@ type MiniAllArticleTagResponse struct { | @@ -855,15 +856,15 @@ type MiniAllArticleTagResponse struct { | ||
| 855 | } | 856 | } |
| 856 | 857 | ||
| 857 | type ArticleTagGroup struct { | 858 | type ArticleTagGroup struct { |
| 858 | - Group string `json:"group"` | ||
| 859 | - Tags []ArticleTagItem `json:"tags"` | 859 | + Category string `json:"category"` |
| 860 | + Tags []ArticleTagItem `json:"tags"` | ||
| 860 | } | 861 | } |
| 861 | 862 | ||
| 862 | type ArticleTagItem struct { | 863 | type ArticleTagItem struct { |
| 863 | - Id int64 `json:"id"` | ||
| 864 | - Group string `json:"group"` | ||
| 865 | - Name string `json:"name"` | ||
| 866 | - Image string `json:"image"` | 864 | + Id int64 `json:"id"` |
| 865 | + Category string `json:"category"` | ||
| 866 | + Name string `json:"name"` | ||
| 867 | + Image string `json:"image"` | ||
| 867 | } | 868 | } |
| 868 | 869 | ||
| 869 | type SystemArticleGetRequest struct { | 870 | type SystemArticleGetRequest struct { |
| @@ -926,17 +927,18 @@ type SystemArticleSearch struct { | @@ -926,17 +927,18 @@ type SystemArticleSearch struct { | ||
| 926 | } | 927 | } |
| 927 | 928 | ||
| 928 | type SystemArticleUpdateRequest struct { | 929 | type SystemArticleUpdateRequest struct { |
| 929 | - Id int64 `json:"id"` | ||
| 930 | - CompanyId int64 `json:"companyId,optional"` | ||
| 931 | - Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
| 932 | - Section []ArticleSection `json:"section"` // 填写的内容 | ||
| 933 | - Title string `json:"title"` // 标题 | ||
| 934 | - Images []string `json:"images"` // 图片 | ||
| 935 | - WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
| 936 | - WhoReview []int64 `json:"whoReview"` // 评论人 | ||
| 937 | - Location Location `json:"location"` // 坐标 | ||
| 938 | - TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
| 939 | - Tags []int64 `json:"tags"` // 标签 | 930 | + Id int64 `json:"id"` |
| 931 | + CompanyId int64 `json:"companyId,optional"` | ||
| 932 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
| 933 | + Section []ArticleSection `json:"section"` // 填写的内容 | ||
| 934 | + Title string `json:"title"` // 标题 | ||
| 935 | + Images []string `json:"images"` // 图片 | ||
| 936 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
| 937 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
| 938 | + Location Location `json:"location"` // 坐标 | ||
| 939 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 940 | + Tags []int64 `json:"tags"` // 标签 | ||
| 941 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 940 | } | 942 | } |
| 941 | 943 | ||
| 942 | type SystemArticleUpdateResponse struct { | 944 | type SystemArticleUpdateResponse struct { |
| @@ -946,7 +948,7 @@ type SystemArticleUpdateResponse struct { | @@ -946,7 +948,7 @@ type SystemArticleUpdateResponse struct { | ||
| 946 | Images []string `json:"images"` //图片 | 948 | Images []string `json:"images"` //图片 |
| 947 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 949 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
| 948 | CountLove int `json:"countLove"` //点赞数量 | 950 | CountLove int `json:"countLove"` //点赞数量 |
| 949 | - CountComment int `json:"CountComment"` //评论数量 | 951 | + CountComment int `json:"countComment"` //评论数量 |
| 950 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 952 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 951 | Tags []int64 `json:"tags"` //标签 | 953 | Tags []int64 `json:"tags"` //标签 |
| 952 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 954 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| @@ -982,8 +984,6 @@ type SystemArticleGetHistoryResponse struct { | @@ -982,8 +984,6 @@ type SystemArticleGetHistoryResponse struct { | ||
| 982 | Id int64 `json:"id"` // id | 984 | Id int64 `json:"id"` // id |
| 983 | ArticleId int64 `json:"articleId"` // 文章ID | 985 | ArticleId int64 `json:"articleId"` // 文章ID |
| 984 | Title string `json:"title"` // 标题 | 986 | Title string `json:"title"` // 标题 |
| 985 | - AuthorId int64 `json:"authorId"` // 发布人id | ||
| 986 | - Author ArticleAuthor `json:"author"` // 发布人 | ||
| 987 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | 987 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 |
| 988 | Section []ArticleSection `json:"section"` // 文章的文本内容 | 988 | Section []ArticleSection `json:"section"` // 文章的文本内容 |
| 989 | Images []string `json:"images"` // 图片 | 989 | Images []string `json:"images"` // 图片 |
| @@ -992,11 +992,64 @@ type SystemArticleGetHistoryResponse struct { | @@ -992,11 +992,64 @@ type SystemArticleGetHistoryResponse struct { | ||
| 992 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 992 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
| 993 | WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 | 993 | WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 |
| 994 | Location Location `json:"location"` // 定位坐标 | 994 | Location Location `json:"location"` // 定位坐标 |
| 995 | - CountLove int `json:"countLove"` // 点赞数量 | ||
| 996 | - CountComment int `json:"countComment"` // 评论数量 | ||
| 997 | - CountRead int `json:"countRead"` // 浏览数量 | ||
| 998 | - Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | ||
| 999 | - TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 995 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
| 996 | + Tags []int64 `json:"tags"` // 标签 | ||
| 997 | +} | ||
| 998 | + | ||
| 999 | +type SystemArticleRestoreRequest struct { | ||
| 1000 | + Id int64 `json:"id"` //ID | ||
| 1001 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 1002 | +} | ||
| 1003 | + | ||
| 1004 | +type SystemArticleRestoreResponse struct { | ||
| 1005 | + Id int64 `json:"id"` //ID | ||
| 1006 | + ArticleId int64 `json:"articleId"` //文章ID | ||
| 1007 | +} | ||
| 1008 | + | ||
| 1009 | +type MiniHomePageRequest struct { | ||
| 1010 | + CompanyId int64 `path:",optional"` | ||
| 1011 | + UserId int64 `path:",optional"` | ||
| 1012 | +} | ||
| 1013 | + | ||
| 1014 | +type MiniHomePageResponse struct { | ||
| 1015 | + TagCategory []string `json:"tagCategory"` | ||
| 1016 | + Tags []ArticleTagCount `json:"tags"` | ||
| 1017 | +} | ||
| 1018 | + | ||
| 1019 | +type ArticleTagCount struct { | ||
| 1020 | + TagCategory string `json:"tagCategory"` // 标签分组 | ||
| 1021 | + TagId int64 `json:"tagId"` // 标签id | ||
| 1022 | + TagImage string `json:"tagImage"` // 对应的图标 | ||
| 1023 | + TagName string `json:"tagName"` // 标签名称 | ||
| 1024 | + TagRemark string `json:"tagRemark"` // 标签备注 | ||
| 1025 | + TotalArticle int `json:"totalArticle"` // 总的文章数量 | ||
| 1026 | + ReadArticle int `json:"readArticle"` // 已读的标签数量 | ||
| 1027 | +} | ||
| 1028 | + | ||
| 1029 | +type MiniSearchArticleRequest struct { | ||
| 1030 | + Page int `json:"page"` | ||
| 1031 | + Size int `json:"size"` | ||
| 1032 | + CompanyId int64 `json:",optional"` | ||
| 1033 | + UserId int64 `json:",optional"` | ||
| 1034 | + TagGroup string `json:"tagGroup"` | ||
| 1035 | + TagId int64 `json:"tagId"` | ||
| 1036 | + BeginTime int64 `json:"beginTime"` | ||
| 1037 | + EndTime int `json:"endTime"` | ||
| 1038 | + SearchWord string `json:"searchWord"` | ||
| 1039 | +} | ||
| 1040 | + | ||
| 1041 | +type MiniSearchArticleResponse struct { | ||
| 1042 | + Total int `json:"total"` | ||
| 1043 | + List []MiniSearchArticleItem `json:"list"` | ||
| 1044 | +} | ||
| 1045 | + | ||
| 1046 | +type MiniSearchArticleItem struct { | ||
| 1047 | + ArticleId int64 `json:"articleId"` | ||
| 1048 | + Title string `json:"title"` | ||
| 1049 | + Author string `json:"author"` // 发布人 | ||
| 1050 | + Images []string `json:"images"` | ||
| 1051 | + CreatedAt int64 `json:"createdAt"` | ||
| 1052 | + MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] | ||
| 1000 | } | 1053 | } |
| 1001 | 1054 | ||
| 1002 | type RoleGetRequest struct { | 1055 | type RoleGetRequest struct { |
| @@ -53,3 +53,10 @@ func (m *ArticleAndTag) CachePrimaryKeyFunc() string { | @@ -53,3 +53,10 @@ func (m *ArticleAndTag) CachePrimaryKeyFunc() string { | ||
| 53 | } | 53 | } |
| 54 | return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") | 54 | return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") |
| 55 | } | 55 | } |
| 56 | + | ||
| 57 | +// 统计所有已有标签的文章和人员已读的文章 | ||
| 58 | +type CountArticleTagRead struct { | ||
| 59 | + TotalArticle int `gorm:"total_article"` //标签下文章的数量 | ||
| 60 | + ReadArticle int `gorm:"read_article"` //人员已读的文章 | ||
| 61 | + TagId int64 `gorm:"tag_id"` // 标签的id | ||
| 62 | +} |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "fmt" | ||
| 5 | 6 | ||
| 6 | "github.com/jinzhu/copier" | 7 | "github.com/jinzhu/copier" |
| 7 | "github.com/pkg/errors" | 8 | "github.com/pkg/errors" |
| @@ -132,6 +133,59 @@ func (repository *ArticleAndTagRepository) DomainModelToModel(from *domain.Artic | @@ -132,6 +133,59 @@ func (repository *ArticleAndTagRepository) DomainModelToModel(from *domain.Artic | ||
| 132 | return to, err | 133 | return to, err |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 136 | +// 以TagId作为分组,统计所有已有标签的文章和人员已读的文章 | ||
| 137 | +func (repository *ArticleAndTagRepository) CountArticleReadGroupByTag(ctx context.Context, conn transaction.Conn, userId int64, companyId int64) ([]*domain.CountArticleTagRead, error) { | ||
| 138 | + | ||
| 139 | + sqlStr := ` | ||
| 140 | +-- 首页统计数据 | ||
| 141 | +with | ||
| 142 | +-- 按查看权限查询文章 | ||
| 143 | +-- 获取有标签的文章 | ||
| 144 | +-- 过滤出可展示的文章id | ||
| 145 | +t_article_and_tag_2 as ( | ||
| 146 | + select article_and_tag.article_id,article_and_tag.tag_id | ||
| 147 | + from article_and_tag | ||
| 148 | + join article on article_and_tag.article_id = article.id | ||
| 149 | + where article.deleted_at=0 | ||
| 150 | + and article.company_id = ? | ||
| 151 | + and article."show" = ? | ||
| 152 | + and (article.target_user =0 or article.who_read @> ?) | ||
| 153 | +), | ||
| 154 | +-- 查询人员已查看的文章 | ||
| 155 | +t_user_read as( | ||
| 156 | + select user_read_article.article_id from user_read_article where user_read_article.user_id = ? | ||
| 157 | +) | ||
| 158 | +-- 汇总统计 total_article 符合条件的文章总数,read_article 已浏览的数量 | ||
| 159 | +select count(t_article_and_tag_2.article_id) as total_article ,count(t_user_read.article_id) as read_article, t_article_and_tag_2.tag_id | ||
| 160 | +from t_article_and_tag_2 | ||
| 161 | +left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id | ||
| 162 | +group by t_article_and_tag_2.tag_id | ||
| 163 | +` | ||
| 164 | + condition := []interface{}{ | ||
| 165 | + companyId, | ||
| 166 | + domain.ArticleShowEnable, | ||
| 167 | + fmt.Sprintf("[%d]", userId), | ||
| 168 | + userId, | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + m := []*models.CountArticleTagRead{} | ||
| 172 | + db := conn.DB() | ||
| 173 | + result := db.Raw(sqlStr, condition...).Scan(&m) | ||
| 174 | + if result.Error != nil { | ||
| 175 | + return nil, result.Error | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + var dm []*domain.CountArticleTagRead | ||
| 179 | + for _, val := range m { | ||
| 180 | + dm = append(dm, &domain.CountArticleTagRead{ | ||
| 181 | + TagId: val.TagId, | ||
| 182 | + TotalArticle: val.TotalArticle, | ||
| 183 | + ReadArticle: val.ReadArticle, | ||
| 184 | + }) | ||
| 185 | + } | ||
| 186 | + return dm, nil | ||
| 187 | +} | ||
| 188 | + | ||
| 135 | func NewArticleAndTagRepository(cache *cache.CachedRepository) domain.ArticleAndTagRepository { | 189 | func NewArticleAndTagRepository(cache *cache.CachedRepository) domain.ArticleAndTagRepository { |
| 136 | return &ArticleAndTagRepository{CachedRepository: cache} | 190 | return &ArticleAndTagRepository{CachedRepository: cache} |
| 137 | } | 191 | } |
| @@ -279,11 +279,11 @@ func (repository *ArticleCommentRepository) Top5Comment(ctx context.Context, con | @@ -279,11 +279,11 @@ func (repository *ArticleCommentRepository) Top5Comment(ctx context.Context, con | ||
| 279 | article_comment.id , | 279 | article_comment.id , |
| 280 | (article_comment.count_reply +article_comment.count_user_love +article_comment.count_admin_love ) cnt | 280 | (article_comment.count_reply +article_comment.count_user_love +article_comment.count_admin_love ) cnt |
| 281 | from article_comment | 281 | from article_comment |
| 282 | - where top_id =0 and article_id =? and deleted_at=0 and show=0 and company_id=? | 282 | + where top_id =0 and article_id =? and deleted_at=0 and show= ? and company_id=? |
| 283 | order by cnt desc,article_comment.id desc | 283 | order by cnt desc,article_comment.id desc |
| 284 | limit 5 ` | 284 | limit 5 ` |
| 285 | db := conn.DB() | 285 | db := conn.DB() |
| 286 | - rows, err := db.Raw(sql1, articleId, companyId).Rows() | 286 | + rows, err := db.Raw(sql1, articleId, domain.CommentShowEnable, companyId).Rows() |
| 287 | if err != nil { | 287 | if err != nil { |
| 288 | return nil, err | 288 | return nil, err |
| 289 | } | 289 | } |
| @@ -278,34 +278,27 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor | @@ -278,34 +278,27 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor | ||
| 278 | return &ArticleRepository{CachedRepository: cache} | 278 | return &ArticleRepository{CachedRepository: cache} |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | +// -- 首页统计数据 | ||
| 281 | // with | 282 | // with |
| 282 | // -- 按查看权限查询文章 | 283 | // -- 按查看权限查询文章 |
| 283 | -// t_article as( | ||
| 284 | -// select article.id | ||
| 285 | -// from article | 284 | +// -- 获取有标签的文章 |
| 285 | +// -- 过滤出可展示的文章id | ||
| 286 | +// t_article_and_tag_2 as ( | ||
| 287 | +// select article_and_tag.article_id , article_and_tag.tag_id | ||
| 288 | +// from article_and_tag | ||
| 289 | +// join article on article_and_tag.article_id = article.id | ||
| 286 | // where article.deleted_at=0 | 290 | // where article.deleted_at=0 |
| 287 | // and article.company_id =1598224576532189184 | 291 | // and article.company_id =1598224576532189184 |
| 288 | // and article."show" =0 | 292 | // and article."show" =0 |
| 289 | // and (article.target_user =0 or article.who_read @>'[1]') | 293 | // and (article.target_user =0 or article.who_read @>'[1]') |
| 290 | // ), | 294 | // ), |
| 291 | -// -- 获取有标签的文章 | ||
| 292 | -// t_article_and_tag as ( | ||
| 293 | -// select article_and_tag.article_id ,article_and_tag.tag_id | ||
| 294 | -// from article_and_tag | ||
| 295 | -// where article_and_tag.company_id =1598224576532189184 | ||
| 296 | -// ), | ||
| 297 | -// -- 过滤出可展示的文章id | ||
| 298 | -// t_article_and_tag_2 as ( | ||
| 299 | -// select t_article_and_tag.article_id, t_article_and_tag.tag_id | ||
| 300 | -// from t_article_and_tag | ||
| 301 | -// join t_article on t_article_and_tag.article_id = t_article.id | ||
| 302 | -// ), | ||
| 303 | // -- 查询人员已查看的文章 | 295 | // -- 查询人员已查看的文章 |
| 304 | // t_user_read as( | 296 | // t_user_read as( |
| 305 | -// select user_read_article.article_id from user_read_article where user_read_article.user_id =1 | 297 | +// select user_read_article.article_id from user_read_article where user_read_article.user_id =1 |
| 306 | // ) | 298 | // ) |
| 307 | // -- 汇总统计 cnt_1符合条件的文章总数,cnt_2 已浏览的数量 | 299 | // -- 汇总统计 cnt_1符合条件的文章总数,cnt_2 已浏览的数量 |
| 308 | // select count(t_article_and_tag_2.article_id) as cnt_1 ,count(t_user_read.article_id) as cnt_2, t_article_and_tag_2.tag_id | 300 | // select count(t_article_and_tag_2.article_id) as cnt_1 ,count(t_user_read.article_id) as cnt_2, t_article_and_tag_2.tag_id |
| 309 | // from t_article_and_tag_2 | 301 | // from t_article_and_tag_2 |
| 310 | // left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id | 302 | // left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id |
| 311 | // group by t_article_and_tag_2.tag_id | 303 | // group by t_article_and_tag_2.tag_id |
| 304 | +// ; |
| @@ -121,8 +121,7 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti | @@ -121,8 +121,7 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti | ||
| 121 | ) | 121 | ) |
| 122 | queryFunc := func() (interface{}, error) { | 122 | queryFunc := func() (interface{}, error) { |
| 123 | tx = tx.Model(&ms). | 123 | tx = tx.Model(&ms). |
| 124 | - Where("company_id=?", companyId). | ||
| 125 | - Order("id asc") | 124 | + Where("company_id=?", companyId).Order("sort_by asc").Order("id asc") |
| 126 | 125 | ||
| 127 | if v, ok := queryOptions["name"]; ok { | 126 | if v, ok := queryOptions["name"]; ok { |
| 128 | tx = tx.Where("name like ?", v) | 127 | tx = tx.Where("name like ?", v) |
| @@ -25,7 +25,7 @@ type Article struct { | @@ -25,7 +25,7 @@ type Article struct { | ||
| 25 | CountLove int `json:"countLove"` // 点赞数量 | 25 | CountLove int `json:"countLove"` // 点赞数量 |
| 26 | CountComment int `json:"countComment"` // 评论数量 | 26 | CountComment int `json:"countComment"` // 评论数量 |
| 27 | CountRead int `json:"countRead"` // 浏览数量 | 27 | CountRead int `json:"countRead"` // 浏览数量 |
| 28 | - Show ArticleShow `json:"show"` // 评论的展示状态(0显示、1不显示) | 28 | + Show ArticleShow `json:"show"` // 评论的展示状态(1显示,2不显示、) |
| 29 | Tags []int64 `json:"tags"` // 定性标签 | 29 | Tags []int64 `json:"tags"` // 定性标签 |
| 30 | Summary string `json:"summary"` // 内容概要 | 30 | Summary string `json:"summary"` // 内容概要 |
| 31 | // ...more | 31 | // ...more |
| @@ -60,12 +60,12 @@ func (a ArticleTarget) Named() string { | @@ -60,12 +60,12 @@ func (a ArticleTarget) Named() string { | ||
| 60 | return "" | 60 | return "" |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | -// 文章的展示状态(0显示、1不显示) | 63 | +// 文章的展示状态(1显示,2不显示) |
| 64 | type ArticleShow int | 64 | type ArticleShow int |
| 65 | 65 | ||
| 66 | const ( | 66 | const ( |
| 67 | - ArticleShowEnable ArticleShow = 0 | ||
| 68 | - ArticleShowDisable ArticleShow = 1 | 67 | + ArticleShowEnable ArticleShow = 1 |
| 68 | + ArticleShowDisable ArticleShow = 2 | ||
| 69 | ) | 69 | ) |
| 70 | 70 | ||
| 71 | func (a ArticleShow) Named() string { | 71 | func (a ArticleShow) Named() string { |
| @@ -16,10 +16,18 @@ type ArticleAndTag struct { | @@ -16,10 +16,18 @@ type ArticleAndTag struct { | ||
| 16 | TagId int64 `json:"tagId"` | 16 | TagId int64 `json:"tagId"` |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | +// 以TagId作为分组,统计所有已有标签的文章和人员已读的文章 | ||
| 20 | +type CountArticleTagRead struct { | ||
| 21 | + TotalArticle int `gorm:"total_article"` //标签下文章的数量 | ||
| 22 | + ReadArticle int `gorm:"read_article"` //人员已读的文章 | ||
| 23 | + TagId int64 `gorm:"tag_id"` // 标签的id | ||
| 24 | +} | ||
| 25 | + | ||
| 19 | type ArticleAndTagRepository interface { | 26 | type ArticleAndTagRepository interface { |
| 20 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) | 27 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) |
| 21 | Update(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) | 28 | Update(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) |
| 22 | Delete(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) | 29 | Delete(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) |
| 23 | FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleAndTag, error) | 30 | FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleAndTag, error) |
| 24 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleAndTag, error) | 31 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleAndTag, error) |
| 32 | + CountArticleReadGroupByTag(ctx context.Context, con transaction.Conn, userId int64, companyId int64) ([]*CountArticleTagRead, error) | ||
| 25 | } | 33 | } |
| @@ -27,17 +27,17 @@ type ArticleComment struct { | @@ -27,17 +27,17 @@ type ArticleComment struct { | ||
| 27 | CountReply int `json:"countReply"` // 回复数量 | 27 | CountReply int `json:"countReply"` // 回复数量 |
| 28 | CountUserLove int `json:"countUserLove"` // 用户点赞数量 | 28 | CountUserLove int `json:"countUserLove"` // 用户点赞数量 |
| 29 | CountAdminLove int `json:"countAdminLove"` // 运营点赞数量 | 29 | CountAdminLove int `json:"countAdminLove"` // 运营点赞数量 |
| 30 | - Show CommentShow `json:"showState"` // 评论的展示状态(0显示、1不显示) | 30 | + Show CommentShow `json:"showState"` // 评论的展示状态(1显示、2不显示) |
| 31 | AtWho []UserSimple `json:"atWho"` // 填写评论时@的人 | 31 | AtWho []UserSimple `json:"atWho"` // 填写评论时@的人 |
| 32 | // ...more | 32 | // ...more |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | -// 评论的展示状态(0显示、1不显示) | 35 | +// 评论的展示状态(1显示、2不显示) |
| 36 | type CommentShow int | 36 | type CommentShow int |
| 37 | 37 | ||
| 38 | const ( | 38 | const ( |
| 39 | - CommentShowEnable CommentShow = 0 | ||
| 40 | - CommentShowDisable CommentShow = 1 | 39 | + CommentShowEnable CommentShow = 1 |
| 40 | + CommentShowDisable CommentShow = 2 | ||
| 41 | ) | 41 | ) |
| 42 | 42 | ||
| 43 | func (show CommentShow) Named() string { | 43 | func (show CommentShow) Named() string { |
pkg/tool/oss/ali_oss.go
0 → 100644
| 1 | +package oss | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "encoding/json" | ||
| 5 | + "fmt" | ||
| 6 | + "image" | ||
| 7 | + _ "image/jpeg" | ||
| 8 | + "net/http" | ||
| 9 | + "strings" | ||
| 10 | + "time" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type FileInfo struct { | ||
| 14 | + FileSize struct { | ||
| 15 | + Value string | ||
| 16 | + } | ||
| 17 | + Format struct { | ||
| 18 | + Value string | ||
| 19 | + } | ||
| 20 | + ImageHeight struct { | ||
| 21 | + Value string | ||
| 22 | + } | ||
| 23 | + ImageWidth struct { | ||
| 24 | + Value string | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func GetImageInfo(url string) (info FileInfo, err error) { | ||
| 29 | + //ok := strings.HasPrefix(url, "https://timeless-world.oss-cn-shenzhen.aliyuncs.com") | ||
| 30 | + ok := strings.HasPrefix(url, "http") | ||
| 31 | + if !ok { | ||
| 32 | + return | ||
| 33 | + } | ||
| 34 | + ok = strings.Contains(url, "aliyuncs") | ||
| 35 | + if !ok { | ||
| 36 | + return | ||
| 37 | + } | ||
| 38 | + apiUrl := url + `?x-oss-process=image/info` | ||
| 39 | + req, err := http.NewRequest(http.MethodGet, apiUrl, nil) | ||
| 40 | + if err != nil { | ||
| 41 | + return info, err | ||
| 42 | + } | ||
| 43 | + httpclient := http.Client{ | ||
| 44 | + Timeout: 30 * time.Second, | ||
| 45 | + } | ||
| 46 | + resp, err := httpclient.Do(req) | ||
| 47 | + if err != nil { | ||
| 48 | + return info, err | ||
| 49 | + } | ||
| 50 | + defer resp.Body.Close() | ||
| 51 | + if resp.StatusCode != http.StatusOK { | ||
| 52 | + return | ||
| 53 | + } | ||
| 54 | + jDecoder := json.NewDecoder(resp.Body) | ||
| 55 | + err = jDecoder.Decode(&info) | ||
| 56 | + if err != nil { | ||
| 57 | + return info, err | ||
| 58 | + } | ||
| 59 | + return info, nil | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +// 获取视频封面图 | ||
| 63 | +func GetVideoCover(videoUrl string) (coverUrl string, w int, h int, err error) { | ||
| 64 | + ok := strings.HasPrefix(videoUrl, "http") | ||
| 65 | + if !ok { | ||
| 66 | + return | ||
| 67 | + } | ||
| 68 | + ok = strings.Contains(videoUrl, "aliyuncs") | ||
| 69 | + if !ok { | ||
| 70 | + return | ||
| 71 | + } | ||
| 72 | + videoUrl = videoUrl + "?x-oss-process=video/snapshot,t_100,f_jpg,m_fast" | ||
| 73 | + res, err := http.Get(videoUrl) | ||
| 74 | + if err != nil || res.StatusCode != http.StatusOK { | ||
| 75 | + return videoUrl, 600, 600, fmt.Errorf("获取图片失败:%s", err) | ||
| 76 | + } | ||
| 77 | + defer res.Body.Close() | ||
| 78 | + m, _, err := image.Decode(res.Body) | ||
| 79 | + if err != nil { | ||
| 80 | + return videoUrl, 600, 600, fmt.Errorf("获取图片失败:%s", err) | ||
| 81 | + } | ||
| 82 | + return videoUrl, m.Bounds().Dx(), m.Bounds().Dy(), nil | ||
| 83 | +} |
pkg/tool/oss/ali_oss_test.go
0 → 100644
| 1 | +package oss | ||
| 2 | + | ||
| 3 | +import "testing" | ||
| 4 | + | ||
| 5 | +func TestGetVideoCover(t *testing.T) { | ||
| 6 | + | ||
| 7 | + cover, w, h, err := GetVideoCover("https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20230913/object/1694587897_yYfG6TYTsGMCKETxdnTEhAQjXpYGD3MB.mp4") | ||
| 8 | + t.Logf("cover=%v, w=%v, h=%v, err=%v", cover, w, h, err) | ||
| 9 | +} |
-
请 注册 或 登录 后发表评论