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