作者 郑周

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

正在显示 51 个修改的文件 包含 551 行增加223 行删除
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 +}
@@ -5024,55 +5024,94 @@ @@ -5024,55 +5024,94 @@
5024 "show" 5024 "show"
5025 ] 5025 ]
5026 }, 5026 },
5027 - "SystemArticleHistoryRequest": { 5027 + "SystemArticleHistory": {
5028 "type": "object", 5028 "type": "object",
5029 "properties": { 5029 "properties": {
5030 - "articleId": { 5030 + "id": {
5031 "type": "integer", 5031 "type": "integer",
5032 "format": "int64", 5032 "format": "int64",
5033 - "description": "文章ID" 5033 + "description": "id"
5034 }, 5034 },
5035 "author": { 5035 "author": {
5036 "type": "string", 5036 "type": "string",
5037 - "description": "发布人" 5037 + "description": "编辑人"
5038 }, 5038 },
5039 - "updatedAt": { 5039 + "action": {
5040 "type": "string", 5040 "type": "string",
5041 - "description": "修改日期" 5041 + "description": "编辑类型"
  5042 + },
  5043 + "updatedAt": {
  5044 + "type": "integer",
  5045 + "format": "int64",
  5046 + "description": "编辑时间"
5042 } 5047 }
5043 }, 5048 },
5044 - "title": "SystemArticleHistoryRequest", 5049 + "title": "SystemArticleHistory",
5045 "required": [ 5050 "required": [
5046 - "articleId" 5051 + "id",
  5052 + "author",
  5053 + "action",
  5054 + "updatedAt"
5047 ] 5055 ]
5048 }, 5056 },
5049 - "SystemArticleHistoryResponse": { 5057 + "SystemArticleHistoryRequest": {
5050 "type": "object", 5058 "type": "object",
5051 "properties": { 5059 "properties": {
5052 - "id": { 5060 + "articleId": {
5053 "type": "integer", 5061 "type": "integer",
5054 "format": "int64", 5062 "format": "int64",
5055 - "description": "id" 5063 + "description": "文章ID"
5056 }, 5064 },
5057 "author": { 5065 "author": {
5058 "type": "string", 5066 "type": "string",
5059 - "description": "编辑人" 5067 + "description": "发布人"
5060 }, 5068 },
5061 - "action": {  
5062 - "type": "string",  
5063 - "description": "编辑类型" 5069 + "beginTime": {
  5070 + "type": "integer",
  5071 + "format": "int64",
  5072 + "description": "开始时间"
5064 }, 5073 },
5065 - "updatedAt": {  
5066 - "type": "string",  
5067 - "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 + }
5068 } 5109 }
5069 }, 5110 },
5070 "title": "SystemArticleHistoryResponse", 5111 "title": "SystemArticleHistoryResponse",
5071 "required": [ 5112 "required": [
5072 - "id",  
5073 - "author",  
5074 - "action",  
5075 - "updatedAt" 5113 + "total",
  5114 + "list"
5076 ] 5115 ]
5077 }, 5116 },
5078 "SystemArticleSearch": { 5117 "SystemArticleSearch": {
@@ -5214,16 +5253,22 @@ @@ -5214,16 +5253,22 @@
5214 "type": "string", 5253 "type": "string",
5215 "description": "发布人" 5254 "description": "发布人"
5216 }, 5255 },
5217 - "publishDate": {  
5218 - "type": "string",  
5219 - "description": "发布日期" 5256 + "beginTime": {
  5257 + "type": "integer",
  5258 + "format": "int64",
  5259 + "description": "开始时间"
5220 }, 5260 },
5221 - "pageNumber": { 5261 + "endTime": {
  5262 + "type": "integer",
  5263 + "format": "int64",
  5264 + "description": "结束时间"
  5265 + },
  5266 + "page": {
5222 "type": "integer", 5267 "type": "integer",
5223 "format": "int32", 5268 "format": "int32",
5224 "description": "页码" 5269 "description": "页码"
5225 }, 5270 },
5226 - "pageSize": { 5271 + "size": {
5227 "type": "integer", 5272 "type": "integer",
5228 "format": "int32", 5273 "format": "int32",
5229 "description": "每页行数" 5274 "description": "每页行数"
@@ -5231,8 +5276,8 @@ @@ -5231,8 +5276,8 @@
5231 }, 5276 },
5232 "title": "SystemArticleSearchRequest", 5277 "title": "SystemArticleSearchRequest",
5233 "required": [ 5278 "required": [
5234 - "pageNumber",  
5235 - "pageSize" 5279 + "page",
  5280 + "size"
5236 ] 5281 ]
5237 }, 5282 },
5238 "SystemArticleSearchResponse": { 5283 "SystemArticleSearchResponse": {
@@ -72,6 +72,12 @@ service Core { @@ -72,6 +72,12 @@ service Core {
72 @doc "小程序所有的定性标签" 72 @doc "小程序所有的定性标签"
73 @handler MiniAllArticleTag 73 @handler MiniAllArticleTag
74 get /article_tag/list/all (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse) 74 get /article_tag/list/all (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse)
  75 +
  76 + @doc "小程序首页数据展示"
  77 + @handler MinishowHomePage
  78 + get /show/home_page (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse)
  79 +
  80 +
75 } 81 }
76 82
77 // 管理后台接口 83 // 管理后台接口
@@ -97,6 +103,10 @@ service Core { @@ -97,6 +103,10 @@ service Core {
97 @handler SystemHistoryArticle 103 @handler SystemHistoryArticle
98 post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse) 104 post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse)
99 105
  106 + @doc "管理后台帖子历史详情"
  107 + @handler SystemArticleGetHistory
  108 + get /article/history/:id (SystemArticleGetHistoryRequest) returns (SystemArticleGetHistoryResponse)
  109 +
100 @doc "管理后台获取我发布的文章" 110 @doc "管理后台获取我发布的文章"
101 @handler SystemArticleSearchMe 111 @handler SystemArticleSearchMe
102 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,19 +410,54 @@ type ( @@ -409,19 +410,54 @@ 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"`
426 } 438 }
427 -)  
  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分发给指定的人]
  458 + }
  459 +)
  460 +
  461 +//小程序端 首页数据展示
  462 +// 统计各标签下的文章数量,和已被人员阅读的数量
  463 +type
@@ -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 }
@@ -15,7 +15,7 @@ func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniAllArticleTagRequest 16 var req types.MiniAllArticleTagRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniArticleBackupSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -15,7 +15,7 @@ func MiniArticleBackupSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleBackupSearchRequest 16 var req types.MiniArticleBackupSearchRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 token := contextdata.GetUserTokenFromCtx(r.Context()) 21 token := contextdata.GetUserTokenFromCtx(r.Context())
1 package article 1 package article
2 2
3 import ( 3 import (
4 - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"  
5 "net/http" 4 "net/http"
6 5
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  7 +
7 "github.com/zeromicro/go-zero/rest/httpx" 8 "github.com/zeromicro/go-zero/rest/httpx"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
@@ -14,7 +15,7 @@ func MiniArticleMarkListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -14,7 +15,7 @@ func MiniArticleMarkListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
14 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
15 var req types.MiniArticleMarkListRequest 16 var req types.MiniArticleMarkListRequest
16 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
17 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
18 return 19 return
19 } 20 }
20 21
@@ -16,7 +16,7 @@ func MiniArticleMarkUserReadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -16,7 +16,7 @@ func MiniArticleMarkUserReadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
16 return func(w http.ResponseWriter, r *http.Request) { 16 return func(w http.ResponseWriter, r *http.Request) {
17 var req types.MiniArticleMarkUserReadRequest 17 var req types.MiniArticleMarkUserReadRequest
18 if err := httpx.Parse(r, &req); err != nil { 18 if err := httpx.Parse(r, &req); err != nil {
19 - httpx.ErrorCtx(r.Context(), w, err) 19 + result.HttpResult(r, w, nil, err)
20 return 20 return
21 } 21 }
22 22
@@ -15,7 +15,7 @@ func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleSearchMeRequest 16 var req types.MiniArticleSearchMeRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniArticleSetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func MiniArticleSetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleSetTagRequest 16 var req types.MiniArticleSetTagRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -15,7 +15,7 @@ func MiniCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleDraftCreateRequest 16 var req types.MiniArticleDraftCreateRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleCreateRequest 16 var req types.MiniArticleCreateRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 token := contextdata.GetUserTokenFromCtx(r.Context()) 21 token := contextdata.GetUserTokenFromCtx(r.Context())
@@ -15,7 +15,7 @@ func MiniDeleteArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFun @@ -15,7 +15,7 @@ func MiniDeleteArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFun
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleDraftDeleteMeRequest 16 var req types.MiniArticleDraftDeleteMeRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -7,22 +7,23 @@ import ( @@ -7,22 +7,23 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
10 ) 12 )
11 13
12 func MiniGetArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 func MiniGetArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
13 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
14 var req types.MiniArticleDraftGetMeRequest 16 var req types.MiniArticleDraftGetMeRequest
15 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
16 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
17 return 19 return
18 } 20 }
19 21
20 l := article.NewMiniGetArticleDraftMeLogic(r.Context(), svcCtx) 22 l := article.NewMiniGetArticleDraftMeLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.AuthorId = token.UserId
  25 + req.CompanyId = token.CompanyId
21 resp, err := l.MiniGetArticleDraftMe(&req) 26 resp, err := l.MiniGetArticleDraftMe(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.OkJsonCtx(r.Context(), w, resp)  
26 - } 27 + result.HttpResult(r, w, resp, err)
27 } 28 }
28 } 29 }
@@ -15,7 +15,7 @@ func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleGetRequest 16 var req types.MiniArticleGetRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniSearchArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFun @@ -15,7 +15,7 @@ func MiniSearchArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFun
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleDraftSearchMeRequest 16 var req types.MiniArticleDraftSearchMeRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniSetUserLikeRequset 16 var req types.MiniSetUserLikeRequset
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniUpdateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -15,7 +15,7 @@ func MiniUpdateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleDraftUpdateRequest 16 var req types.MiniArticleDraftUpdateRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 l := article.NewMiniUpdateArticleDraftLogic(r.Context(), svcCtx) 21 l := article.NewMiniUpdateArticleDraftLogic(r.Context(), svcCtx)
@@ -15,7 +15,7 @@ func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniUserLikeArticleRequest 16 var req types.MiniUserLikeArticleRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
  1 +package article
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  5 + "net/http"
  6 +
  7 + "github.com/zeromicro/go-zero/rest/httpx"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  11 +)
  12 +
  13 +func 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 }
@@ -15,7 +15,7 @@ func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -15,7 +15,7 @@ func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniArticleCommentAtWhoRequest 16 var req types.MiniArticleCommentAtWhoRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniCreateArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFun @@ -15,7 +15,7 @@ func MiniCreateArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFun
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniCreateArticleCommentRequest 16 var req types.MiniCreateArticleCommentRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 l := comment.NewMiniCreateArticleCommentLogic(r.Context(), svcCtx) 21 l := comment.NewMiniCreateArticleCommentLogic(r.Context(), svcCtx)
@@ -15,7 +15,7 @@ func MiniDeleteArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFun @@ -15,7 +15,7 @@ func MiniDeleteArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFun
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniDeleteArticleCommentRequest 16 var req types.MiniDeleteArticleCommentRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniGetArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func MiniGetArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniGetArticleCommentRequest 16 var req types.MiniGetArticleCommentRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func MiniListArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -15,7 +15,7 @@ func MiniListArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniListArticleCommentRequest 16 var req types.MiniListArticleCommentRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 l := comment.NewMiniListArticleCommentLogic(r.Context(), svcCtx) 21 l := comment.NewMiniListArticleCommentLogic(r.Context(), svcCtx)
@@ -15,7 +15,7 @@ func MiniTop5ArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -15,7 +15,7 @@ func MiniTop5ArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.MiniTop5ArticleCommentRequest 16 var req types.MiniTop5ArticleCommentRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -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),
@@ -15,7 +15,7 @@ func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.TagCreateRequest 16 var req types.TagCreateRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.TagDeleteRequest 16 var req types.TagDeleteRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.TagEditRequest 16 var req types.TagEditRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
@@ -15,7 +15,7 @@ func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.TagGetRequest 16 var req types.TagGetRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 token := contextdata.GetUserTokenFromCtx(r.Context()) 21 token := contextdata.GetUserTokenFromCtx(r.Context())
@@ -15,7 +15,7 @@ func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -15,7 +15,7 @@ func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.TagListRequest 16 var req types.TagListRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
  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 }
@@ -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 {
@@ -53,3 +53,10 @@ func (m *ArticleAndTag) CachePrimaryKeyFunc() string { @@ -53,3 +53,10 @@ func (m *ArticleAndTag) CachePrimaryKeyFunc() string {
53 } 53 }
54 return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") 54 return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
55 } 55 }
  56 +
  57 +// 统计所有已有标签的文章和人员已读的文章
  58 +type CountArticleTagRead struct {
  59 + TotalArticle int `gorm:"total_article"` //标签下文章的数量
  60 + ReadArticle int `gorm:"read_article"` //人员已读的文章
  61 + TagId int64 `gorm:"tag_id"` // 标签的id
  62 +}
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "fmt"
5 6
6 "github.com/jinzhu/copier" 7 "github.com/jinzhu/copier"
7 "github.com/pkg/errors" 8 "github.com/pkg/errors"
@@ -132,6 +133,59 @@ func (repository *ArticleAndTagRepository) DomainModelToModel(from *domain.Artic @@ -132,6 +133,59 @@ func (repository *ArticleAndTagRepository) DomainModelToModel(from *domain.Artic
132 return to, err 133 return to, err
133 } 134 }
134 135
  136 +// 以TagId作为分组,统计所有已有标签的文章和人员已读的文章
  137 +func (repository *ArticleAndTagRepository) CountArticleReadGroupByTag(ctx context.Context, conn transaction.Conn, userId int64, companyId int64) ([]*domain.CountArticleTagRead, error) {
  138 +
  139 + sqlStr := `
  140 +-- 首页统计数据
  141 +with
  142 +-- 按查看权限查询文章
  143 +-- 获取有标签的文章
  144 +-- 过滤出可展示的文章id
  145 +t_article_and_tag_2 as (
  146 + select article_and_tag.article_id , article_and_tag.tag_id
  147 + from article_and_tag
  148 + join article on article_and_tag.article_id = article.id
  149 + where article.deleted_at=0
  150 + and article.company_id =1598224576532189184
  151 + and article."show" =0
  152 + and (article.target_user =0 or article.who_read @>'[1]')
  153 +),
  154 +-- 查询人员已查看的文章
  155 +t_user_read as(
  156 + select user_read_article.article_id from user_read_article where user_read_article.user_id =1
  157 +)
  158 +-- 汇总统计 total_article 符合条件的文章总数,read_article 已浏览的数量
  159 +select count(t_article_and_tag_2.article_id) as total_article ,count(t_user_read.article_id) as read_article, t_article_and_tag_2.tag_id
  160 +from t_article_and_tag_2
  161 +left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id
  162 +group by t_article_and_tag_2.tag_id
  163 +`
  164 + condition := []interface{}{
  165 + companyId,
  166 + fmt.Sprintf("[%d]", userId),
  167 + userId,
  168 + }
  169 +
  170 + m := []*models.CountArticleTagRead{}
  171 + db := conn.DB()
  172 + result := db.Raw(sqlStr, condition...).Scan(&m)
  173 + if result.Error != nil {
  174 + return nil, result.Error
  175 + }
  176 +
  177 + var dm []*domain.CountArticleTagRead
  178 +
  179 + for _, val := range m {
  180 + dm = append(dm, &domain.CountArticleTagRead{
  181 + TagId: val.TagId,
  182 + TotalArticle: val.TotalArticle,
  183 + ReadArticle: val.ReadArticle,
  184 + })
  185 + }
  186 + return dm, nil
  187 +}
  188 +
135 func NewArticleAndTagRepository(cache *cache.CachedRepository) domain.ArticleAndTagRepository { 189 func NewArticleAndTagRepository(cache *cache.CachedRepository) domain.ArticleAndTagRepository {
136 return &ArticleAndTagRepository{CachedRepository: cache} 190 return &ArticleAndTagRepository{CachedRepository: cache}
137 } 191 }
@@ -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 {
@@ -278,34 +278,27 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor @@ -278,34 +278,27 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor
278 return &ArticleRepository{CachedRepository: cache} 278 return &ArticleRepository{CachedRepository: cache}
279 } 279 }
280 280
  281 +// -- 首页统计数据
281 // with 282 // with
282 // -- 按查看权限查询文章 283 // -- 按查看权限查询文章
283 -// t_article as(  
284 -// select article.id  
285 -// from article 284 +// -- 获取有标签的文章
  285 +// -- 过滤出可展示的文章id
  286 +// t_article_and_tag_2 as (
  287 +// select article_and_tag.article_id , article_and_tag.tag_id
  288 +// from article_and_tag
  289 +// join article on article_and_tag.article_id = article.id
286 // where article.deleted_at=0 290 // where article.deleted_at=0
287 // and article.company_id =1598224576532189184 291 // and article.company_id =1598224576532189184
288 // and article."show" =0 292 // and article."show" =0
289 // and (article.target_user =0 or article.who_read @>'[1]') 293 // and (article.target_user =0 or article.who_read @>'[1]')
290 // ), 294 // ),
291 -// -- 获取有标签的文章  
292 -// t_article_and_tag as (  
293 -// select article_and_tag.article_id ,article_and_tag.tag_id  
294 -// from article_and_tag  
295 -// where article_and_tag.company_id =1598224576532189184  
296 -// ),  
297 -// -- 过滤出可展示的文章id  
298 -// t_article_and_tag_2 as (  
299 -// select t_article_and_tag.article_id, t_article_and_tag.tag_id  
300 -// from t_article_and_tag  
301 -// join t_article on t_article_and_tag.article_id = t_article.id  
302 -// ),  
303 // -- 查询人员已查看的文章 295 // -- 查询人员已查看的文章
304 // t_user_read as( 296 // t_user_read as(
305 -// select user_read_article.article_id from user_read_article where user_read_article.user_id =1 297 +// select user_read_article.article_id from user_read_article where user_read_article.user_id =1
306 // ) 298 // )
307 // -- 汇总统计 cnt_1符合条件的文章总数,cnt_2 已浏览的数量 299 // -- 汇总统计 cnt_1符合条件的文章总数,cnt_2 已浏览的数量
308 // select count(t_article_and_tag_2.article_id) as cnt_1 ,count(t_user_read.article_id) as cnt_2, t_article_and_tag_2.tag_id 300 // select count(t_article_and_tag_2.article_id) as cnt_1 ,count(t_user_read.article_id) as cnt_2, t_article_and_tag_2.tag_id
309 // from t_article_and_tag_2 301 // from t_article_and_tag_2
310 // left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id 302 // left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id
311 // group by t_article_and_tag_2.tag_id 303 // group by t_article_and_tag_2.tag_id
  304 +// ;
@@ -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,
@@ -16,10 +16,18 @@ type ArticleAndTag struct { @@ -16,10 +16,18 @@ type ArticleAndTag struct {
16 TagId int64 `json:"tagId"` 16 TagId int64 `json:"tagId"`
17 } 17 }
18 18
  19 +// 以TagId作为分组,统计所有已有标签的文章和人员已读的文章
  20 +type CountArticleTagRead struct {
  21 + TotalArticle int `gorm:"total_article"` //标签下文章的数量
  22 + ReadArticle int `gorm:"read_article"` //人员已读的文章
  23 + TagId int64 `gorm:"tag_id"` // 标签的id
  24 +}
  25 +
19 type ArticleAndTagRepository interface { 26 type ArticleAndTagRepository interface {
20 Insert(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) 27 Insert(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error)
21 Update(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) 28 Update(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error)
22 Delete(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error) 29 Delete(ctx context.Context, conn transaction.Conn, dm *ArticleAndTag) (*ArticleAndTag, error)
23 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleAndTag, error) 30 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleAndTag, error)
24 Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleAndTag, error) 31 Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleAndTag, error)
  32 + CountArticleReadGroupByTag(ctx context.Context, con transaction.Conn, userId int64, companyId int64) ([]*CountArticleTagRead, error)
25 } 33 }