作者 yangfu

角色权限

正在显示 30 个修改的文件 包含 514 行增加193 行删除
  1 +syntax = "v1"
1 import "core/comment.api" 2 import "core/comment.api"
2 import "core/message.api" 3 import "core/message.api"
3 import "core/article_tag.api" 4 import "core/article_tag.api"
1 syntax = "v1" 1 syntax = "v1"
2 2
  3 +import "article_type.api"
  4 +
3 info( 5 info(
4 title: "文章内容处理" 6 title: "文章内容处理"
5 desc: "编辑处理文章内容" 7 desc: "编辑处理文章内容"
@@ -18,9 +20,6 @@ service Core { @@ -18,9 +20,6 @@ service Core {
18 @doc "小程序创建发布内容" 20 @doc "小程序创建发布内容"
19 @handler MiniCreateArticle 21 @handler MiniCreateArticle
20 post /article (MiniArticleCreateRequest) returns (MiniArticleCreateResponse) 22 post /article (MiniArticleCreateRequest) returns (MiniArticleCreateResponse)
21 - @doc "小程序获取我发布的文章"  
22 - @handler MiniArticleSearchMe  
23 - post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)  
24 @doc "小程序获取文章内容详情" 23 @doc "小程序获取文章内容详情"
25 @handler MiniGetArticle 24 @handler MiniGetArticle
26 get /article/:id (MiniArticleGetRequest) returns (MiniArticleGetResponse) 25 get /article/:id (MiniArticleGetRequest) returns (MiniArticleGetResponse)
@@ -30,128 +29,25 @@ service Core { @@ -30,128 +29,25 @@ service Core {
30 @doc "小程序人员操作点赞文章/评论" 29 @doc "小程序人员操作点赞文章/评论"
31 @handler MiniSetUserLike 30 @handler MiniSetUserLike
32 post /article/user_like/set (MiniSetUserLikeRequset) returns (MiniSetUserLikeResponse) 31 post /article/user_like/set (MiniSetUserLikeRequset) returns (MiniSetUserLikeResponse)
33 -}  
34 32
35 -// 坐标地点描述  
36 -type Location {  
37 - Longitude float64 `json:"longitude,optional"` //经度  
38 - Latitude float64 `json:"latitude,optional"` //纬度  
39 - Descript string `json:"descript,optional"` //地点描述  
40 -} 33 + @doc "小程序获取我发布的文章"
  34 + @handler MiniArticleSearchMe
  35 + post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)
41 36
42 -// 人员的简单展示信息  
43 -type Author {  
44 - Id int64 `json:"id"` // 人员id  
45 - Name string `json:"name"` // 人员的名字  
46 - Avatar string `json:"avatar"` // 人员头像URL  
47 - Group string `json:"group"` // 人员的分组  
48 - Position string `json:"position"` // 职位  
49 - Company string `json:"company"` // 公司  
50 } 37 }
51 38
52 -//小程序端创建发布文章  
53 -type (  
54 - MiniArticleCreateRequest {  
55 - Title string `json:"title"` //标题  
56 - Section []string `json:"section"` //文章的文本内容  
57 - AuthorId int64 `json:"authorId,optional"` //发布人id  
58 - Images []string `json:"images,optional"` //图片  
59 - WhoRead []int64 `json:"whoRead,optional"` //谁可查看  
60 - WhoReview []int64 `json:"whoReview,optional"` //谁可评论  
61 - Location Location `json:"location,optional"` //定位坐标  
62 - }  
63 - MiniArticleCreateResponse {  
64 - Id int64 `json:"id"`  
65 - }  
66 -)  
67 -  
68 -//小程序端查看文章的详情  
69 -type (  
70 - MiniArticleGetRequest {  
71 - Id int64 `path:"id"` //id  
72 - CompanyId int64 `path:"-"`  
73 - }  
74 - MiniArticleGetResponse {  
75 - Id int64 `json:"id"` //id  
76 - Title string `json:"title"` //标题  
77 - AuthorId int64 `json:"authorId"` //发布人id  
78 - Author Author `json:"author"` //发布人  
79 - CreatedAt int64 `json:"createdAt"` //文章的发布时间  
80 - Section []ArticleSection `json:"section"` //文章的文本内容  
81 - Images []string `json:"images"` //图片  
82 - WhoRead []int64 `json:"whoRead"` //谁可查看  
83 - WhoReview []int64 `json:"whoReview"` //谁可评论  
84 - Location Location `json:"location"` //定位坐标  
85 - CountLove int `json:"countLove"` // 点赞数量  
86 - CountComment int `json:"countComment"` // 评论数量  
87 - CountRead int `json:"countRead"` // 浏览数量  
88 - Show int `json:"show"` // 评论的展示状态(0显示、1不显示)  
89 - }  
90 - ArticleSection {  
91 - Id int64 `json:"id"` //段落id  
92 - Content string `json:"content"` // 文本内容  
93 - SortBy int `json:"sortBy"` // 排序  
94 - TotalComment int `json:"totalComment"` // 评论的数量  
95 - }  
96 -)  
97 -  
98 -// 获取我的发文章记录  
99 -type (  
100 - MiniArticleSearchMeRequest {  
101 - AuthorId int64 `json:"-"`  
102 - CompanyId int64 `json:"-"`  
103 - Page int `json:"page"`  
104 - Size int `json:"size"`  
105 - }  
106 -  
107 - MiniArticleSearchMeResponse {  
108 - Total int `json:"total"`  
109 - List []ArticleSearchMe `json:"list"`  
110 - }  
111 -  
112 - ArticleSearchMe {  
113 - Id int64 `json:"id"` //id  
114 - Title string `json:"title"` //标题  
115 - Images []string `json:"images"` //图片  
116 - CreatedAt int64 `json:"createdAt"` //文章的创建日期  
117 - CountLove int `json:"countLove"` //点赞数量  
118 - CountComment int `json:"CountComment"` //评论数量  
119 - Show int `json:"show"` //是否隐藏 [0显示、1不显示]  
120 - }  
121 -)  
122 -  
123 -//获取列表,文章有哪些人进行了点赞  
124 -type (  
125 - MiniUserLikeArticleRequest {  
126 - ArticleId int64 `json:"articleId"` // 文章id  
127 - CompanyId int64 `json:"-"` //公司id  
128 - Page int `json:"page"` //分页,第几页  
129 - Size int `json:"size"` //分页,每页几条  
130 - }  
131 - MiniUserLikeArticleResponse {  
132 - Total int64 `json:"total"` //总数  
133 - List []WhichUserLikeArticle `json:"list"` //列表  
134 - }  
135 - WhichUserLikeArticle {  
136 - ArticleId int64 `json:"articleId"` // 文章id  
137 - UserId int64 `json:"userId"` // 人员id  
138 - Name string `json:"name"` // 人员名称  
139 - Avatar string `json:"avatar"` // 人员头像  
140 - CreatedAt int64 `json:"createdAt"` // 点赞记录的时间  
141 - } 39 +// 管理后台接口
  40 +@server(
  41 + prefix: v1/system
  42 + group: article
  43 + jwt: MiniAuth
142 ) 44 )
  45 +service Core {
  46 + @doc "管理后台获取文章内容详情"
  47 + @handler SystemGetArticle
  48 + get /article/:id (SystemArticleGetRequest) returns (SystemArticleGetResponse)
143 49
144 -// 人员点赞文章/评论  
145 -type (  
146 - MiniSetUserLikeRequset {  
147 - ArticleId int64 `json:"articleId"` //文章id  
148 - CommentId int64 `json:"commentId"` //评论id  
149 - UserId int64 `json:"-"` //操作人  
150 - Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞  
151 - }  
152 - MiniSetUserLikeResponse {  
153 - ArticleId int64 `json:"articleId"` //文章id  
154 - CommentId int64 `json:"commentId"` //评论id  
155 - Count int `json:"count"` //现有的点赞数量  
156 - }  
157 -)  
  50 + @doc "管理后台获取文章列表"
  51 + @handler SystemSearchArticle
  52 + post /article/search (SystemArticleSearchRequest) returns (SystemArticleSearchResponse)
  53 +}
  1 +syntax = "v1"
  2 +
  3 +// 坐标地点描述
  4 +type Location {
  5 + Longitude float64 `json:"longitude,optional"` //经度
  6 + Latitude float64 `json:"latitude,optional"` //纬度
  7 + Descript string `json:"descript,optional"` //地点描述
  8 +}
  9 +
  10 +// 人员的简单展示信息
  11 +type Author {
  12 + Id int64 `json:"id"` // 人员id
  13 + Name string `json:"name"` // 人员的名字
  14 + Avatar string `json:"avatar"` // 人员头像URL
  15 + Group string `json:"group"` // 人员的分组
  16 + Position string `json:"position"` // 职位
  17 + Company string `json:"company"` // 公司
  18 +}
  19 +
  20 +//小程序端创建发布文章
  21 +type (
  22 + MiniArticleCreateRequest {
  23 + Title string `json:"title"` //标题
  24 + Section []string `json:"section"` //文章的文本内容
  25 + AuthorId int64 `json:"authorId,optional"` //发布人id
  26 + Images []string `json:"images,optional"` //图片
  27 + WhoRead []int64 `json:"whoRead,optional"` //谁可查看
  28 + WhoReview []int64 `json:"whoReview,optional"` //谁可评论
  29 + Location Location `json:"location,optional"` //定位坐标
  30 + }
  31 + MiniArticleCreateResponse {
  32 + Id int64 `json:"id"`
  33 + }
  34 +)
  35 +
  36 +//小程序端查看文章的详情
  37 +type (
  38 + MiniArticleGetRequest {
  39 + Id int64 `path:"id"` //id
  40 + CompanyId int64 `path:",optional"`
  41 + }
  42 + MiniArticleGetResponse {
  43 + Id int64 `json:"id"` //id
  44 + Title string `json:"title"` //标题
  45 + AuthorId int64 `json:"authorId"` //发布人id
  46 + Author Author `json:"author"` //发布人
  47 + CreatedAt int64 `json:"createdAt"` //文章的发布时间
  48 + Section []ArticleSection `json:"section"` //文章的文本内容
  49 + Images []string `json:"images"` //图片
  50 + WhoRead []int64 `json:"whoRead"` //谁可查看
  51 + WhoReview []int64 `json:"whoReview"` //谁可评论
  52 + Location Location `json:"location"` //定位坐标
  53 + CountLove int `json:"countLove"` // 点赞数量
  54 + CountComment int `json:"countComment"` // 评论数量
  55 + CountRead int `json:"countRead"` // 浏览数量
  56 + Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
  57 + Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
  58 + }
  59 + ArticleSection {
  60 + Id int64 `json:"id"` //段落id
  61 + Content string `json:"content"` // 文本内容
  62 + SortBy int `json:"sortBy"` // 排序
  63 + TotalComment int `json:"totalComment"` // 评论的数量
  64 + }
  65 +)
  66 +
  67 +// 小程序获取我的发文章记录
  68 +type (
  69 + MiniArticleSearchMeRequest {
  70 + AuthorId int64 `json:",optional"`
  71 + CompanyId int64 `json:",optional"`
  72 + Page int `json:"page"`
  73 + Size int `json:"size"`
  74 + }
  75 +
  76 + MiniArticleSearchMeResponse {
  77 + Total int `json:"total"`
  78 + List []ArticleSearchMe `json:"list"`
  79 + }
  80 +
  81 + ArticleSearchMe {
  82 + Id int64 `json:"id"` //id
  83 + Title string `json:"title"` //标题
  84 + Images []string `json:"images"` //图片
  85 + CreatedAt int64 `json:"createdAt"` //文章的创建日期
  86 + CountLove int `json:"countLove"` //点赞数量
  87 + CountComment int `json:"CountComment"` //评论数量
  88 + Show int `json:"show"` //是否隐藏 [0显示、1不显示]
  89 + }
  90 +)
  91 +
  92 +//小程序端获取文章有哪些人进行了点赞
  93 +type (
  94 + MiniUserLikeArticleRequest {
  95 + ArticleId int64 `json:"articleId"` // 文章id
  96 + CompanyId int64 `json:",optional"` //公司id
  97 + Page int `json:"page"` //分页,第几页
  98 + Size int `json:"size"` //分页,每页几条
  99 + }
  100 + MiniUserLikeArticleResponse {
  101 + Total int64 `json:"total"` //总数
  102 + List []WhichUserLikeArticle `json:"list"` //列表
  103 + }
  104 + WhichUserLikeArticle {
  105 + ArticleId int64 `json:"articleId"` // 文章id
  106 + UserId int64 `json:"userId"` // 人员id
  107 + Name string `json:"name"` // 人员名称
  108 + Avatar string `json:"avatar"` // 人员头像
  109 + CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
  110 + }
  111 +)
  112 +
  113 +// 小程序端人员点赞文章/评论
  114 +type (
  115 + MiniSetUserLikeRequset {
  116 + ArticleId int64 `json:"articleId"` //文章id
  117 + CommentId int64 `json:"commentId"` //评论id
  118 + UserId int64 `json:",optional"` //操作人
  119 + Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞
  120 + }
  121 + MiniSetUserLikeResponse {
  122 + ArticleId int64 `json:"articleId"` //文章id
  123 + CommentId int64 `json:"commentId"` //评论id
  124 + Count int `json:"count"` //现有的点赞数量
  125 + }
  126 +)
  127 +
  128 +//管理后台获取文章详情
  129 +type (
  130 + SystemArticleGetRequest {
  131 + Id int64 `path:"id"` //id
  132 + CompanyId int64 `path:",optional"`
  133 + }
  134 +
  135 + UserShowName {
  136 + Id int `json:"id"`
  137 + Name int `json:"name"`
  138 + }
  139 +
  140 + SystemArticleGetResponse {
  141 + Id int64 `json:"id"` // id
  142 + Title string `json:"title"` // 标题
  143 + AuthorId int64 `json:"authorId"` // 发布人id
  144 + Author Author `json:"author"` // 发布人
  145 + CreatedAt int64 `json:"createdAt"` // 文章的发布时间
  146 + Section []ArticleSection `json:"section"` // 文章的文本内容
  147 + Images []string `json:"images"` // 图片
  148 + WhoRead []int64 `json:"whoRead"` // 谁可查看
  149 + WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
  150 + WhoReview []int64 `json:"whoReview"` // 谁可评论
  151 + WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
  152 + Location Location `json:"location"` // 定位坐标
  153 + CountLove int `json:"countLove"` // 点赞数量
  154 + CountComment int `json:"countComment"` // 评论数量
  155 + CountRead int `json:"countRead"` // 浏览数量
  156 + Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
  157 + }
  158 +)
  159 +
  160 +//管理后台获取文章列表
  161 +type (
  162 + SystemArticleSearchRequest {
  163 + CompanyId int64 `json:",optional"`
  164 + Page int `json:"page"`
  165 + Size int `json:"size"`
  166 + }
  167 +
  168 + SystemArticleSearchResponse {
  169 + Total int `json:"total"`
  170 + List []SystemArticleSearch `json:"list"`
  171 + }
  172 + SystemArticleSearch {
  173 + Id int64 `json:"id"` //id
  174 + Title string `json:"title"` //标题
  175 + Author string `json:"author"` //发布人
  176 + Images []string `json:"images"` //图片
  177 + CreatedAt int64 `json:"createdAt"` //文章的创建日期
  178 + CountLove int `json:"countLove"` //点赞数量
  179 + CountComment int `json:"CountComment"` //评论数量
  180 + Show int `json:"show"` //是否隐藏 [0显示、1不显示]
  181 + Tags []string `json:"tags"` //标签
  182 + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
  183 + }
  184 +)
@@ -8,7 +8,6 @@ info( @@ -8,7 +8,6 @@ info(
8 version: "v1" 8 version: "v1"
9 ) 9 )
10 10
11 -  
12 // 小程序接口 11 // 小程序接口
13 @server( 12 @server(
14 prefix: v1 13 prefix: v1
@@ -21,7 +20,6 @@ service Core { @@ -21,7 +20,6 @@ service Core {
21 get /mini/comment (CommentRequest) returns (CommentResposne) 20 get /mini/comment (CommentRequest) returns (CommentResposne)
22 } 21 }
23 22
24 -  
25 // 后台接口 23 // 后台接口
26 @server( 24 @server(
27 prefix: v1 25 prefix: v1
@@ -34,15 +32,13 @@ service Core { @@ -34,15 +32,13 @@ service Core {
34 get /system/comment (CommentRequest) returns (CommentResposne) 32 get /system/comment (CommentRequest) returns (CommentResposne)
35 } 33 }
36 34
37 -type(  
38 - CommentRequest struct{  
39 - 35 +type (
  36 + CommentRequest {
40 } 37 }
41 - CommentResposne struct{ 38 + CommentResposne {
42 List []Comment `json:"list"` 39 List []Comment `json:"list"`
43 } 40 }
44 41
45 - Comment struct{  
46 - 42 + Comment {
47 } 43 }
48 ) 44 )
@@ -24,7 +24,7 @@ service Core { @@ -24,7 +24,7 @@ service Core {
24 } 24 }
25 25
26 type ( 26 type (
27 - MessageSystemRequest struct { 27 + MessageSystemRequest {
28 Page int `json:"page"` 28 Page int `json:"page"`
29 Size int `json:"size"` 29 Size int `json:"size"`
30 } 30 }
@@ -32,7 +32,7 @@ type ( @@ -32,7 +32,7 @@ type (
32 List []MessageSystemItem `json:"list"` 32 List []MessageSystemItem `json:"list"`
33 Total int64 `json:"total"` 33 Total int64 `json:"total"`
34 } 34 }
35 - MessageSystemItem struct { 35 + MessageSystemItem {
36 Id int64 `json:"id"` // ID 36 Id int64 `json:"id"` // ID
37 Type int `json:"type"` // 系统分类 37 Type int `json:"type"` // 系统分类
38 Title string `json:"title"` // 标题 38 Title string `json:"title"` // 标题
@@ -40,7 +40,7 @@ type ( @@ -40,7 +40,7 @@ type (
40 CreatedAt int64 `json:"createdAt"` // 创建时间 40 CreatedAt int64 `json:"createdAt"` // 创建时间
41 } 41 }
42 42
43 - MessageBusinessRequest struct { 43 + MessageBusinessRequest {
44 Type int `json:"type"` 44 Type int `json:"type"`
45 Page int `json:"page"` 45 Page int `json:"page"`
46 Size int `json:"size"` 46 Size int `json:"size"`
@@ -49,7 +49,7 @@ type ( @@ -49,7 +49,7 @@ type (
49 List []MessageBusinessItem `json:"list"` 49 List []MessageBusinessItem `json:"list"`
50 Total int64 `json:"total"` 50 Total int64 `json:"total"`
51 } 51 }
52 - MessageBusinessItem struct { 52 + MessageBusinessItem {
53 Id int64 `json:"id"` 53 Id int64 `json:"id"`
54 Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) 54 Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
55 OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) 55 OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌)
@@ -67,7 +67,7 @@ type ( @@ -67,7 +67,7 @@ type (
67 Comment *Comment `json:"comment"` // 评论(不一定是自己,可能是被人@到) 67 Comment *Comment `json:"comment"` // 评论(不一定是自己,可能是被人@到)
68 } 68 }
69 69
70 - User struct { 70 + User {
71 Id int64 `json:"id"` 71 Id int64 `json:"id"`
72 CompanyId int64 `json:"companyId,omitempty"` // 公司ID 72 CompanyId int64 `json:"companyId,omitempty"` // 公司ID
73 CompanyName string `json:"companyName,omitempty"` // 公司名称 73 CompanyName string `json:"companyName,omitempty"` // 公司名称
@@ -77,10 +77,11 @@ type ( @@ -77,10 +77,11 @@ type (
77 } 77 }
78 78
79 79
80 - SimpleArticle struct { 80 + SimpleArticle {
81 Id int64 `json:"id"` 81 Id int64 `json:"id"`
82 Title string `json:"title"` // 文章标题 82 Title string `json:"title"` // 文章标题
83 CountLove int `json:"countLove"` // 点赞数量 83 CountLove int `json:"countLove"` // 点赞数量
84 CountComment int `json:"countComment"` // 评论数量 84 CountComment int `json:"countComment"` // 评论数量
85 } 85 }
86 ) 86 )
  87 +
@@ -3,7 +3,7 @@ Host: 0.0.0.0 @@ -3,7 +3,7 @@ Host: 0.0.0.0
3 Port: 8081 3 Port: 8081
4 Verbose: true 4 Verbose: true
5 Migrate: false 5 Migrate: false
6 - 6 +Timeout: 30000
7 Log: 7 Log:
8 #Mode: file 8 #Mode: file
9 Encoding: plain 9 Encoding: plain
@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
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" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
11 ) 12 )
12 13
13 func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -23,10 +24,6 @@ func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -23,10 +24,6 @@ func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
23 req.AuthorId = token.UserId 24 req.AuthorId = token.UserId
24 req.CompanyId = token.CompanyId 25 req.CompanyId = token.CompanyId
25 resp, err := l.MiniArticleSearchMe(&req) 26 resp, err := l.MiniArticleSearchMe(&req)
26 - if err != nil {  
27 - httpx.ErrorCtx(r.Context(), w, err)  
28 - } else {  
29 - httpx.OkJsonCtx(r.Context(), w, resp)  
30 - } 27 + result.HttpResult(r, w, resp, err)
31 } 28 }
32 } 29 }
@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
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" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
11 ) 12 )
12 13
13 func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -22,10 +23,7 @@ func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -22,10 +23,7 @@ func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
22 l := article.NewMiniCreateArticleLogic(r.Context(), svcCtx) 23 l := article.NewMiniCreateArticleLogic(r.Context(), svcCtx)
23 req.AuthorId = token.UserId 24 req.AuthorId = token.UserId
24 resp, err := l.MiniCreateArticle(&req) 25 resp, err := l.MiniCreateArticle(&req)
25 - if err != nil {  
26 - httpx.ErrorCtx(r.Context(), w, err)  
27 - } else {  
28 - httpx.OkJsonCtx(r.Context(), w, resp)  
29 - } 26 + result.HttpResult(r, w, resp, err)
  27 +
30 } 28 }
31 } 29 }
@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
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" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
11 ) 12 )
12 13
13 func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -22,10 +23,6 @@ func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -22,10 +23,6 @@ func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
22 token := contextdata.GetUserTokenFromCtx(r.Context()) 23 token := contextdata.GetUserTokenFromCtx(r.Context())
23 req.CompanyId = token.CompanyId 24 req.CompanyId = token.CompanyId
24 resp, err := l.MiniGetArticle(&req) 25 resp, err := l.MiniGetArticle(&req)
25 - if err != nil {  
26 - httpx.ErrorCtx(r.Context(), w, err)  
27 - } else {  
28 - httpx.OkJsonCtx(r.Context(), w, resp)  
29 - } 26 + result.HttpResult(r, w, resp, err)
30 } 27 }
31 } 28 }
@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
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" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
11 ) 12 )
12 13
13 func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -22,10 +23,6 @@ func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -22,10 +23,6 @@ func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
22 token := contextdata.GetUserTokenFromCtx(r.Context()) 23 token := contextdata.GetUserTokenFromCtx(r.Context())
23 req.UserId = token.UserId 24 req.UserId = token.UserId
24 resp, err := l.MiniSetUserLike(&req) 25 resp, err := l.MiniSetUserLike(&req)
25 - if err != nil {  
26 - httpx.ErrorCtx(r.Context(), w, err)  
27 - } else {  
28 - httpx.OkJsonCtx(r.Context(), w, resp)  
29 - } 26 + result.HttpResult(r, w, resp, err)
30 } 27 }
31 } 28 }
@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
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" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
11 ) 12 )
12 13
13 func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -22,10 +23,6 @@ func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -22,10 +23,6 @@ func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
22 token := contextdata.GetUserTokenFromCtx(r.Context()) 23 token := contextdata.GetUserTokenFromCtx(r.Context())
23 req.CompanyId = token.CompanyId 24 req.CompanyId = token.CompanyId
24 resp, err := l.MiniUserLikeArticle(&req) 25 resp, err := l.MiniUserLikeArticle(&req)
25 - if err != nil {  
26 - httpx.ErrorCtx(r.Context(), w, err)  
27 - } else {  
28 - httpx.OkJsonCtx(r.Context(), w, resp)  
29 - } 26 + result.HttpResult(r, w, resp, err)
30 } 27 }
31 } 28 }
  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 SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.SystemArticleGetRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := article.NewSystemGetArticleLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemGetArticle(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  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 SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.SystemArticleSearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := article.NewSystemSearchArticleLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemSearchArticle(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
@@ -189,11 +189,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -189,11 +189,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
189 Handler: article.MiniCreateArticleHandler(serverCtx), 189 Handler: article.MiniCreateArticleHandler(serverCtx),
190 }, 190 },
191 { 191 {
192 - Method: http.MethodPost,  
193 - Path: "/article/search/me",  
194 - Handler: article.MiniArticleSearchMeHandler(serverCtx),  
195 - },  
196 - {  
197 Method: http.MethodGet, 192 Method: http.MethodGet,
198 Path: "/article/:id", 193 Path: "/article/:id",
199 Handler: article.MiniGetArticleHandler(serverCtx), 194 Handler: article.MiniGetArticleHandler(serverCtx),
@@ -208,6 +203,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -208,6 +203,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
208 Path: "/article/user_like/set", 203 Path: "/article/user_like/set",
209 Handler: article.MiniSetUserLikeHandler(serverCtx), 204 Handler: article.MiniSetUserLikeHandler(serverCtx),
210 }, 205 },
  206 + {
  207 + Method: http.MethodPost,
  208 + Path: "/article/search/me",
  209 + Handler: article.MiniArticleSearchMeHandler(serverCtx),
  210 + },
211 }, 211 },
212 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), 212 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
213 rest.WithPrefix("/v1/mini"), 213 rest.WithPrefix("/v1/mini"),
@@ -217,6 +217,23 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -217,6 +217,23 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
217 []rest.Route{ 217 []rest.Route{
218 { 218 {
219 Method: http.MethodGet, 219 Method: http.MethodGet,
  220 + Path: "/article/:id",
  221 + Handler: article.SystemGetArticleHandler(serverCtx),
  222 + },
  223 + {
  224 + Method: http.MethodPost,
  225 + Path: "/article/search",
  226 + Handler: article.SystemSearchArticleHandler(serverCtx),
  227 + },
  228 + },
  229 + rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
  230 + rest.WithPrefix("/v1/system"),
  231 + )
  232 +
  233 + server.AddRoutes(
  234 + []rest.Route{
  235 + {
  236 + Method: http.MethodGet,
220 Path: "/system/role/:id", 237 Path: "/system/role/:id",
221 Handler: role.SystemGetRoleHandler(serverCtx), 238 Handler: role.SystemGetRoleHandler(serverCtx),
222 }, 239 },
@@ -35,7 +35,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR @@ -35,7 +35,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
35 if err != nil { 35 if err != nil {
36 return nil, xerr.NewErrMsgErr("创建文章内容失败", err) 36 return nil, xerr.NewErrMsgErr("创建文章内容失败", err)
37 } 37 }
38 - //TODO 获取人员信息 38 + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, author.CompanyId)
  39 + if err != nil {
  40 + return nil, xerr.NewErrMsgErr("创建文章内容失败", err)
  41 + }
39 articleAuthor := domain.UserSimple{ 42 articleAuthor := domain.UserSimple{
40 Id: author.Id, 43 Id: author.Id,
41 Name: author.Name, 44 Name: author.Name,
@@ -43,9 +46,16 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR @@ -43,9 +46,16 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
43 GroupId: 0, 46 GroupId: 0,
44 Group: "", 47 Group: "",
45 Position: author.Position, 48 Position: author.Position,
46 - Company: "", 49 + Company: companyInfo.Name,
47 CompanyId: author.CompanyId, 50 CompanyId: author.CompanyId,
48 } 51 }
  52 + if author.DepartmentId > 0 {
  53 + department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, author.DepartmentId)
  54 + if err == nil {
  55 + articleAuthor.GroupId = department.Id
  56 + articleAuthor.Group = department.Name
  57 + }
  58 + }
49 if len(req.Images) > 9 { 59 if len(req.Images) > 9 {
50 return nil, xerr.NewErrMsg("图片数量最多9张") 60 return nil, xerr.NewErrMsg("图片数量最多9张")
51 } 61 }
@@ -76,10 +86,12 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR @@ -76,10 +86,12 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
76 } 86 }
77 //检查文章可被哪些人评论 87 //检查文章可被哪些人评论
78 whoReview := []int64{} 88 whoReview := []int64{}
  89 + if len(req.WhoReview) > 0 {
  90 + whoReview = lo.Uniq(req.WhoReview)
  91 + }
79 //有指定可查看人的情况 92 //有指定可查看人的情况
80 if len(whoRead) > 0 { 93 if len(whoRead) > 0 {
81 if len(whoReview) > 0 { 94 if len(whoReview) > 0 {
82 - whoReview = lo.Uniq(req.WhoReview)  
83 // 检查 whoRead 是否 完全包含 whoReview 95 // 检查 whoRead 是否 完全包含 whoReview
84 ok := lo.Every(whoRead, whoReview) 96 ok := lo.Every(whoRead, whoReview)
85 if !ok { 97 if !ok {
@@ -147,6 +159,11 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR @@ -147,6 +159,11 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
147 Descript: req.Location.Descript, 159 Descript: req.Location.Descript,
148 }, 160 },
149 TargetUser: domain.ArticleTargetAll, 161 TargetUser: domain.ArticleTargetAll,
  162 + CountLove: 0,
  163 + CountComment: 0,
  164 + CountRead: 0,
  165 + Show: 0,
  166 + Tags: []int64{},
150 } 167 }
151 if len(whoRead) > 0 { 168 if len(whoRead) > 0 {
152 newArticle.TargetUser = domain.ArticleTargetLimit 169 newArticle.TargetUser = domain.ArticleTargetLimit
@@ -92,8 +92,11 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( @@ -92,8 +92,11 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
92 CountComment: articleInfo.CountComment, 92 CountComment: articleInfo.CountComment,
93 CountRead: articleInfo.CountRead, 93 CountRead: articleInfo.CountRead,
94 Show: int(articleInfo.Show), 94 Show: int(articleInfo.Show),
  95 + Edit: 0,
  96 + }
  97 + if articleInfo.CreatedAt != articleInfo.UpdatedAt {
  98 + resp.Edit = 1
95 } 99 }
96 -  
97 for _, val := range articleInfo.Images { 100 for _, val := range articleInfo.Images {
98 resp.Images = append(resp.Images, val.Url) 101 resp.Images = append(resp.Images, val.Url)
99 } 102 }
@@ -228,7 +228,9 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ @@ -228,7 +228,9 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
228 flagInfo := domain.UserLoveFlag{ 228 flagInfo := domain.UserLoveFlag{
229 Id: 0, 229 Id: 0,
230 ArticleId: req.ArticleId, 230 ArticleId: req.ArticleId,
231 - CommentId: req.CommentId, 231 + ArticleAuthor: articleInfo.AuthorId,
  232 + CommentId: 0,
  233 + CommentAuthor: 0,
232 UserId: req.UserId, 234 UserId: req.UserId,
233 } 235 }
234 // 去除点赞标识 236 // 去除点赞标识
@@ -247,7 +249,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ @@ -247,7 +249,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
247 return nil, xerr.NewErrMsgErr("设置点赞标识失败", err) 249 return nil, xerr.NewErrMsgErr("设置点赞标识失败", err)
248 } 250 }
249 articleInfo, err = l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId) 251 articleInfo, err = l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
250 - if err == nil { 252 + if err != nil {
251 return nil, xerr.NewErrMsgErr("获取点赞数量失败", err) 253 return nil, xerr.NewErrMsgErr("获取点赞数量失败", err)
252 } 254 }
253 resp = &types.MiniSetUserLikeResponse{ 255 resp = &types.MiniSetUserLikeResponse{
@@ -307,7 +309,9 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ @@ -307,7 +309,9 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ
307 flagInfo := domain.UserLoveFlag{ 309 flagInfo := domain.UserLoveFlag{
308 Id: 0, 310 Id: 0,
309 ArticleId: req.ArticleId, 311 ArticleId: req.ArticleId,
  312 + ArticleAuthor: articleInfo.AuthorId,
310 CommentId: req.CommentId, 313 CommentId: req.CommentId,
  314 + CommentAuthor: commentInfo.FromUserId,
311 UserId: req.UserId, 315 UserId: req.UserId,
312 } 316 }
313 // 设置赞标识 317 // 设置赞标识
@@ -25,7 +25,7 @@ func NewMiniUserLikeArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext @@ -25,7 +25,7 @@ func NewMiniUserLikeArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext
25 } 25 }
26 } 26 }
27 27
28 -// 获取点赞的人员列表 28 +// 获取点赞文章的的人员列表
29 func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeArticleRequest) (resp *types.MiniUserLikeArticleResponse, err error) { 29 func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeArticleRequest) (resp *types.MiniUserLikeArticleResponse, err error) {
30 var conn = l.svcCtx.DefaultDBConn() 30 var conn = l.svcCtx.DefaultDBConn()
31 queryOption := domain.NewQueryOptions(). 31 queryOption := domain.NewQueryOptions().
  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 SystemGetArticleLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewSystemGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetArticleLogic {
  19 + return &SystemGetArticleLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequest) (resp *types.SystemArticleGetResponse, 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 +
  9 + "github.com/zeromicro/go-zero/core/logx"
  10 +)
  11 +
  12 +type SystemSearchArticleLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewSystemSearchArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemSearchArticleLogic {
  19 + return &SystemSearchArticleLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleSearchRequest) (resp *types.SystemArticleSearchResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
@@ -55,22 +55,32 @@ func (l *MiniSystemLogic) ArticleDefined(conn transaction.Conn, companyId, at in @@ -55,22 +55,32 @@ func (l *MiniSystemLogic) ArticleDefined(conn transaction.Conn, companyId, at in
55 return l.createMessage(conn, companyId, at, domain.MsgTypeNormal, "帖子已定性", fmt.Sprintf("您的帖子[%s]已被定性,如有疑问,请联系运营管理员了解详情。", item)) 55 return l.createMessage(conn, companyId, at, domain.MsgTypeNormal, "帖子已定性", fmt.Sprintf("您的帖子[%s]已被定性,如有疑问,请联系运营管理员了解详情。", item))
56 } 56 }
57 57
58 -// AbnormalArticleUnapproved 文章未审核通过 58 +//// ArticleAuth 文章权限变更
  59 +//func (l *MiniSystemLogic) ArticleAuth(conn transaction.Conn, companyId, at int64, item string) (err error) {
  60 +// return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "权限变更", fmt.Sprintf("您的帖子[%s]可见权限已添加,如有疑问,请联系运营管理员了解详情。", item))
  61 +//}
  62 +
  63 +// AbnormalArticleUnapproved 异常通知-文章未审核通过
59 func (l *MiniSystemLogic) AbnormalArticleUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) { 64 func (l *MiniSystemLogic) AbnormalArticleUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) {
60 return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "发帖未通过审核", fmt.Sprintf("您的帖子[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item)) 65 return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "发帖未通过审核", fmt.Sprintf("您的帖子[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item))
61 } 66 }
62 67
63 -// AbnormalArticleHidden 文章被隐藏 68 +// AbnormalArticleHidden 异常通知-文章被隐藏
64 func (l *MiniSystemLogic) AbnormalArticleHidden(conn transaction.Conn, companyId, at int64, item string) (err error) { 69 func (l *MiniSystemLogic) AbnormalArticleHidden(conn transaction.Conn, companyId, at int64, item string) (err error) {
65 return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "帖子被隐藏", fmt.Sprintf("您的帖子[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item)) 70 return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "帖子被隐藏", fmt.Sprintf("您的帖子[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
66 } 71 }
67 72
68 -// AbnormalCommentUnapproved 评论未审核通过 73 +//// AbnormalArticleAuth 异常通知-文章权限变更
  74 +//func (l *MiniSystemLogic) AbnormalArticleAuth(conn transaction.Conn, companyId, at int64, item string) (err error) {
  75 +// return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "权限变更", fmt.Sprintf("您的帖子[%s]可见权限已被移除,如有疑问,请联系运营管理员了解详情。", item))
  76 +//}
  77 +
  78 +// AbnormalCommentUnapproved 异常通知-评论未审核通过
69 func (l *MiniSystemLogic) AbnormalCommentUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) { 79 func (l *MiniSystemLogic) AbnormalCommentUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) {
70 return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论未通过审核", fmt.Sprintf("您的评论[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item)) 80 return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论未通过审核", fmt.Sprintf("您的评论[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item))
71 } 81 }
72 82
73 -// AbnormalCommentHidden 评论被隐藏 83 +// AbnormalCommentHidden 异常通知-评论被隐藏
74 func (l *MiniSystemLogic) AbnormalCommentHidden(conn transaction.Conn, companyId, at int64, item string) (err error) { 84 func (l *MiniSystemLogic) AbnormalCommentHidden(conn transaction.Conn, companyId, at int64, item string) (err error) {
75 return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论被隐藏", fmt.Sprintf("您的评论[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item)) 85 return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论被隐藏", fmt.Sprintf("您的评论[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
76 } 86 }
@@ -174,7 +174,6 @@ type MiniUserInfoResponse struct { @@ -174,7 +174,6 @@ type MiniUserInfoResponse struct {
174 TotalLoved int64 `json:"totalLoved"` // 累计收到的赞 174 TotalLoved int64 `json:"totalLoved"` // 累计收到的赞
175 TotalAccepted int64 `json:"totalAccepted"` // 累计被采纳 175 TotalAccepted int64 `json:"totalAccepted"` // 累计被采纳
176 Accounts []Account `json:"accounts"` // 公司账号 176 Accounts []Account `json:"accounts"` // 公司账号
177 - Auths []Auth `json:"auths"` // 权限  
178 } 177 }
179 178
180 type MiniUserApplyJoinCompanyRequest struct { 179 type MiniUserApplyJoinCompanyRequest struct {
@@ -316,7 +315,7 @@ type MiniArticleCreateResponse struct { @@ -316,7 +315,7 @@ type MiniArticleCreateResponse struct {
316 315
317 type MiniArticleGetRequest struct { 316 type MiniArticleGetRequest struct {
318 Id int64 `path:"id"` //id 317 Id int64 `path:"id"` //id
319 - CompanyId int64 `path:"-"` 318 + CompanyId int64 `path:",optional"`
320 } 319 }
321 320
322 type MiniArticleGetResponse struct { 321 type MiniArticleGetResponse struct {
@@ -334,6 +333,7 @@ type MiniArticleGetResponse struct { @@ -334,6 +333,7 @@ type MiniArticleGetResponse struct {
334 CountComment int `json:"countComment"` // 评论数量 333 CountComment int `json:"countComment"` // 评论数量
335 CountRead int `json:"countRead"` // 浏览数量 334 CountRead int `json:"countRead"` // 浏览数量
336 Show int `json:"show"` // 评论的展示状态(0显示、1不显示) 335 Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
  336 + Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
337 } 337 }
338 338
339 type ArticleSection struct { 339 type ArticleSection struct {
@@ -344,8 +344,8 @@ type ArticleSection struct { @@ -344,8 +344,8 @@ type ArticleSection struct {
344 } 344 }
345 345
346 type MiniArticleSearchMeRequest struct { 346 type MiniArticleSearchMeRequest struct {
347 - AuthorId int64 `json:"-"`  
348 - CompanyId int64 `json:"-"` 347 + AuthorId int64 `json:",optional"`
  348 + CompanyId int64 `json:",optional"`
349 Page int `json:"page"` 349 Page int `json:"page"`
350 Size int `json:"size"` 350 Size int `json:"size"`
351 } 351 }
@@ -367,7 +367,7 @@ type ArticleSearchMe struct { @@ -367,7 +367,7 @@ type ArticleSearchMe struct {
367 367
368 type MiniUserLikeArticleRequest struct { 368 type MiniUserLikeArticleRequest struct {
369 ArticleId int64 `json:"articleId"` // 文章id 369 ArticleId int64 `json:"articleId"` // 文章id
370 - CompanyId int64 `json:"-"` //公司id 370 + CompanyId int64 `json:",optional"` //公司id
371 Page int `json:"page"` //分页,第几页 371 Page int `json:"page"` //分页,第几页
372 Size int `json:"size"` //分页,每页几条 372 Size int `json:"size"` //分页,每页几条
373 } 373 }
@@ -388,7 +388,7 @@ type WhichUserLikeArticle struct { @@ -388,7 +388,7 @@ type WhichUserLikeArticle struct {
388 type MiniSetUserLikeRequset struct { 388 type MiniSetUserLikeRequset struct {
389 ArticleId int64 `json:"articleId"` //文章id 389 ArticleId int64 `json:"articleId"` //文章id
390 CommentId int64 `json:"commentId"` //评论id 390 CommentId int64 `json:"commentId"` //评论id
391 - UserId int64 `json:"-"` //操作人 391 + UserId int64 `json:",optional"` //操作人
392 Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞 392 Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞
393 } 393 }
394 394
@@ -398,6 +398,59 @@ type MiniSetUserLikeResponse struct { @@ -398,6 +398,59 @@ type MiniSetUserLikeResponse struct {
398 Count int `json:"count"` //现有的点赞数量 398 Count int `json:"count"` //现有的点赞数量
399 } 399 }
400 400
  401 +type SystemArticleGetRequest struct {
  402 + Id int64 `path:"id"` //id
  403 + CompanyId int64 `path:",optional"`
  404 +}
  405 +
  406 +type UserShowName struct {
  407 + Id int `json:"id"`
  408 + Name int `json:"name"`
  409 +}
  410 +
  411 +type SystemArticleGetResponse struct {
  412 + Id int64 `json:"id"` // id
  413 + Title string `json:"title"` // 标题
  414 + AuthorId int64 `json:"authorId"` // 发布人id
  415 + Author Author `json:"author"` // 发布人
  416 + CreatedAt int64 `json:"createdAt"` // 文章的发布时间
  417 + Section []ArticleSection `json:"section"` // 文章的文本内容
  418 + Images []string `json:"images"` // 图片
  419 + WhoRead []int64 `json:"whoRead"` // 谁可查看
  420 + WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
  421 + WhoReview []int64 `json:"whoReview"` // 谁可评论
  422 + WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
  423 + Location Location `json:"location"` // 定位坐标
  424 + CountLove int `json:"countLove"` // 点赞数量
  425 + CountComment int `json:"countComment"` // 评论数量
  426 + CountRead int `json:"countRead"` // 浏览数量
  427 + Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
  428 +}
  429 +
  430 +type SystemArticleSearchRequest struct {
  431 + CompanyId int64 `json:",optional"`
  432 + Page int `json:"page"`
  433 + Size int `json:"size"`
  434 +}
  435 +
  436 +type SystemArticleSearchResponse struct {
  437 + Total int `json:"total"`
  438 + List []SystemArticleSearch `json:"list"`
  439 +}
  440 +
  441 +type SystemArticleSearch struct {
  442 + Id int64 `json:"id"` //id
  443 + Title string `json:"title"` //标题
  444 + Author string `json:"author"` //发布人
  445 + Images []string `json:"images"` //图片
  446 + CreatedAt int64 `json:"createdAt"` //文章的创建日期
  447 + CountLove int `json:"countLove"` //点赞数量
  448 + CountComment int `json:"CountComment"` //评论数量
  449 + Show int `json:"show"` //是否隐藏 [0显示、1不显示]
  450 + Tags []string `json:"tags"` //标签
  451 + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
  452 +}
  453 +
401 type RoleGetRequest struct { 454 type RoleGetRequest struct {
402 Id int64 `path:"id"` 455 Id int64 `path:"id"`
403 } 456 }
@@ -45,6 +45,7 @@ func (m *Article) BeforeCreate(tx *gorm.DB) (err error) { @@ -45,6 +45,7 @@ func (m *Article) BeforeCreate(tx *gorm.DB) (err error) {
45 45
46 func (m *Article) BeforeUpdate(tx *gorm.DB) (err error) { 46 func (m *Article) BeforeUpdate(tx *gorm.DB) (err error) {
47 m.UpdatedAt = time.Now().Unix() 47 m.UpdatedAt = time.Now().Unix()
  48 + m.Version += 1
48 return 49 return
49 } 50 }
50 51
@@ -45,6 +45,7 @@ func (m *ArticleComment) BeforeCreate(tx *gorm.DB) (err error) { @@ -45,6 +45,7 @@ func (m *ArticleComment) BeforeCreate(tx *gorm.DB) (err error) {
45 45
46 func (m *ArticleComment) BeforeUpdate(tx *gorm.DB) (err error) { 46 func (m *ArticleComment) BeforeUpdate(tx *gorm.DB) (err error) {
47 m.UpdatedAt = time.Now().Unix() 47 m.UpdatedAt = time.Now().Unix()
  48 + m.Version += 1
48 return 49 return
49 } 50 }
50 51
@@ -13,6 +13,8 @@ type UserLoveFlag struct { @@ -13,6 +13,8 @@ type UserLoveFlag struct {
13 Id int64 `gorm:"primaryKey"` // 唯一标识 13 Id int64 `gorm:"primaryKey"` // 唯一标识
14 ArticleId int64 // 点赞文章时,文章id 14 ArticleId int64 // 点赞文章时,文章id
15 CommentId int64 // 点赞评论时,填评论id 15 CommentId int64 // 点赞评论时,填评论id
  16 + ArticleAuthor int64 // 文章的发布人
  17 + CommentAuthor int64 // 评论的填写人
16 UserId int64 18 UserId int64
17 CreatedAt int64 19 CreatedAt int64
18 UpdatedAt int64 20 UpdatedAt int64
@@ -194,9 +194,25 @@ func (repository *ArticleCommentRepository) DomainModelToModel(from *domain.Arti @@ -194,9 +194,25 @@ func (repository *ArticleCommentRepository) DomainModelToModel(from *domain.Arti
194 return to, nil 194 return to, nil
195 } 195 }
196 196
197 -// TODO 点赞数量变动 197 +// 点赞数量变动
198 func (repository *ArticleCommentRepository) IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, dm *domain.ArticleComment) error { 198 func (repository *ArticleCommentRepository) IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, dm *domain.ArticleComment) error {
  199 + var (
  200 + err error
  201 + m *models.ArticleComment
  202 + tx = conn.DB()
  203 + )
  204 + if m, err = repository.DomainModelToModel(dm); err != nil {
  205 + return err
  206 + }
  207 + queryFunc := func() (interface{}, error) {
  208 + tx = tx.Model(m).Update("count_user_love", gorm.Expr("count_user_love+?", incr))
  209 + return nil, tx.Error
  210 + }
  211 + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  212 + return err
  213 + }
199 return nil 214 return nil
  215 +
200 } 216 }
201 217
202 func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository { 218 func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository {
@@ -168,6 +168,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* @@ -168,6 +168,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (*
168 CountComment: from.CountComment, 168 CountComment: from.CountComment,
169 CountRead: from.CountRead, 169 CountRead: from.CountRead,
170 Show: domain.ArticleShow(from.Show), 170 Show: domain.ArticleShow(from.Show),
  171 + Tags: from.Tags,
171 } 172 }
172 return to, nil 173 return to, nil
173 } 174 }
@@ -193,22 +194,27 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* @@ -193,22 +194,27 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (*
193 CountRead: from.CountRead, 194 CountRead: from.CountRead,
194 CountComment: from.CountComment, 195 CountComment: from.CountComment,
195 Show: int(from.Show), 196 Show: int(from.Show),
  197 + Tags: from.Tags,
196 } 198 }
197 // err := copier.Copy(to, from) 199 // err := copier.Copy(to, from)
198 return to, nil 200 return to, nil
199 } 201 }
200 202
201 // 点赞数量变动 203 // 点赞数量变动
202 -func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, article *domain.Article) error { 204 +func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
203 // 205 //
204 var ( 206 var (
205 err error 207 err error
206 m *models.Article 208 m *models.Article
207 tx = conn.DB() 209 tx = conn.DB()
208 ) 210 )
209 - m = &models.Article{Id: article.Id} 211 + if m, err = repository.DomainModelToModel(dm); err != nil {
  212 + return err
  213 + }
210 queryFunc := func() (interface{}, error) { 214 queryFunc := func() (interface{}, error) {
211 - tx = tx.Model(m).Update("count_love", gorm.Expr("count_love+?", incr)) 215 + tx = tx.Model(m).Updates(map[string]interface{}{
  216 + "count_love": gorm.Expr("count_love+?", incr),
  217 + })
212 return nil, tx.Error 218 return nil, tx.Error
213 } 219 }
214 if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { 220 if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
@@ -218,13 +224,15 @@ func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn @@ -218,13 +224,15 @@ func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn
218 } 224 }
219 225
220 // 浏览数量变动 226 // 浏览数量变动
221 -func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, article *domain.Article) error { 227 +func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
222 var ( 228 var (
223 err error 229 err error
224 m *models.Article 230 m *models.Article
225 tx = conn.DB() 231 tx = conn.DB()
226 ) 232 )
227 - m = &models.Article{Id: article.Id} 233 + if m, err = repository.DomainModelToModel(dm); err != nil {
  234 + return err
  235 + }
228 queryFunc := func() (interface{}, error) { 236 queryFunc := func() (interface{}, error) {
229 tx = tx.Model(m).Update("count_read", gorm.Expr("count_read+?", incr)) 237 tx = tx.Model(m).Update("count_read", gorm.Expr("count_read+?", incr))
230 return nil, tx.Error 238 return nil, tx.Error
@@ -236,13 +244,15 @@ func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn @@ -236,13 +244,15 @@ func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn
236 } 244 }
237 245
238 // 评论数量变动 246 // 评论数量变动
239 -func (repository *ArticleRepository) IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, article *domain.Article) error { 247 +func (repository *ArticleRepository) IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
240 var ( 248 var (
241 err error 249 err error
242 m *models.Article 250 m *models.Article
243 tx = conn.DB() 251 tx = conn.DB()
244 ) 252 )
245 - m = &models.Article{Id: article.Id} 253 + if m, err = repository.DomainModelToModel(dm); err != nil {
  254 + return err
  255 + }
246 queryFunc := func() (interface{}, error) { 256 queryFunc := func() (interface{}, error) {
247 tx = tx.Model(m).Update("count_comment", gorm.Expr("count_comment+?", incr)) 257 tx = tx.Model(m).Update("count_comment", gorm.Expr("count_comment+?", incr))
248 return nil, tx.Error 258 return nil, tx.Error
@@ -153,6 +153,8 @@ func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLo @@ -153,6 +153,8 @@ func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLo
153 to := &domain.UserLoveFlag{ 153 to := &domain.UserLoveFlag{
154 Id: from.Id, 154 Id: from.Id,
155 ArticleId: from.ArticleId, 155 ArticleId: from.ArticleId,
  156 + ArticleAuthor: from.ArticleAuthor,
  157 + CommentAuthor: from.CommentAuthor,
156 CommentId: from.CommentId, 158 CommentId: from.CommentId,
157 UserId: from.UserId, 159 UserId: from.UserId,
158 CreatedAt: from.CreatedAt, 160 CreatedAt: from.CreatedAt,
@@ -169,11 +171,14 @@ func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLo @@ -169,11 +171,14 @@ func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLo
169 Id: from.Id, 171 Id: from.Id,
170 ArticleId: from.ArticleId, 172 ArticleId: from.ArticleId,
171 CommentId: from.CommentId, 173 CommentId: from.CommentId,
  174 + ArticleAuthor: from.ArticleAuthor,
  175 + CommentAuthor: from.CommentAuthor,
172 UserId: from.UserId, 176 UserId: from.UserId,
173 CreatedAt: from.CreatedAt, 177 CreatedAt: from.CreatedAt,
174 UpdatedAt: from.UpdatedAt, 178 UpdatedAt: from.UpdatedAt,
175 DeletedAt: from.DeletedAt, 179 DeletedAt: from.DeletedAt,
176 Version: from.Version, 180 Version: from.Version,
  181 + IsDel: 0,
177 } 182 }
178 // err := copier.Copy(to, from) 183 // err := copier.Copy(to, from)
179 return to, nil 184 return to, nil
@@ -81,7 +81,7 @@ func (a ArticleShow) Named() string { @@ -81,7 +81,7 @@ func (a ArticleShow) Named() string {
81 func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *ArticleBackup { 81 func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *ArticleBackup {
82 b := ArticleBackup{ 82 b := ArticleBackup{
83 Id: 0, 83 Id: 0,
84 - CompanyId: 0, 84 + CompanyId: m.CompanyId,
85 CreatedAt: 0, 85 CreatedAt: 0,
86 UpdatedAt: 0, 86 UpdatedAt: 0,
87 DeletedAt: 0, 87 DeletedAt: 0,
@@ -11,7 +11,9 @@ import ( @@ -11,7 +11,9 @@ import (
11 type UserLoveFlag struct { 11 type UserLoveFlag struct {
12 Id int64 `json:"id"` 12 Id int64 `json:"id"`
13 ArticleId int64 `json:"articleId"` // 点赞文章时,文章id 13 ArticleId int64 `json:"articleId"` // 点赞文章时,文章id
  14 + ArticleAuthor int64 `json:"articleAuthor"` // 文章的发布人
14 CommentId int64 `json:"commentId"` // 点赞评论时,填评论id 15 CommentId int64 `json:"commentId"` // 点赞评论时,填评论id
  16 + CommentAuthor int64 `json:"commentAuthor"` // 评论的填写人
15 UserId int64 `json:"userId"` 17 UserId int64 `json:"userId"`
16 CreatedAt int64 `json:"createdAt,omitempty"` 18 CreatedAt int64 `json:"createdAt,omitempty"`
17 UpdatedAt int64 `json:"updatedAt,omitempty"` 19 UpdatedAt int64 `json:"updatedAt,omitempty"`