作者 郑周

Merge remote-tracking branch 'origin/dev' into dev

正在显示 37 个修改的文件 包含 1098 行增加118 行删除
@@ -1225,6 +1225,60 @@ @@ -1225,6 +1225,60 @@
1225 ] 1225 ]
1226 } 1226 }
1227 }, 1227 },
  1228 + "v1/system/article/history/{id}": {
  1229 + "get": {
  1230 + "summary": "管理后台帖子历史详情",
  1231 + "operationId": "SystemArticleGetHistory",
  1232 + "responses": {
  1233 + "200": {
  1234 + "description": "A successful response.",
  1235 + "schema": {
  1236 + "$ref": "#/definitions/SystemArticleGetHistoryResponse"
  1237 + }
  1238 + }
  1239 + },
  1240 + "parameters": [
  1241 + {
  1242 + "name": "id",
  1243 + "in": "path",
  1244 + "required": true,
  1245 + "type": "string"
  1246 + }
  1247 + ],
  1248 + "requestBody": {},
  1249 + "tags": [
  1250 + "article"
  1251 + ]
  1252 + }
  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 + },
1228 "v1/system/article/search": { 1282 "v1/system/article/search": {
1229 "post": { 1283 "post": {
1230 "summary": "管理后台获取文章列表", 1284 "summary": "管理后台获取文章列表",
@@ -4891,6 +4945,125 @@ @@ -4891,6 +4945,125 @@
4891 "total" 4945 "total"
4892 ] 4946 ]
4893 }, 4947 },
  4948 + "SystemArticleGetHistoryRequest": {
  4949 + "type": "object",
  4950 + "properties": {
  4951 + "id": {
  4952 + "type": "integer",
  4953 + "format": "int64",
  4954 + "description": "id"
  4955 + },
  4956 + "": {
  4957 + "type": "integer",
  4958 + "format": "int64"
  4959 + }
  4960 + },
  4961 + "title": "SystemArticleGetHistoryRequest",
  4962 + "required": [
  4963 + "id"
  4964 + ]
  4965 + },
  4966 + "SystemArticleGetHistoryResponse": {
  4967 + "type": "object",
  4968 + "properties": {
  4969 + "id": {
  4970 + "type": "integer",
  4971 + "format": "int64",
  4972 + "description": " id"
  4973 + },
  4974 + "articleId": {
  4975 + "type": "integer",
  4976 + "format": "int64",
  4977 + "description": " 文章ID"
  4978 + },
  4979 + "title": {
  4980 + "type": "string",
  4981 + "description": " 标题"
  4982 + },
  4983 + "createdAt": {
  4984 + "type": "integer",
  4985 + "format": "int64",
  4986 + "description": " 文章的发布时间"
  4987 + },
  4988 + "section": {
  4989 + "type": "array",
  4990 + "items": {
  4991 + "$ref": "#/definitions/ArticleSection"
  4992 + },
  4993 + "description": " 文章的文本内容"
  4994 + },
  4995 + "images": {
  4996 + "type": "array",
  4997 + "items": {
  4998 + "type": "string"
  4999 + },
  5000 + "description": " 图片"
  5001 + },
  5002 + "whoRead": {
  5003 + "type": "array",
  5004 + "items": {
  5005 + "type": "integer",
  5006 + "format": "int64"
  5007 + },
  5008 + "description": " 谁可查看"
  5009 + },
  5010 + "whoReadInfo": {
  5011 + "type": "array",
  5012 + "items": {
  5013 + "$ref": "#/definitions/UserShowName"
  5014 + },
  5015 + "description": " 谁可查看"
  5016 + },
  5017 + "whoReview": {
  5018 + "type": "array",
  5019 + "items": {
  5020 + "type": "integer",
  5021 + "format": "int64"
  5022 + },
  5023 + "description": " 谁可评论"
  5024 + },
  5025 + "whoReviewInfo": {
  5026 + "type": "array",
  5027 + "items": {
  5028 + "$ref": "#/definitions/UserShowName"
  5029 + },
  5030 + "description": " 谁可评论"
  5031 + },
  5032 + "location": {
  5033 + "$ref": "#/definitions/Location",
  5034 + "description": " 定位坐标"
  5035 + },
  5036 + "targetUser": {
  5037 + "type": "integer",
  5038 + "format": "int32",
  5039 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  5040 + },
  5041 + "tags": {
  5042 + "type": "array",
  5043 + "items": {
  5044 + "type": "integer",
  5045 + "format": "int64"
  5046 + },
  5047 + "description": " 标签"
  5048 + }
  5049 + },
  5050 + "title": "SystemArticleGetHistoryResponse",
  5051 + "required": [
  5052 + "id",
  5053 + "articleId",
  5054 + "title",
  5055 + "createdAt",
  5056 + "section",
  5057 + "images",
  5058 + "whoRead",
  5059 + "whoReadInfo",
  5060 + "whoReview",
  5061 + "whoReviewInfo",
  5062 + "location",
  5063 + "targetUser",
  5064 + "tags"
  5065 + ]
  5066 + },
4894 "SystemArticleGetRequest": { 5067 "SystemArticleGetRequest": {
4895 "type": "object", 5068 "type": "object",
4896 "properties": { 5069 "properties": {
@@ -5002,6 +5175,13 @@ @@ -5002,6 +5175,13 @@
5002 "type": "integer", 5175 "type": "integer",
5003 "format": "int32", 5176 "format": "int32",
5004 "description": " 评论的展示状态(0显示、1不显示)" 5177 "description": " 评论的展示状态(0显示、1不显示)"
  5178 + },
  5179 + "tags": {
  5180 + "type": "array",
  5181 + "items": {
  5182 + "$ref": "#/definitions/ArticleTagItem"
  5183 + },
  5184 + "description": "标签"
5005 } 5185 }
5006 }, 5186 },
5007 "title": "SystemArticleGetResponse", 5187 "title": "SystemArticleGetResponse",
@@ -5021,7 +5201,8 @@ @@ -5021,7 +5201,8 @@
5021 "countLove", 5201 "countLove",
5022 "countComment", 5202 "countComment",
5023 "countRead", 5203 "countRead",
5024 - "show" 5204 + "show",
  5205 + "tags"
5025 ] 5206 ]
5026 }, 5207 },
5027 "SystemArticleHistory": { 5208 "SystemArticleHistory": {
@@ -5114,6 +5295,45 @@ @@ -5114,6 +5295,45 @@
5114 "list" 5295 "list"
5115 ] 5296 ]
5116 }, 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 + },
5117 "SystemArticleSearch": { 5337 "SystemArticleSearch": {
5118 "type": "object", 5338 "type": "object",
5119 "properties": { 5339 "properties": {
@@ -5263,6 +5483,14 @@ @@ -5263,6 +5483,14 @@
5263 "format": "int64", 5483 "format": "int64",
5264 "description": "结束时间" 5484 "description": "结束时间"
5265 }, 5485 },
  5486 + "tags": {
  5487 + "type": "array",
  5488 + "items": {
  5489 + "type": "integer",
  5490 + "format": "int64"
  5491 + },
  5492 + "description": "标签"
  5493 + },
5266 "page": { 5494 "page": {
5267 "type": "integer", 5495 "type": "integer",
5268 "format": "int32", 5496 "format": "int32",
@@ -5358,6 +5586,14 @@ @@ -5358,6 +5586,14 @@
5358 "type": "integer", 5586 "type": "integer",
5359 "format": "int32", 5587 "format": "int32",
5360 "description": "分发方式 [0分发给所有人、1分发给指定的人]" 5588 "description": "分发方式 [0分发给所有人、1分发给指定的人]"
  5589 + },
  5590 + "tags": {
  5591 + "type": "array",
  5592 + "items": {
  5593 + "type": "integer",
  5594 + "format": "int64"
  5595 + },
  5596 + "description": " 标签"
5361 } 5597 }
5362 }, 5598 },
5363 "title": "SystemArticleUpdateRequest", 5599 "title": "SystemArticleUpdateRequest",
@@ -5370,7 +5606,8 @@ @@ -5370,7 +5606,8 @@
5370 "whoRead", 5606 "whoRead",
5371 "whoReview", 5607 "whoReview",
5372 "location", 5608 "location",
5373 - "targetUser" 5609 + "targetUser",
  5610 + "tags"
5374 ] 5611 ]
5375 }, 5612 },
5376 "SystemArticleUpdateResponse": { 5613 "SystemArticleUpdateResponse": {
@@ -5419,7 +5656,8 @@ @@ -5419,7 +5656,8 @@
5419 "tags": { 5656 "tags": {
5420 "type": "array", 5657 "type": "array",
5421 "items": { 5658 "items": {
5422 - "type": "string" 5659 + "type": "integer",
  5660 + "format": "int64"
5423 }, 5661 },
5424 "description": "标签" 5662 "description": "标签"
5425 }, 5663 },
@@ -75,9 +75,11 @@ service Core { @@ -75,9 +75,11 @@ service Core {
75 75
76 @doc "小程序首页数据展示" 76 @doc "小程序首页数据展示"
77 @handler MiniShowHomePage 77 @handler MiniShowHomePage
78 - get /show/home_page (MiniHomePageRequest) returns (MiniHomePageRespose)  
79 - 78 + get /show/home_page (MiniHomePageRequest) returns (MiniHomePageResponse)
80 79
  80 + @doc "小程序首页搜索文章"
  81 + @handler MiniSearchArticlePage
  82 + post /show/search_article (MiniSearchArticleRequest) returns (MiniSearchArticleResponse)
81 } 83 }
82 84
83 // 管理后台接口 85 // 管理后台接口
@@ -111,4 +113,7 @@ service Core { @@ -111,4 +113,7 @@ service Core {
111 @handler SystemArticleSearchMe 113 @handler SystemArticleSearchMe
112 post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse) 114 post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse)
113 115
  116 + @doc "管理后台文章恢复"
  117 + @handler SystemArticleRestore
  118 + post /article/restore (SystemArticleRestoreRequest) returns (SystemArticleRestoreResponse)
114 } 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
@@ -314,12 +315,12 @@ type ( @@ -314,12 +315,12 @@ 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 Id int64 `json:"id"`
322 - Group string `json:"group"` 323 + Category string `json:"category"`
323 Name string `json:"name"` 324 Name string `json:"name"`
324 Image string `json:"image"` 325 Image string `json:"image"`
325 } 326 }
@@ -398,8 +399,9 @@ type ( @@ -398,8 +399,9 @@ type (
398 WhoRead []int64 `json:"whoRead"` // 谁可以看 399 WhoRead []int64 `json:"whoRead"` // 谁可以看
399 WhoReview []int64 `json:"whoReview"` // 评论人 400 WhoReview []int64 `json:"whoReview"` // 评论人
400 Location Location `json:"location"` // 坐标 401 Location Location `json:"location"` // 坐标
401 - TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] 402 + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
402 Tags []int64 `json:"tags"` // 标签 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,11 +450,16 @@ type ( @@ -450,11 +450,16 @@ 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
458 } 463 }
459 ) 464 )
460 465
@@ -465,11 +470,12 @@ type ( @@ -465,11 +470,12 @@ type (
465 CompanyId int64 `path:",optional"` 470 CompanyId int64 `path:",optional"`
466 UserId int64 `path:",optional"` 471 UserId int64 `path:",optional"`
467 } 472 }
468 - MiniHomePageRespose { 473 + MiniHomePageResponse {
  474 + TagCategory []string `json:"tagCategory"`
469 Tags []ArticleTagCount `json:"tags"` 475 Tags []ArticleTagCount `json:"tags"`
470 } 476 }
471 ArticleTagCount { 477 ArticleTagCount {
472 - TagGroup string `json:"tagGroup"` // 标签分组 478 + TagCategory string `json:"tagCategory"` // 标签分组
473 TagId int64 `json:"tagId"` // 标签id 479 TagId int64 `json:"tagId"` // 标签id
474 TagImage string `json:"tagImage"` // 对应的图标 480 TagImage string `json:"tagImage"` // 对应的图标
475 TagName string `json:"tagName"` // 标签名称 481 TagName string `json:"tagName"` // 标签名称
@@ -478,3 +484,32 @@ type ( @@ -478,3 +484,32 @@ type (
478 ReadArticle int `json:"readArticle"` // 已读的标签数量 484 ReadArticle int `json:"readArticle"` // 已读的标签数量
479 } 485 }
480 ) 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:已读]
  514 + }
  515 +)
@@ -33,6 +33,9 @@ service Core { @@ -33,6 +33,9 @@ service Core {
33 @doc "用户信息" 33 @doc "用户信息"
34 @handler miniUserInfo 34 @handler miniUserInfo
35 post /mini/user/info (MiniUserInfoRequest) returns (MiniUserInfoResponse) 35 post /mini/user/info (MiniUserInfoRequest) returns (MiniUserInfoResponse)
  36 + @doc "用户统计"
  37 + @handler miniUserStatistics
  38 + post /mini/user/statistics (UserStatisticsRequest) returns (UserStatisticsResponse)
36 @doc "用户审核列表" 39 @doc "用户审核列表"
37 @handler miniUserAuditList 40 @handler miniUserAuditList
38 post /mini/user/audit-list (UserSearchRequest)returns(UserSearchResponse) 41 post /mini/user/audit-list (UserSearchRequest)returns(UserSearchResponse)
@@ -41,7 +44,10 @@ service Core { @@ -41,7 +44,10 @@ service Core {
41 post /mini/user/audit (MiniUserAuditRequest) 44 post /mini/user/audit (MiniUserAuditRequest)
42 @doc "部门用户列表" 45 @doc "部门用户列表"
43 @handler miniUserDepartmentUsers 46 @handler miniUserDepartmentUsers
44 - post /mini/user/department-users (MiniUserDepartmentUsersRequest)returns (MiniUserInfoResponse) 47 + post /mini/user/department-users (MiniUserDepartmentUsersRequest)
  48 + @doc "用户列表"
  49 + @handler miniUsersList
  50 + post /mini/user/user-list (MiniUsersListRequest)
45 @doc "关注我的人" 51 @doc "关注我的人"
46 @handler miniUserFollower 52 @handler miniUserFollower
47 post /mini/user/follower (MiniUserFollowedSearchRequest)returns(MiniUserFollowedSearchResponse) 53 post /mini/user/follower (MiniUserFollowedSearchRequest)returns(MiniUserFollowedSearchResponse)
@@ -105,6 +111,10 @@ type( @@ -105,6 +111,10 @@ type(
105 Departments []*Department `json:"departments"` 111 Departments []*Department `json:"departments"`
106 Users []*UserItem `json:"users"` 112 Users []*UserItem `json:"users"`
107 } 113 }
  114 + MiniUsersListRequest{
  115 + ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户)
  116 + RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户
  117 + }
108 MiniUserFollowedSearchRequest{ 118 MiniUserFollowedSearchRequest{
109 Page int `json:"page,optional"` 119 Page int `json:"page,optional"`
110 Size int `json:"size,optional"` 120 Size int `json:"size,optional"`
@@ -117,6 +127,7 @@ type( @@ -117,6 +127,7 @@ type(
117 Id int64 `json:"id,omitempty"` // 用户ID 127 Id int64 `json:"id,omitempty"` // 用户ID
118 CompanyId int64 `json:"companyId,omitempty"` // 公司ID 128 CompanyId int64 `json:"companyId,omitempty"` // 公司ID
119 CompanyName string `json:"companyName,omitempty"` // 公司名称 129 CompanyName string `json:"companyName,omitempty"` // 公司名称
  130 + CompanyCode string `json:"companyCode,omitempty"` // 公司编码(邀请码)
120 //DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID 131 //DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID
121 //Roles []int64 `json:"roleId,omitempty"` // 角色 132 //Roles []int64 `json:"roleId,omitempty"` // 角色
122 Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) 133 Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
@@ -216,6 +227,9 @@ service Core { @@ -216,6 +227,9 @@ service Core {
216 @doc "用户统计" 227 @doc "用户统计"
217 @handler systemUserStatistics 228 @handler systemUserStatistics
218 post /system/user/statistics (UserStatisticsRequest) returns (UserStatisticsResponse) 229 post /system/user/statistics (UserStatisticsRequest) returns (UserStatisticsResponse)
  230 + @doc "用户列表"
  231 + @handler systemUsersList
  232 + post /system/user/user-list (MiniUsersListRequest)
219 233
220 @doc "用户详情" 234 @doc "用户详情"
221 @handler systemUserGet 235 @handler systemUserGet
  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 +}
@@ -3,26 +3,27 @@ package article @@ -3,26 +3,27 @@ package article
3 import ( 3 import (
4 "net/http" 4 "net/http"
5 5
6 - "github.com/zeromicro/go-zero/rest/httpx"  
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" 6 "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" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 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"
10 ) 11 )
11 12
  13 +// 展示小程序端首页的数据
12 func MiniShowHomePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func MiniShowHomePageHandler(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.MiniHomePageRequest 16 var req types.MiniHomePageRequest
15 - if err := httpx.Parse(r, &req); err != nil {  
16 - httpx.ErrorCtx(r.Context(), w, err)  
17 - return  
18 - } 17 + // if err := httpx.Parse(r, &req); err != nil {
  18 + // httpx.ErrorCtx(r.Context(), w, err)
  19 + // return
  20 + // }
19 21
20 l := article.NewMiniShowHomePageLogic(r.Context(), svcCtx) 22 l := article.NewMiniShowHomePageLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.UserId = token.UserId
  25 + req.CompanyId = token.CompanyId
21 resp, err := l.MiniShowHomePage(&req) 26 resp, err := l.MiniShowHomePage(&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 }
  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 }
@@ -149,6 +149,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -149,6 +149,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
149 }, 149 },
150 { 150 {
151 Method: http.MethodPost, 151 Method: http.MethodPost,
  152 + Path: "/mini/user/statistics",
  153 + Handler: user.MiniUserStatisticsHandler(serverCtx),
  154 + },
  155 + {
  156 + Method: http.MethodPost,
152 Path: "/mini/user/audit-list", 157 Path: "/mini/user/audit-list",
153 Handler: user.MiniUserAuditListHandler(serverCtx), 158 Handler: user.MiniUserAuditListHandler(serverCtx),
154 }, 159 },
@@ -164,6 +169,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -164,6 +169,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
164 }, 169 },
165 { 170 {
166 Method: http.MethodPost, 171 Method: http.MethodPost,
  172 + Path: "/mini/user/user-list",
  173 + Handler: user.MiniUsersListHandler(serverCtx),
  174 + },
  175 + {
  176 + Method: http.MethodPost,
167 Path: "/mini/user/follower", 177 Path: "/mini/user/follower",
168 Handler: user.MiniUserFollowerHandler(serverCtx), 178 Handler: user.MiniUserFollowerHandler(serverCtx),
169 }, 179 },
@@ -207,6 +217,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -207,6 +217,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
207 Handler: user.SystemUserStatisticsHandler(serverCtx), 217 Handler: user.SystemUserStatisticsHandler(serverCtx),
208 }, 218 },
209 { 219 {
  220 + Method: http.MethodPost,
  221 + Path: "/system/user/user-list",
  222 + Handler: user.SystemUsersListHandler(serverCtx),
  223 + },
  224 + {
210 Method: http.MethodGet, 225 Method: http.MethodGet,
211 Path: "/system/user/:id", 226 Path: "/system/user/:id",
212 Handler: user.SystemUserGetHandler(serverCtx), 227 Handler: user.SystemUserGetHandler(serverCtx),
@@ -369,6 +384,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -369,6 +384,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
369 Path: "/show/home_page", 384 Path: "/show/home_page",
370 Handler: article.MiniShowHomePageHandler(serverCtx), 385 Handler: article.MiniShowHomePageHandler(serverCtx),
371 }, 386 },
  387 + {
  388 + Method: http.MethodPost,
  389 + Path: "/show/search_article",
  390 + Handler: article.MiniSearchArticlePageHandler(serverCtx),
  391 + },
372 }, 392 },
373 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), 393 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
374 rest.WithPrefix("/v1/mini"), 394 rest.WithPrefix("/v1/mini"),
@@ -406,6 +426,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -406,6 +426,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
406 Path: "/article/search/me", 426 Path: "/article/search/me",
407 Handler: article.SystemArticleSearchMeHandler(serverCtx), 427 Handler: article.SystemArticleSearchMeHandler(serverCtx),
408 }, 428 },
  429 + {
  430 + Method: http.MethodPost,
  431 + Path: "/article/restore",
  432 + Handler: article.SystemArticleRestoreHandler(serverCtx),
  433 + },
409 }, 434 },
410 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 435 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
411 rest.WithPrefix("/v1/system"), 436 rest.WithPrefix("/v1/system"),
  1 +package user
  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/user"
  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 MiniUserStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  14 + return func(w http.ResponseWriter, r *http.Request) {
  15 + var req types.UserStatisticsRequest
  16 + if err := httpx.Parse(r, &req); err != nil {
  17 + httpx.ErrorCtx(r.Context(), w, err)
  18 + return
  19 + }
  20 +
  21 + l := user.NewSystemUserStatisticsLogic(r.Context(), svcCtx)
  22 + resp, err := l.SystemUserStatistics(&req)
  23 + result.HttpResult(r, w, resp, err)
  24 + }
  25 +}
  1 +package user
  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/user"
  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 MiniUsersListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  14 + return func(w http.ResponseWriter, r *http.Request) {
  15 + var req types.MiniUsersListRequest
  16 + if err := httpx.Parse(r, &req); err != nil {
  17 + httpx.ErrorCtx(r.Context(), w, err)
  18 + return
  19 + }
  20 +
  21 + l := user.NewMiniAtUsersListLogic(r.Context(), svcCtx)
  22 + resp, err := l.MiniAtUsersList(&req)
  23 + result.HttpResult(r, w, resp, err)
  24 + }
  25 +}
  1 +package user
  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/user"
  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 SystemUsersListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  14 + return func(w http.ResponseWriter, r *http.Request) {
  15 + var req types.MiniUsersListRequest
  16 + if err := httpx.Parse(r, &req); err != nil {
  17 + httpx.ErrorCtx(r.Context(), w, err)
  18 + return
  19 + }
  20 +
  21 + l := user.NewMiniAtUsersListLogic(r.Context(), svcCtx)
  22 + resp, err := l.MiniAtUsersList(&req)
  23 + result.HttpResult(r, w, resp, err)
  24 + }
  25 +}
@@ -39,7 +39,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR @@ -39,7 +39,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
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, 41 Id: val.Id,
42 - Group: val.Category, 42 + Category: val.Category,
43 Name: val.Name, 43 Name: val.Name,
44 Image: val.Image.Url, 44 Image: val.Image.Url,
45 }) 45 })
@@ -49,7 +49,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR @@ -49,7 +49,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR
49 tagMap[val.Category] = []types.ArticleTagItem{ 49 tagMap[val.Category] = []types.ArticleTagItem{
50 { 50 {
51 Id: val.Id, 51 Id: val.Id,
52 - Group: val.Category, 52 + Category: val.Category,
53 Name: val.Name, 53 Name: val.Name,
54 Image: val.Image.Url, 54 Image: val.Image.Url,
55 }, 55 },
@@ -61,7 +61,7 @@ func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagR @@ -61,7 +61,7 @@ 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], 64 + Category: group[i],
65 Tags: tagMap[group[i]], 65 Tags: tagMap[group[i]],
66 }) 66 })
67 } 67 }
@@ -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 +}
@@ -5,7 +5,10 @@ import ( @@ -5,7 +5,10 @@ import (
5 5
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
8 10
  11 + "github.com/samber/lo"
9 "github.com/zeromicro/go-zero/core/logx" 12 "github.com/zeromicro/go-zero/core/logx"
10 ) 13 )
11 14
@@ -23,8 +26,47 @@ func NewMiniShowHomePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) * @@ -23,8 +26,47 @@ func NewMiniShowHomePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
23 } 26 }
24 } 27 }
25 28
26 -func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) (resp *types.MiniHomePageRespose, err error) {  
27 - // todo: add your logic here and delete this line 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 + }
28 46
29 - return 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
30 } 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"
@@ -72,7 +73,7 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ @@ -72,7 +73,7 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ
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 Id: tag.Id,
75 - Group: tag.Category, 76 + Category: tag.Category,
76 Name: tag.Name, 77 Name: tag.Name,
77 Image: tag.Image.Url, 78 Image: tag.Image.Url,
78 }) 79 })
@@ -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
@@ -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
@@ -42,14 +42,21 @@ func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp * @@ -42,14 +42,21 @@ func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp *
42 if _, roles, err = l.svcCtx.RoleRepository.Find(l.ctx, conn, domain.IndexCompanyId(user.CompanyId)().MustWithKV("ids", user.Roles)); err != nil { 42 if _, roles, err = l.svcCtx.RoleRepository.Find(l.ctx, conn, domain.IndexCompanyId(user.CompanyId)().MustWithKV("ids", user.Roles)); err != nil {
43 return nil, xerr.NewErrMsgErr("角色不存在", err) 43 return nil, xerr.NewErrMsgErr("角色不存在", err)
44 } 44 }
  45 +
45 resp = &types.MiniUserInfoResponse{ 46 resp = &types.MiniUserInfoResponse{
46 User: &types.UserItem{ 47 User: &types.UserItem{
47 Id: user.Id, 48 Id: user.Id,
48 Name: user.Name, 49 Name: user.Name,
  50 + Avatar: user.Avatar,
  51 + Position: user.Position,
49 }, 52 },
50 Accounts: make([]types.Account, 0), 53 Accounts: make([]types.Account, 0),
51 Auths: make([]types.Auth, 0), 54 Auths: make([]types.Auth, 0),
52 } 55 }
  56 + if company, _ := domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne); company != nil {
  57 + resp.User.CompanyName = company.Name
  58 + resp.User.CompanyCode = company.Code
  59 + }
53 _, accounts, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().MustWithKV("phone", user.Phone).MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed})) 60 _, accounts, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().MustWithKV("phone", user.Phone).MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}))
54 if err != nil { 61 if err != nil {
55 return nil, xerr.NewErrMsgErr("用户不存在", err) 62 return nil, xerr.NewErrMsgErr("用户不存在", err)
  1 +package user
  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 MiniUserStatisticsLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserStatisticsLogic {
  19 + return &MiniUserStatisticsLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserStatisticsLogic) MiniUserStatistics(req *types.UserStatisticsRequest) (resp *types.UserStatisticsResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  2 +
  3 +import (
  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/contextdata"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  9 +
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  12 +
  13 + "github.com/zeromicro/go-zero/core/logx"
  14 +)
  15 +
  16 +type MiniAtUsersListLogic struct {
  17 + logx.Logger
  18 + ctx context.Context
  19 + svcCtx *svc.ServiceContext
  20 +}
  21 +
  22 +func NewMiniAtUsersListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniAtUsersListLogic {
  23 + return &MiniAtUsersListLogic{
  24 + Logger: logx.WithContext(ctx),
  25 + ctx: ctx,
  26 + svcCtx: svcCtx,
  27 + }
  28 +}
  29 +
  30 +func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest) (resp interface{}, err error) {
  31 + var (
  32 + conn = l.svcCtx.DefaultDBConn()
  33 + article *domain.Article
  34 + users []*domain.User
  35 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  36 + onlyUsers []int64
  37 + )
  38 + if req.ArticleId != 0 {
  39 + if article, err = l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId); err != nil {
  40 + return nil, xerr.NewErrMsgErr("用户列表获取失败", err)
  41 + }
  42 + if article.TargetUser == domain.ArticleTargetLimit && len(article.WhoRead) > 0 {
  43 + onlyUsers = article.WhoRead
  44 + }
  45 + }
  46 + if _, users, err = l.svcCtx.UserRepository.FindDepartmentUsers(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions().WithFindOnly()); err != nil {
  47 + return nil, xerr.NewErrMsgErr("用户列表获取失败", err)
  48 + }
  49 + if len(onlyUsers) > 0 {
  50 + onlyUsersMap := lo.KeyBy(onlyUsers, func(item int64) int64 {
  51 + return item
  52 + })
  53 + users = lo.Filter(users, func(item *domain.User, index int) bool {
  54 + if _, ok := onlyUsersMap[item.Id]; ok {
  55 + return false
  56 + }
  57 + return true
  58 + })
  59 + }
  60 + var list = make([]*domain.User, 0)
  61 + lo.ForEach(users, func(item *domain.User, index int) {
  62 + list = append(list, &domain.User{
  63 + Id: item.Id,
  64 + Name: item.Name,
  65 + PinYinName: item.PinYinName,
  66 + })
  67 + })
  68 + return map[string]interface{}{
  69 + "list": list,
  70 + }, nil
  71 +}
  1 +package user
  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 SystemUsersListLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewSystemUsersListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUsersListLogic {
  19 + return &SystemUsersListLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *SystemUsersListLogic) SystemUsersList(req *types.MiniUsersListRequest) error {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return nil
  30 +}
@@ -325,6 +325,11 @@ type MiniUserDepartmentUsersResponse struct { @@ -325,6 +325,11 @@ type MiniUserDepartmentUsersResponse struct {
325 Users []*UserItem `json:"users"` 325 Users []*UserItem `json:"users"`
326 } 326 }
327 327
  328 +type MiniUsersListRequest struct {
  329 + ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户)
  330 + RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户
  331 +}
  332 +
328 type MiniUserFollowedSearchRequest struct { 333 type MiniUserFollowedSearchRequest struct {
329 Page int `json:"page,optional"` 334 Page int `json:"page,optional"`
330 Size int `json:"size,optional"` 335 Size int `json:"size,optional"`
@@ -339,6 +344,7 @@ type UserItem struct { @@ -339,6 +344,7 @@ type UserItem struct {
339 Id int64 `json:"id,omitempty"` // 用户ID 344 Id int64 `json:"id,omitempty"` // 用户ID
340 CompanyId int64 `json:"companyId,omitempty"` // 公司ID 345 CompanyId int64 `json:"companyId,omitempty"` // 公司ID
341 CompanyName string `json:"companyName,omitempty"` // 公司名称 346 CompanyName string `json:"companyName,omitempty"` // 公司名称
  347 + CompanyCode string `json:"companyCode,omitempty"` // 公司编码(邀请码)
342 Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) 348 Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
343 Name string `json:"name,omitempty"` // 名称 349 Name string `json:"name,omitempty"` // 名称
344 Avatar string `json:"avatar,omitempty"` // 头像 350 Avatar string `json:"avatar,omitempty"` // 头像
@@ -615,9 +621,10 @@ type MiniArticleGetResponse struct { @@ -615,9 +621,10 @@ type MiniArticleGetResponse struct {
615 CountLove int `json:"countLove"` // 点赞数量 621 CountLove int `json:"countLove"` // 点赞数量
616 CountComment int `json:"countComment"` // 评论数量 622 CountComment int `json:"countComment"` // 评论数量
617 CountRead int `json:"countRead"` // 浏览数量 623 CountRead int `json:"countRead"` // 浏览数量
618 - Show int `json:"show"` // 评论的展示状态(0显示、1不显示) 624 + Show int `json:"show"` // 评论的展示状态(1显示、2不显示)
619 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) 625 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
620 MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞) 626 MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
  627 + Tags []string `json:"tags"` //文章的标签
621 } 628 }
622 629
623 type ArticleSection struct { 630 type ArticleSection struct {
@@ -849,13 +856,13 @@ type MiniAllArticleTagResponse struct { @@ -849,13 +856,13 @@ type MiniAllArticleTagResponse struct {
849 } 856 }
850 857
851 type ArticleTagGroup struct { 858 type ArticleTagGroup struct {
852 - Group string `json:"group"` 859 + Category string `json:"category"`
853 Tags []ArticleTagItem `json:"tags"` 860 Tags []ArticleTagItem `json:"tags"`
854 } 861 }
855 862
856 type ArticleTagItem struct { 863 type ArticleTagItem struct {
857 Id int64 `json:"id"` 864 Id int64 `json:"id"`
858 - Group string `json:"group"` 865 + Category string `json:"category"`
859 Name string `json:"name"` 866 Name string `json:"name"`
860 Image string `json:"image"` 867 Image string `json:"image"`
861 } 868 }
@@ -929,8 +936,9 @@ type SystemArticleUpdateRequest struct { @@ -929,8 +936,9 @@ type SystemArticleUpdateRequest struct {
929 WhoRead []int64 `json:"whoRead"` // 谁可以看 936 WhoRead []int64 `json:"whoRead"` // 谁可以看
930 WhoReview []int64 `json:"whoReview"` // 评论人 937 WhoReview []int64 `json:"whoReview"` // 评论人
931 Location Location `json:"location"` // 坐标 938 Location Location `json:"location"` // 坐标
932 - TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] 939 + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
933 Tags []int64 `json:"tags"` // 标签 940 Tags []int64 `json:"tags"` // 标签
  941 + AccessToken string `header:"x-mmm-accesstoken"` // 授权token
934 } 942 }
935 943
936 type SystemArticleUpdateResponse struct { 944 type SystemArticleUpdateResponse struct {
@@ -940,7 +948,7 @@ type SystemArticleUpdateResponse struct { @@ -940,7 +948,7 @@ type SystemArticleUpdateResponse struct {
940 Images []string `json:"images"` //图片 948 Images []string `json:"images"` //图片
941 CreatedAt int64 `json:"createdAt"` //文章的创建日期 949 CreatedAt int64 `json:"createdAt"` //文章的创建日期
942 CountLove int `json:"countLove"` //点赞数量 950 CountLove int `json:"countLove"` //点赞数量
943 - CountComment int `json:"CountComment"` //评论数量 951 + CountComment int `json:"countComment"` //评论数量
944 Show int `json:"show"` //是否隐藏 [0显示、1不显示] 952 Show int `json:"show"` //是否隐藏 [0显示、1不显示]
945 Tags []int64 `json:"tags"` //标签 953 Tags []int64 `json:"tags"` //标签
946 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] 954 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
@@ -976,8 +984,6 @@ type SystemArticleGetHistoryResponse struct { @@ -976,8 +984,6 @@ type SystemArticleGetHistoryResponse struct {
976 Id int64 `json:"id"` // id 984 Id int64 `json:"id"` // id
977 ArticleId int64 `json:"articleId"` // 文章ID 985 ArticleId int64 `json:"articleId"` // 文章ID
978 Title string `json:"title"` // 标题 986 Title string `json:"title"` // 标题
979 - AuthorId int64 `json:"authorId"` // 发布人id  
980 - Author ArticleAuthor `json:"author"` // 发布人  
981 CreatedAt int64 `json:"createdAt"` // 文章的发布时间 987 CreatedAt int64 `json:"createdAt"` // 文章的发布时间
982 Section []ArticleSection `json:"section"` // 文章的文本内容 988 Section []ArticleSection `json:"section"` // 文章的文本内容
983 Images []string `json:"images"` // 图片 989 Images []string `json:"images"` // 图片
@@ -986,11 +992,18 @@ type SystemArticleGetHistoryResponse struct { @@ -986,11 +992,18 @@ type SystemArticleGetHistoryResponse struct {
986 WhoReview []int64 `json:"whoReview"` // 谁可评论 992 WhoReview []int64 `json:"whoReview"` // 谁可评论
987 WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论 993 WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
988 Location Location `json:"location"` // 定位坐标 994 Location Location `json:"location"` // 定位坐标
989 - CountLove int `json:"countLove"` // 点赞数量  
990 - CountComment int `json:"countComment"` // 评论数量  
991 - CountRead int `json:"countRead"` // 浏览数量  
992 - Show int `json:"show"` // 评论的展示状态(0显示、1不显示)  
993 - 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
994 } 1007 }
995 1008
996 type MiniHomePageRequest struct { 1009 type MiniHomePageRequest struct {
@@ -998,12 +1011,13 @@ type MiniHomePageRequest struct { @@ -998,12 +1011,13 @@ type MiniHomePageRequest struct {
998 UserId int64 `path:",optional"` 1011 UserId int64 `path:",optional"`
999 } 1012 }
1000 1013
1001 -type MiniHomePageRespose struct { 1014 +type MiniHomePageResponse struct {
  1015 + TagCategory []string `json:"tagCategory"`
1002 Tags []ArticleTagCount `json:"tags"` 1016 Tags []ArticleTagCount `json:"tags"`
1003 } 1017 }
1004 1018
1005 type ArticleTagCount struct { 1019 type ArticleTagCount struct {
1006 - TagGroup string `json:"tagGroup"` // 标签分组 1020 + TagCategory string `json:"tagCategory"` // 标签分组
1007 TagId int64 `json:"tagId"` // 标签id 1021 TagId int64 `json:"tagId"` // 标签id
1008 TagImage string `json:"tagImage"` // 对应的图标 1022 TagImage string `json:"tagImage"` // 对应的图标
1009 TagName string `json:"tagName"` // 标签名称 1023 TagName string `json:"tagName"` // 标签名称
@@ -1012,6 +1026,32 @@ type ArticleTagCount struct { @@ -1012,6 +1026,32 @@ type ArticleTagCount struct {
1012 ReadArticle int `json:"readArticle"` // 已读的标签数量 1026 ReadArticle int `json:"readArticle"` // 已读的标签数量
1013 } 1027 }
1014 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:已读]
  1053 +}
  1054 +
1015 type RoleGetRequest struct { 1055 type RoleGetRequest struct {
1016 Id int64 `path:"id"` 1056 Id int64 `path:"id"`
1017 } 1057 }
@@ -136,24 +136,23 @@ func (repository *ArticleAndTagRepository) DomainModelToModel(from *domain.Artic @@ -136,24 +136,23 @@ func (repository *ArticleAndTagRepository) DomainModelToModel(from *domain.Artic
136 // 以TagId作为分组,统计所有已有标签的文章和人员已读的文章 136 // 以TagId作为分组,统计所有已有标签的文章和人员已读的文章
137 func (repository *ArticleAndTagRepository) CountArticleReadGroupByTag(ctx context.Context, conn transaction.Conn, userId int64, companyId int64) ([]*domain.CountArticleTagRead, error) { 137 func (repository *ArticleAndTagRepository) CountArticleReadGroupByTag(ctx context.Context, conn transaction.Conn, userId int64, companyId int64) ([]*domain.CountArticleTagRead, error) {
138 138
139 - sqlStr := `  
140 --- 首页统计数据 139 + sqlStr := `-- 首页统计数据
141 with 140 with
142 -- 按查看权限查询文章 141 -- 按查看权限查询文章
143 -- 获取有标签的文章 142 -- 获取有标签的文章
144 -- 过滤出可展示的文章id 143 -- 过滤出可展示的文章id
145 t_article_and_tag_2 as ( 144 t_article_and_tag_2 as (
146 - select article_and_tag.article_id , article_and_tag.tag_id 145 + select article_and_tag.article_id,article_and_tag.tag_id
147 from article_and_tag 146 from article_and_tag
148 join article on article_and_tag.article_id = article.id 147 join article on article_and_tag.article_id = article.id
149 where article.deleted_at=0 148 where article.deleted_at=0
150 - and article.company_id =1598224576532189184  
151 - and article."show" =0  
152 - and (article.target_user =0 or article.who_read @>'[1]') 149 + and article.company_id = ?
  150 + and article."show" = ?
  151 + and (article.target_user =0 or article.who_read @> ?)
153 ), 152 ),
154 -- 查询人员已查看的文章 153 -- 查询人员已查看的文章
155 t_user_read as( 154 t_user_read as(
156 - select user_read_article.article_id from user_read_article where user_read_article.user_id =1 155 + select user_read_article.article_id from user_read_article where user_read_article.user_id = ?
157 ) 156 )
158 -- 汇总统计 total_article 符合条件的文章总数,read_article 已浏览的数量 157 -- 汇总统计 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 158 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
@@ -163,6 +162,7 @@ group by t_article_and_tag_2.tag_id @@ -163,6 +162,7 @@ group by t_article_and_tag_2.tag_id
163 ` 162 `
164 condition := []interface{}{ 163 condition := []interface{}{
165 companyId, 164 companyId,
  165 + domain.ArticleShowEnable,
166 fmt.Sprintf("[%d]", userId), 166 fmt.Sprintf("[%d]", userId),
167 userId, 167 userId,
168 } 168 }
@@ -175,7 +175,6 @@ group by t_article_and_tag_2.tag_id @@ -175,7 +175,6 @@ group by t_article_and_tag_2.tag_id
175 } 175 }
176 176
177 var dm []*domain.CountArticleTagRead 177 var dm []*domain.CountArticleTagRead
178 -  
179 for _, val := range m { 178 for _, val := range m {
180 dm = append(dm, &domain.CountArticleTagRead{ 179 dm = append(dm, &domain.CountArticleTagRead{
181 TagId: val.TagId, 180 TagId: val.TagId,
@@ -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,27 +278,11 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor @@ -278,27 +278,11 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor
278 return &ArticleRepository{CachedRepository: cache} 278 return &ArticleRepository{CachedRepository: cache}
279 } 279 }
280 280
281 -// -- 首页统计数据  
282 -// with  
283 -// -- 按查看权限查询文章  
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  
290 -// where article.deleted_at=0  
291 -// and article.company_id =1598224576532189184  
292 -// and article."show" =0  
293 -// and (article.target_user =0 or article.who_read @>'[1]')  
294 -// ),  
295 -// -- 查询人员已查看的文章  
296 -// t_user_read as(  
297 -// select user_read_article.article_id from user_read_article where user_read_article.user_id =1  
298 -// )  
299 -// -- 汇总统计 cnt_1符合条件的文章总数,cnt_2 已浏览的数量  
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  
301 -// from t_article_and_tag_2  
302 -// left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id  
303 -// group by t_article_and_tag_2.tag_id  
304 -// ; 281 +// select *
  282 +// from article
  283 +// join article_and_tag on article.id = article_and_tag.article_id
  284 +// where article."show" =1
  285 +// and article_and_tag.tag_id =any(select article_tag.id from article_tag where category ='分组三' )
  286 +// and article_and_tag.tag_id =0
  287 +// and article.created_at >=0 and article.created_at <=9000000000
  288 +// and article.title like '%%'
@@ -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 {
@@ -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 {
  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: 5 * 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 + httpclient := http.Client{
  74 + Timeout: 5 * time.Second,
  75 + }
  76 + res, err := httpclient.Get(videoUrl)
  77 + if err != nil || res.StatusCode != http.StatusOK {
  78 + return videoUrl, 600, 600, fmt.Errorf("获取图片失败:%s", err)
  79 + }
  80 + defer res.Body.Close()
  81 + m, _, err := image.Decode(res.Body)
  82 + if err != nil {
  83 + return videoUrl, 600, 600, fmt.Errorf("获取图片失败:%s", err)
  84 + }
  85 + return videoUrl, m.Bounds().Dx(), m.Bounds().Dy(), nil
  86 +}
  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 +}