Merge remote-tracking branch 'origin/dev' into dev
正在显示
22 个修改的文件
包含
234 行增加
和
76 行删除
@@ -7,6 +7,15 @@ type Location { | @@ -7,6 +7,15 @@ type Location { | ||
7 | Descript string `json:"descript,optional"` //地点描述 | 7 | Descript string `json:"descript,optional"` //地点描述 |
8 | } | 8 | } |
9 | 9 | ||
10 | + | ||
11 | +type Video { | ||
12 | + Url string `json:"url"` //视频文件的地址 | ||
13 | + Cover string `json:"cover"` //封面 | ||
14 | + Width int `json:"width"` //封面图片宽 | ||
15 | + Height int `json:"height"` //封面图片长 | ||
16 | +} | ||
17 | + | ||
18 | + | ||
10 | // 人员的简单展示信息 | 19 | // 人员的简单展示信息 |
11 | type ArticleAuthor { | 20 | type ArticleAuthor { |
12 | Id int64 `json:"id"` // 人员id | 21 | Id int64 `json:"id"` // 人员id |
@@ -48,6 +57,7 @@ type ( | @@ -48,6 +57,7 @@ type ( | ||
48 | CreatedAt int64 `json:"createdAt"` //文章的发布时间 | 57 | CreatedAt int64 `json:"createdAt"` //文章的发布时间 |
49 | Section []ArticleSection `json:"section"` //文章的文本内容 | 58 | Section []ArticleSection `json:"section"` //文章的文本内容 |
50 | Images []string `json:"images"` //图片 | 59 | Images []string `json:"images"` //图片 |
60 | + Videos []Video `json:"videos"` //视频 | ||
51 | WhoRead []int64 `json:"whoRead"` //谁可查看 | 61 | WhoRead []int64 `json:"whoRead"` //谁可查看 |
52 | WhoReview []int64 `json:"whoReview"` //谁可评论 | 62 | WhoReview []int64 `json:"whoReview"` //谁可评论 |
53 | Location Location `json:"location"` //定位坐标 | 63 | Location Location `json:"location"` //定位坐标 |
@@ -355,6 +365,7 @@ type ( | @@ -355,6 +365,7 @@ type ( | ||
355 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | 365 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 |
356 | Section []ArticleSection `json:"section"` // 文章的文本内容 | 366 | Section []ArticleSection `json:"section"` // 文章的文本内容 |
357 | Images []string `json:"images"` // 图片 | 367 | Images []string `json:"images"` // 图片 |
368 | + Videos []Video `json:"videos"` // 视频 | ||
358 | WhoRead []int64 `json:"whoRead"` // 谁可查看 | 369 | WhoRead []int64 `json:"whoRead"` // 谁可查看 |
359 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | 370 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 |
360 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 371 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
@@ -389,12 +400,12 @@ type ( | @@ -389,12 +400,12 @@ type ( | ||
389 | SystemArticleSearch { | 400 | SystemArticleSearch { |
390 | Id int64 `json:"id"` //id | 401 | Id int64 `json:"id"` //id |
391 | Title string `json:"title"` //标题 | 402 | Title string `json:"title"` //标题 |
392 | - AuthorId int64 `json:"author"` //发布人ID | 403 | + AuthorId int64 `json:"authorId"` //发布人ID |
393 | Author string `json:"author"` //发布人 | 404 | Author string `json:"author"` //发布人 |
394 | Images []string `json:"images"` //图片 | 405 | Images []string `json:"images"` //图片 |
395 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 406 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
396 | CountLove int `json:"countLove"` //点赞数量 | 407 | CountLove int `json:"countLove"` //点赞数量 |
397 | - CountComment int `json:"CountComment"` //评论数量 | 408 | + CountComment int `json:"countComment"` //评论数量 |
398 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 409 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
399 | Tags []string `json:"tags"` //标签 | 410 | Tags []string `json:"tags"` //标签 |
400 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 411 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
@@ -410,6 +421,7 @@ type ( | @@ -410,6 +421,7 @@ type ( | ||
410 | Section []ArticleSection `json:"section"` // 填写的内容 | 421 | Section []ArticleSection `json:"section"` // 填写的内容 |
411 | Title string `json:"title"` // 标题 | 422 | Title string `json:"title"` // 标题 |
412 | Images []string `json:"images"` // 图片 | 423 | Images []string `json:"images"` // 图片 |
424 | + Videos []Video `json:"video"` // 视频 | ||
413 | WhoRead []int64 `json:"whoRead"` // 谁可以看 | 425 | WhoRead []int64 `json:"whoRead"` // 谁可以看 |
414 | WhoReview []int64 `json:"whoReview"` // 评论人 | 426 | WhoReview []int64 `json:"whoReview"` // 评论人 |
415 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | 427 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
@@ -423,6 +435,7 @@ type ( | @@ -423,6 +435,7 @@ type ( | ||
423 | Images []string `json:"images"` //图片 | 435 | Images []string `json:"images"` //图片 |
424 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 436 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
425 | CountLove int `json:"countLove"` //点赞数量 | 437 | CountLove int `json:"countLove"` //点赞数量 |
438 | + Videos []Video `json:"video"` // 视频 | ||
426 | CountComment int `json:"countComment"` //评论数量 | 439 | CountComment int `json:"countComment"` //评论数量 |
427 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 440 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
428 | Tags []int64 `json:"tags"` //标签 | 441 | Tags []int64 `json:"tags"` //标签 |
@@ -464,6 +477,7 @@ type ( | @@ -464,6 +477,7 @@ type ( | ||
464 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | 477 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 |
465 | Section []ArticleSection `json:"section"` // 文章的文本内容 | 478 | Section []ArticleSection `json:"section"` // 文章的文本内容 |
466 | Images []string `json:"images"` // 图片 | 479 | Images []string `json:"images"` // 图片 |
480 | + Videos []Video `json:"video"` | ||
467 | WhoRead []int64 `json:"whoRead"` // 谁可查看 | 481 | WhoRead []int64 `json:"whoRead"` // 谁可查看 |
468 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | 482 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 |
469 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 483 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
@@ -530,6 +544,7 @@ type ( | @@ -530,6 +544,7 @@ type ( | ||
530 | MiniSearchArticleItem{ | 544 | MiniSearchArticleItem{ |
531 | ArticleId int64 `json:"articleId"` | 545 | ArticleId int64 `json:"articleId"` |
532 | Title string `json:"title"` | 546 | Title string `json:"title"` |
547 | + AuthorId int64 `json:"authorId"` | ||
533 | Author string `json:"author"` // 发布人 | 548 | Author string `json:"author"` // 发布人 |
534 | Avatar string `json:"avatar"`// 发布人的头像 | 549 | Avatar string `json:"avatar"`// 发布人的头像 |
535 | Images []string `json:"images"` | 550 | Images []string `json:"images"` |
@@ -254,14 +254,14 @@ type ( | @@ -254,14 +254,14 @@ type ( | ||
254 | // 文章里的评论列表 | 254 | // 文章里的评论列表 |
255 | type ( | 255 | type ( |
256 | SystemArticleCommentSearchRequest { | 256 | SystemArticleCommentSearchRequest { |
257 | - Page int `json:"page"` | ||
258 | - Size int `json:"size"` | ||
259 | - ArticleId int64 `json:"articleId"` // 文章ID | ||
260 | - TopId int64 `json:"topId,optional"` // 文章顶层ID | ||
261 | - Author int64 `json:"author,optional"` // 用户 | ||
262 | - Show int `json:"show,optional"` // 显示状态 | ||
263 | - BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
264 | - EndTime int64 `json:"endTime,optional"` // 结束时间 | 257 | + Page int `json:"page"` |
258 | + Size int `json:"size"` | ||
259 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
260 | + TopId int64 `json:"topId,optional"` // 文章顶层ID | ||
261 | + Author int64 `json:"author,optional"` // 用户 | ||
262 | + Show int `json:"show,optional"` // 显示状态 | ||
263 | + BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
264 | + EndTime int64 `json:"endTime,optional"` // 结束时间 | ||
265 | } | 265 | } |
266 | SystemArticleCommentSearchResponse { | 266 | SystemArticleCommentSearchResponse { |
267 | Total int64 `json:"total"` | 267 | Total int64 `json:"total"` |
@@ -362,10 +362,11 @@ type ( | @@ -362,10 +362,11 @@ type ( | ||
362 | // 管理后台变更评论 | 362 | // 管理后台变更评论 |
363 | type ( | 363 | type ( |
364 | SystemEditCommentRequest { | 364 | SystemEditCommentRequest { |
365 | - CompanyId int64 `json:",optional"` | ||
366 | - Id int64 `json:"id"` | ||
367 | - Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] | ||
368 | - CountAdminLove int `json:"countAdminLove,optional"` | 365 | + CompanyId int64 `json:",optional"` |
366 | + Id int64 `json:"id"` | ||
367 | + Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] | ||
368 | + Content string `json:"content,optional"` | ||
369 | + CountAdminLove int `json:"countAdminLove,optional"` | ||
369 | } | 370 | } |
370 | 371 | ||
371 | SystemEditCommentResponse { | 372 | SystemEditCommentResponse { |
@@ -3,8 +3,10 @@ package article | @@ -3,8 +3,10 @@ package article | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | 5 | ||
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/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
8 | 10 | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 11 | "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" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
@@ -14,15 +16,17 @@ import ( | @@ -14,15 +16,17 @@ import ( | ||
14 | 16 | ||
15 | type MiniArticleMarkListLogic struct { | 17 | type MiniArticleMarkListLogic struct { |
16 | logx.Logger | 18 | logx.Logger |
17 | - ctx context.Context | ||
18 | - svcCtx *svc.ServiceContext | 19 | + ctx context.Context |
20 | + svcCtx *svc.ServiceContext | ||
21 | + userCache map[int64]*domain.User | ||
19 | } | 22 | } |
20 | 23 | ||
21 | func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleMarkListLogic { | 24 | func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleMarkListLogic { |
22 | return &MiniArticleMarkListLogic{ | 25 | return &MiniArticleMarkListLogic{ |
23 | - Logger: logx.WithContext(ctx), | ||
24 | - ctx: ctx, | ||
25 | - svcCtx: svcCtx, | 26 | + Logger: logx.WithContext(ctx), |
27 | + ctx: ctx, | ||
28 | + svcCtx: svcCtx, | ||
29 | + userCache: make(map[int64]*domain.User, 0), | ||
26 | } | 30 | } |
27 | } | 31 | } |
28 | 32 | ||
@@ -36,10 +40,16 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar | @@ -36,10 +40,16 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar | ||
36 | if err != nil { | 40 | if err != nil { |
37 | return nil, err | 41 | return nil, err |
38 | } | 42 | } |
43 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.svcCtx.DefaultDBConn(), userToken.CompanyId) | ||
44 | + if err != nil { | ||
45 | + return nil, xerr.NewErrMsgErr("获取文章信息失败", err) | ||
46 | + } | ||
39 | resp = &types.MiniArticleMarkListResponse{} | 47 | resp = &types.MiniArticleMarkListResponse{} |
40 | resp.Total = total | 48 | resp.Total = total |
41 | resp.List = make([]types.MiniArticleMarkItem, 0) | 49 | resp.List = make([]types.MiniArticleMarkItem, 0) |
50 | + var author domain.User | ||
42 | for _, item := range list { | 51 | for _, item := range list { |
52 | + author = l.getAuthor(l.svcCtx.DefaultDBConn(), item.Author.Id) | ||
43 | to := types.MiniArticleMarkItem{ | 53 | to := types.MiniArticleMarkItem{ |
44 | Id: item.Id, | 54 | Id: item.Id, |
45 | CompanyId: item.CompanyId, | 55 | CompanyId: item.CompanyId, |
@@ -48,10 +58,10 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar | @@ -48,10 +58,10 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar | ||
48 | Author: types.SimpleUser{ | 58 | Author: types.SimpleUser{ |
49 | Id: item.Author.Id, | 59 | Id: item.Author.Id, |
50 | CompanyId: item.Author.CompanyId, | 60 | CompanyId: item.Author.CompanyId, |
51 | - CompanyName: item.Author.Company, | ||
52 | - Name: item.Author.Name, | ||
53 | - Avatar: item.Author.Avatar, | ||
54 | - Position: item.Author.Position, | 61 | + CompanyName: companyInfo.Name, |
62 | + Name: author.Name, | ||
63 | + Avatar: author.Avatar, | ||
64 | + Position: author.Position, | ||
55 | }, | 65 | }, |
56 | UpdatedAt: item.UpdatedAt, | 66 | UpdatedAt: item.UpdatedAt, |
57 | } | 67 | } |
@@ -59,3 +69,15 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar | @@ -59,3 +69,15 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar | ||
59 | } | 69 | } |
60 | return resp, nil | 70 | return resp, nil |
61 | } | 71 | } |
72 | + | ||
73 | +func (l *MiniArticleMarkListLogic) getAuthor(conn transaction.Conn, userid int64) domain.User { | ||
74 | + if u, ok := l.userCache[userid]; ok { | ||
75 | + return *u | ||
76 | + } | ||
77 | + toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid) | ||
78 | + if err == nil { | ||
79 | + l.userCache[toUser.Id] = toUser | ||
80 | + return *toUser | ||
81 | + } | ||
82 | + return domain.User{} | ||
83 | +} |
@@ -41,25 +41,25 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -41,25 +41,25 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
41 | if articleInfo.CompanyId != req.CompanyId { | 41 | if articleInfo.CompanyId != req.CompanyId { |
42 | return nil, xerr.NewErrMsg("没有查看权限") | 42 | return nil, xerr.NewErrMsg("没有查看权限") |
43 | } | 43 | } |
44 | - | ||
45 | - if len(articleInfo.WhoRead) > 0 { | ||
46 | - inWhoRead := false | ||
47 | - for _, val := range articleInfo.WhoRead { | ||
48 | - if req.UserId == int(val) { | ||
49 | - inWhoRead = true | 44 | + if articleInfo.AuthorId != int64(req.UserId) { |
45 | + if len(articleInfo.WhoRead) > 0 { | ||
46 | + inWhoRead := false | ||
47 | + for _, val := range articleInfo.WhoRead { | ||
48 | + if req.UserId == int(val) { | ||
49 | + inWhoRead = true | ||
50 | + } | ||
50 | } | 51 | } |
51 | - } | ||
52 | - if !inWhoRead { | ||
53 | - // 文章内容不显示 | ||
54 | - resp = &types.MiniArticleGetResponse{ | ||
55 | - Id: articleInfo.Id, | ||
56 | - Title: articleInfo.Title, | ||
57 | - Show: int(domain.ArticleShowDisable), | 52 | + if !inWhoRead { |
53 | + // 文章内容不显示 | ||
54 | + resp = &types.MiniArticleGetResponse{ | ||
55 | + Id: articleInfo.Id, | ||
56 | + Title: articleInfo.Title, | ||
57 | + Show: int(domain.ArticleShowDisable), | ||
58 | + } | ||
59 | + return resp, nil | ||
58 | } | 60 | } |
59 | - return resp, nil | ||
60 | } | 61 | } |
61 | } | 62 | } |
62 | - | ||
63 | if articleInfo.Show == domain.ArticleShowDisable { | 63 | if articleInfo.Show == domain.ArticleShowDisable { |
64 | // 文章内容不显示 | 64 | // 文章内容不显示 |
65 | resp = &types.MiniArticleGetResponse{ | 65 | resp = &types.MiniArticleGetResponse{ |
@@ -80,7 +80,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -80,7 +80,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
80 | } | 80 | } |
81 | 81 | ||
82 | //获取作者信息 | 82 | //获取作者信息 |
83 | - author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, int64(req.UserId)) | 83 | + author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, int64(articleInfo.AuthorId)) |
84 | 84 | ||
85 | var meLoveFlag int | 85 | var meLoveFlag int |
86 | if req.UserId > 0 { | 86 | if req.UserId > 0 { |
@@ -152,6 +152,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -152,6 +152,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
152 | MeFollowFlag: 0, | 152 | MeFollowFlag: 0, |
153 | Tags: tags, | 153 | Tags: tags, |
154 | MatchUrl: map[string]string{}, | 154 | MatchUrl: map[string]string{}, |
155 | + Videos: []types.Video{}, | ||
155 | } | 156 | } |
156 | if len(backupList) > 0 { | 157 | if len(backupList) > 0 { |
157 | resp.Edit = 1 | 158 | resp.Edit = 1 |
@@ -171,6 +172,16 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -171,6 +172,16 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
171 | for _, val := range articleInfo.Images { | 172 | for _, val := range articleInfo.Images { |
172 | resp.Images = append(resp.Images, val.Url) | 173 | resp.Images = append(resp.Images, val.Url) |
173 | } | 174 | } |
175 | + | ||
176 | + for _, val := range articleInfo.Videos { | ||
177 | + resp.Videos = append(resp.Videos, types.Video{ | ||
178 | + Url: val.Url, | ||
179 | + Cover: val.Cover, | ||
180 | + Width: val.Width, | ||
181 | + Height: val.Height, | ||
182 | + }) | ||
183 | + } | ||
184 | + | ||
174 | if follow != nil { | 185 | if follow != nil { |
175 | resp.MeFollowFlag = 1 | 186 | resp.MeFollowFlag = 1 |
176 | } | 187 | } |
@@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
5 | 5 | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
10 | 11 | ||
@@ -13,15 +14,17 @@ import ( | @@ -13,15 +14,17 @@ import ( | ||
13 | 14 | ||
14 | type MiniSearchArticlePageLogic struct { | 15 | type MiniSearchArticlePageLogic struct { |
15 | logx.Logger | 16 | logx.Logger |
16 | - ctx context.Context | ||
17 | - svcCtx *svc.ServiceContext | 17 | + ctx context.Context |
18 | + svcCtx *svc.ServiceContext | ||
19 | + userCache map[int64]*domain.User | ||
18 | } | 20 | } |
19 | 21 | ||
20 | func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSearchArticlePageLogic { | 22 | func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSearchArticlePageLogic { |
21 | return &MiniSearchArticlePageLogic{ | 23 | return &MiniSearchArticlePageLogic{ |
22 | - Logger: logx.WithContext(ctx), | ||
23 | - ctx: ctx, | ||
24 | - svcCtx: svcCtx, | 24 | + Logger: logx.WithContext(ctx), |
25 | + ctx: ctx, | ||
26 | + svcCtx: svcCtx, | ||
27 | + userCache: make(map[int64]*domain.User), | ||
25 | } | 28 | } |
26 | } | 29 | } |
27 | 30 | ||
@@ -63,11 +66,13 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch | @@ -63,11 +66,13 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch | ||
63 | } | 66 | } |
64 | 67 | ||
65 | for i, val := range articleList { | 68 | for i, val := range articleList { |
69 | + author := l.getAuthor(conn, val.AuthorId) | ||
66 | item := types.MiniSearchArticleItem{ | 70 | item := types.MiniSearchArticleItem{ |
67 | ArticleId: val.Id, | 71 | ArticleId: val.Id, |
68 | Title: val.Title, | 72 | Title: val.Title, |
69 | - Author: val.Author.Name, | ||
70 | - Avatar: val.Author.Avatar, | 73 | + AuthorId: val.AuthorId, |
74 | + Author: author.Name, | ||
75 | + Avatar: author.Avatar, | ||
71 | Images: []string{}, | 76 | Images: []string{}, |
72 | CreatedAt: val.CreatedAt, | 77 | CreatedAt: val.CreatedAt, |
73 | MeReadFlag: 0, | 78 | MeReadFlag: 0, |
@@ -84,3 +89,15 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch | @@ -84,3 +89,15 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch | ||
84 | 89 | ||
85 | return resp, nil | 90 | return resp, nil |
86 | } | 91 | } |
92 | + | ||
93 | +func (l *MiniSearchArticlePageLogic) getAuthor(conn transaction.Conn, userid int64) domain.User { | ||
94 | + if u, ok := l.userCache[userid]; ok { | ||
95 | + return *u | ||
96 | + } | ||
97 | + toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid) | ||
98 | + if err == nil { | ||
99 | + l.userCache[toUser.Id] = toUser | ||
100 | + return *toUser | ||
101 | + } | ||
102 | + return domain.User{} | ||
103 | +} |
@@ -52,7 +52,9 @@ func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.System | @@ -52,7 +52,9 @@ func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.System | ||
52 | }, | 52 | }, |
53 | TargetUser: int(backup.TargetUser), | 53 | TargetUser: int(backup.TargetUser), |
54 | Tags: backup.Tags, | 54 | Tags: backup.Tags, |
55 | + Videos: make([]types.Video, 0), | ||
55 | } | 56 | } |
57 | + | ||
56 | //文章段落内容 | 58 | //文章段落内容 |
57 | lo.ForEach(backup.Section, func(item domain.ArticleSection, index int) { | 59 | lo.ForEach(backup.Section, func(item domain.ArticleSection, index int) { |
58 | resp.Section = append(resp.Section, types.ArticleSection{ | 60 | resp.Section = append(resp.Section, types.ArticleSection{ |
@@ -66,6 +68,16 @@ func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.System | @@ -66,6 +68,16 @@ func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.System | ||
66 | lo.ForEach(backup.Images, func(item domain.Image, index int) { | 68 | lo.ForEach(backup.Images, func(item domain.Image, index int) { |
67 | resp.Images = append(resp.Images, item.Url) | 69 | resp.Images = append(resp.Images, item.Url) |
68 | }) | 70 | }) |
71 | + | ||
72 | + // 视频 | ||
73 | + for _, val := range backup.Videos { | ||
74 | + resp.Videos = append(resp.Videos, types.Video{ | ||
75 | + Url: val.Url, | ||
76 | + Cover: val.Cover, | ||
77 | + Width: val.Width, | ||
78 | + Height: val.Height, | ||
79 | + }) | ||
80 | + } | ||
69 | //用户 | 81 | //用户 |
70 | userIds := lo.Union(resp.WhoRead, resp.WhoReview) | 82 | userIds := lo.Union(resp.WhoRead, resp.WhoReview) |
71 | if len(userIds) > 0 { | 83 | if len(userIds) > 0 { |
@@ -62,6 +62,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | @@ -62,6 +62,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | ||
62 | 62 | ||
63 | article.Version = article.Version + 1 | 63 | article.Version = article.Version + 1 |
64 | article.Images = backup.Images | 64 | article.Images = backup.Images |
65 | + article.Videos = backup.Videos | ||
65 | article.Title = backup.Title | 66 | article.Title = backup.Title |
66 | article.MatchUrl = backup.MatchUrl | 67 | article.MatchUrl = backup.MatchUrl |
67 | articleSections := make([]domain.ArticleSection, 0) | 68 | articleSections := make([]domain.ArticleSection, 0) |
@@ -66,6 +66,16 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ | @@ -66,6 +66,16 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ | ||
66 | Show: int(article.Show), | 66 | Show: int(article.Show), |
67 | Tags: make([]types.ArticleTagItem, 0), | 67 | Tags: make([]types.ArticleTagItem, 0), |
68 | TargetUser: int(article.TargetUser), | 68 | TargetUser: int(article.TargetUser), |
69 | + Videos: make([]types.Video, 0), | ||
70 | + } | ||
71 | + | ||
72 | + for _, val := range article.Videos { | ||
73 | + resp.Videos = append(resp.Videos, types.Video{ | ||
74 | + Url: val.Url, | ||
75 | + Cover: val.Cover, | ||
76 | + Width: val.Width, | ||
77 | + Height: val.Height, | ||
78 | + }) | ||
69 | } | 79 | } |
70 | //标签 | 80 | //标签 |
71 | if len(article.Tags) > 0 { | 81 | if len(article.Tags) > 0 { |
@@ -31,6 +31,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | @@ -31,6 +31,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | ||
31 | WithOffsetLimit(req.Page, req.Size). | 31 | WithOffsetLimit(req.Page, req.Size). |
32 | WithKV("title", req.Title). | 32 | WithKV("title", req.Title). |
33 | WithKV("authorId", req.Author). | 33 | WithKV("authorId", req.Author). |
34 | + WithKV("tags", req.Tags). | ||
34 | WithKV("beginCreatedAt", req.BeginTime). | 35 | WithKV("beginCreatedAt", req.BeginTime). |
35 | WithKV("endCreatedAt", req.EndTime) | 36 | WithKV("endCreatedAt", req.EndTime) |
36 | total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) | 37 | total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) |
@@ -43,33 +44,47 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | @@ -43,33 +44,47 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | ||
43 | } | 44 | } |
44 | authorIds := make([]int64, 0) | 45 | authorIds := make([]int64, 0) |
45 | lo.ForEach(articles, func(item *domain.Article, index int) { | 46 | lo.ForEach(articles, func(item *domain.Article, index int) { |
47 | + authorIds = append(authorIds, item.AuthorId) | ||
48 | + }) | ||
49 | + //查询用户数据,重新赋值更新用户名称 | ||
50 | + _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds)) | ||
51 | + //获取标签 | ||
52 | + _, tags, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions()) | ||
53 | + lo.ForEach(articles, func(item *domain.Article, index int) { | ||
54 | + //图片 | ||
46 | images := make([]string, 0) | 55 | images := make([]string, 0) |
47 | lo.ForEach(item.Images, func(img domain.Image, n int) { | 56 | lo.ForEach(item.Images, func(img domain.Image, n int) { |
48 | images = append(images, img.Url) | 57 | images = append(images, img.Url) |
49 | }) | 58 | }) |
59 | + //发布人 | ||
60 | + author := item.Author.Name | ||
61 | + for _, user := range users { | ||
62 | + if user.Id == item.AuthorId { | ||
63 | + author = user.Name | ||
64 | + } | ||
65 | + } | ||
66 | + //标签 | ||
67 | + articleTags := make([]string, 0) | ||
68 | + lo.ForEach(item.Tags, func(tagId int64, index int) { | ||
69 | + for _, t := range tags { | ||
70 | + if t.Id == tagId { | ||
71 | + articleTags = append(articleTags, t.Name) | ||
72 | + } | ||
73 | + } | ||
74 | + }) | ||
50 | resp.List = append(resp.List, types.SystemArticleSearch{ | 75 | resp.List = append(resp.List, types.SystemArticleSearch{ |
51 | Id: item.Id, | 76 | Id: item.Id, |
52 | Title: item.Title, | 77 | Title: item.Title, |
53 | AuthorId: item.AuthorId, | 78 | AuthorId: item.AuthorId, |
54 | - Author: item.Author.Name, | 79 | + Author: author, |
55 | Images: images, | 80 | Images: images, |
56 | CreatedAt: item.CreatedAt, | 81 | CreatedAt: item.CreatedAt, |
57 | CountLove: item.CountLove, | 82 | CountLove: item.CountLove, |
58 | CountComment: item.CountComment, | 83 | CountComment: item.CountComment, |
59 | Show: int(item.Show), | 84 | Show: int(item.Show), |
60 | - Tags: nil, | 85 | + Tags: articleTags, |
61 | TargetUser: int(item.TargetUser), | 86 | TargetUser: int(item.TargetUser), |
62 | }) | 87 | }) |
63 | - authorIds = append(authorIds, item.AuthorId) | ||
64 | - }) | ||
65 | - //查询用户数据,重新赋值更新用户名称 | ||
66 | - _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds)) | ||
67 | - lo.ForEach(resp.List, func(item types.SystemArticleSearch, index int) { | ||
68 | - for _, user := range users { | ||
69 | - if user.Id == item.AuthorId { | ||
70 | - resp.List[index].Author = user.Name | ||
71 | - } | ||
72 | - } | ||
73 | }) | 88 | }) |
74 | - return resp, nil | 89 | + return |
75 | } | 90 | } |
@@ -90,6 +90,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -90,6 +90,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
90 | Height: h, | 90 | Height: h, |
91 | }) | 91 | }) |
92 | } | 92 | } |
93 | + | ||
93 | //检查文章可被哪些人查看 | 94 | //检查文章可被哪些人查看 |
94 | whoRead := []int64{} | 95 | whoRead := []int64{} |
95 | if len(req.WhoRead) > 0 { | 96 | if len(req.WhoRead) > 0 { |
@@ -37,6 +37,7 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System | @@ -37,6 +37,7 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System | ||
37 | return nil, xerr.NewErrMsg("没有操作权限") | 37 | return nil, xerr.NewErrMsg("没有操作权限") |
38 | } | 38 | } |
39 | commetInfo.CountAdminLove = req.CountAdminLove | 39 | commetInfo.CountAdminLove = req.CountAdminLove |
40 | + commetInfo.Content = req.Content | ||
40 | var increaseCount int | 41 | var increaseCount int |
41 | switch req.Show { | 42 | switch req.Show { |
42 | case 1: | 43 | case 1: |
@@ -52,7 +53,7 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System | @@ -52,7 +53,7 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System | ||
52 | increaseCount = -1 | 53 | increaseCount = -1 |
53 | } | 54 | } |
54 | } | 55 | } |
55 | - commetInfo.Show = domain.CommentShowEnable | 56 | + |
56 | // 变更回复数量 | 57 | // 变更回复数量 |
57 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 58 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
58 | _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) | 59 | _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) |
@@ -49,6 +49,9 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini | @@ -49,6 +49,9 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini | ||
49 | return nil, xerr.NewErrMsgErr("申请失败", err) | 49 | return nil, xerr.NewErrMsgErr("申请失败", err) |
50 | } | 50 | } |
51 | if user != nil { | 51 | if user != nil { |
52 | + if user.Enable != domain.UserEnable { | ||
53 | + return nil, xerr.NewErrMsgErr("账号不可用", err) | ||
54 | + } | ||
52 | token, err = generateToken(l.svcCtx, user) | 55 | token, err = generateToken(l.svcCtx, user) |
53 | if err != nil { | 56 | if err != nil { |
54 | return nil, xerr.NewErrMsgErr("登录失败", err) | 57 | return nil, xerr.NewErrMsgErr("登录失败", err) |
@@ -44,6 +44,8 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp * | @@ -44,6 +44,8 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp * | ||
44 | ) | 44 | ) |
45 | if req.AuthorId > 0 { | 45 | if req.AuthorId > 0 { |
46 | users = []int64{req.AuthorId} | 46 | users = []int64{req.AuthorId} |
47 | + } else { | ||
48 | + users = append(users, user.Id) | ||
47 | } | 49 | } |
48 | if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, user.Id, req.LastArticleId, req.Size); err != nil { | 50 | if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, user.Id, req.LastArticleId, req.Size); err != nil { |
49 | return nil, xerr.NewErrMsgErr("获取快讯异常", err) | 51 | return nil, xerr.NewErrMsgErr("获取快讯异常", err) |
@@ -265,10 +265,11 @@ type SystemEditCommentShowResponse struct { | @@ -265,10 +265,11 @@ type SystemEditCommentShowResponse struct { | ||
265 | } | 265 | } |
266 | 266 | ||
267 | type SystemEditCommentRequest struct { | 267 | type SystemEditCommentRequest struct { |
268 | - CompanyId int64 `json:",optional"` | ||
269 | - Id int64 `json:"id"` | ||
270 | - Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] | ||
271 | - CountAdminLove int `json:"countAdminLove,optional"` | 268 | + CompanyId int64 `json:",optional"` |
269 | + Id int64 `json:"id"` | ||
270 | + Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] | ||
271 | + Content string `json:"content,optional"` | ||
272 | + CountAdminLove int `json:"countAdminLove,optional"` | ||
272 | } | 273 | } |
273 | 274 | ||
274 | type SystemEditCommentResponse struct { | 275 | type SystemEditCommentResponse struct { |
@@ -825,6 +826,13 @@ type Location struct { | @@ -825,6 +826,13 @@ type Location struct { | ||
825 | Descript string `json:"descript,optional"` //地点描述 | 826 | Descript string `json:"descript,optional"` //地点描述 |
826 | } | 827 | } |
827 | 828 | ||
829 | +type Video struct { | ||
830 | + Url string `json:"url"` //视频文件的地址 | ||
831 | + Cover string `json:"cover"` //封面 | ||
832 | + Width int `json:"width"` //封面图片宽 | ||
833 | + Height int `json:"height"` //封面图片长 | ||
834 | +} | ||
835 | + | ||
828 | type ArticleAuthor struct { | 836 | type ArticleAuthor struct { |
829 | Id int64 `json:"id"` // 人员id | 837 | Id int64 `json:"id"` // 人员id |
830 | Name string `json:"name"` // 人员的名字 | 838 | Name string `json:"name"` // 人员的名字 |
@@ -862,6 +870,7 @@ type MiniArticleGetResponse struct { | @@ -862,6 +870,7 @@ type MiniArticleGetResponse struct { | ||
862 | CreatedAt int64 `json:"createdAt"` //文章的发布时间 | 870 | CreatedAt int64 `json:"createdAt"` //文章的发布时间 |
863 | Section []ArticleSection `json:"section"` //文章的文本内容 | 871 | Section []ArticleSection `json:"section"` //文章的文本内容 |
864 | Images []string `json:"images"` //图片 | 872 | Images []string `json:"images"` //图片 |
873 | + Videos []Video `json:"videos"` //视频 | ||
865 | WhoRead []int64 `json:"whoRead"` //谁可查看 | 874 | WhoRead []int64 `json:"whoRead"` //谁可查看 |
866 | WhoReview []int64 `json:"whoReview"` //谁可评论 | 875 | WhoReview []int64 `json:"whoReview"` //谁可评论 |
867 | Location Location `json:"location"` //定位坐标 | 876 | Location Location `json:"location"` //定位坐标 |
@@ -1140,6 +1149,7 @@ type SystemArticleGetResponse struct { | @@ -1140,6 +1149,7 @@ type SystemArticleGetResponse struct { | ||
1140 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | 1149 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 |
1141 | Section []ArticleSection `json:"section"` // 文章的文本内容 | 1150 | Section []ArticleSection `json:"section"` // 文章的文本内容 |
1142 | Images []string `json:"images"` // 图片 | 1151 | Images []string `json:"images"` // 图片 |
1152 | + Videos []Video `json:"videos"` // 视频 | ||
1143 | WhoRead []int64 `json:"whoRead"` // 谁可查看 | 1153 | WhoRead []int64 `json:"whoRead"` // 谁可查看 |
1144 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | 1154 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 |
1145 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 1155 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
@@ -1172,12 +1182,12 @@ type SystemArticleSearchResponse struct { | @@ -1172,12 +1182,12 @@ type SystemArticleSearchResponse struct { | ||
1172 | type SystemArticleSearch struct { | 1182 | type SystemArticleSearch struct { |
1173 | Id int64 `json:"id"` //id | 1183 | Id int64 `json:"id"` //id |
1174 | Title string `json:"title"` //标题 | 1184 | Title string `json:"title"` //标题 |
1175 | - AuthorId int64 `json:"author"` //发布人ID | 1185 | + AuthorId int64 `json:"authorId"` //发布人ID |
1176 | Author string `json:"author"` //发布人 | 1186 | Author string `json:"author"` //发布人 |
1177 | Images []string `json:"images"` //图片 | 1187 | Images []string `json:"images"` //图片 |
1178 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 1188 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
1179 | CountLove int `json:"countLove"` //点赞数量 | 1189 | CountLove int `json:"countLove"` //点赞数量 |
1180 | - CountComment int `json:"CountComment"` //评论数量 | 1190 | + CountComment int `json:"countComment"` //评论数量 |
1181 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 1191 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
1182 | Tags []string `json:"tags"` //标签 | 1192 | Tags []string `json:"tags"` //标签 |
1183 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 1193 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
@@ -1190,6 +1200,7 @@ type SystemArticleUpdateRequest struct { | @@ -1190,6 +1200,7 @@ type SystemArticleUpdateRequest struct { | ||
1190 | Section []ArticleSection `json:"section"` // 填写的内容 | 1200 | Section []ArticleSection `json:"section"` // 填写的内容 |
1191 | Title string `json:"title"` // 标题 | 1201 | Title string `json:"title"` // 标题 |
1192 | Images []string `json:"images"` // 图片 | 1202 | Images []string `json:"images"` // 图片 |
1203 | + Videos []Video `json:"video"` // 视频 | ||
1193 | WhoRead []int64 `json:"whoRead"` // 谁可以看 | 1204 | WhoRead []int64 `json:"whoRead"` // 谁可以看 |
1194 | WhoReview []int64 `json:"whoReview"` // 评论人 | 1205 | WhoReview []int64 `json:"whoReview"` // 评论人 |
1195 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | 1206 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
@@ -1204,6 +1215,7 @@ type SystemArticleUpdateResponse struct { | @@ -1204,6 +1215,7 @@ type SystemArticleUpdateResponse struct { | ||
1204 | Images []string `json:"images"` //图片 | 1215 | Images []string `json:"images"` //图片 |
1205 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 1216 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
1206 | CountLove int `json:"countLove"` //点赞数量 | 1217 | CountLove int `json:"countLove"` //点赞数量 |
1218 | + Videos []Video `json:"video"` // 视频 | ||
1207 | CountComment int `json:"countComment"` //评论数量 | 1219 | CountComment int `json:"countComment"` //评论数量 |
1208 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 1220 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
1209 | Tags []int64 `json:"tags"` //标签 | 1221 | Tags []int64 `json:"tags"` //标签 |
@@ -1237,12 +1249,13 @@ type SystemArticleGetHistoryRequest struct { | @@ -1237,12 +1249,13 @@ type SystemArticleGetHistoryRequest struct { | ||
1237 | } | 1249 | } |
1238 | 1250 | ||
1239 | type SystemArticleGetHistoryResponse struct { | 1251 | type SystemArticleGetHistoryResponse struct { |
1240 | - Id int64 `json:"id"` // id | ||
1241 | - ArticleId int64 `json:"articleId"` // 文章ID | ||
1242 | - Title string `json:"title"` // 标题 | ||
1243 | - CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | ||
1244 | - Section []ArticleSection `json:"section"` // 文章的文本内容 | ||
1245 | - Images []string `json:"images"` // 图片 | 1252 | + Id int64 `json:"id"` // id |
1253 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
1254 | + Title string `json:"title"` // 标题 | ||
1255 | + CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | ||
1256 | + Section []ArticleSection `json:"section"` // 文章的文本内容 | ||
1257 | + Images []string `json:"images"` // 图片 | ||
1258 | + Videos []Video `json:"video"` | ||
1246 | WhoRead []int64 `json:"whoRead"` // 谁可查看 | 1259 | WhoRead []int64 `json:"whoRead"` // 谁可查看 |
1247 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | 1260 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 |
1248 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 1261 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
@@ -1303,6 +1316,7 @@ type MiniSearchArticleResponse struct { | @@ -1303,6 +1316,7 @@ type MiniSearchArticleResponse struct { | ||
1303 | type MiniSearchArticleItem struct { | 1316 | type MiniSearchArticleItem struct { |
1304 | ArticleId int64 `json:"articleId"` | 1317 | ArticleId int64 `json:"articleId"` |
1305 | Title string `json:"title"` | 1318 | Title string `json:"title"` |
1319 | + AuthorId int64 `json:"authorId"` | ||
1306 | Author string `json:"author"` // 发布人 | 1320 | Author string `json:"author"` // 发布人 |
1307 | Avatar string `json:"avatar"` // 发布人的头像 | 1321 | Avatar string `json:"avatar"` // 发布人的头像 |
1308 | Images []string `json:"images"` | 1322 | Images []string `json:"images"` |
@@ -22,6 +22,7 @@ type ArticleBackup struct { | @@ -22,6 +22,7 @@ type ArticleBackup struct { | ||
22 | Title string // 标题 | 22 | Title string // 标题 |
23 | Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"` // 分段内容 | 23 | Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"` // 分段内容 |
24 | Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片 | 24 | Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片 |
25 | + Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频 | ||
25 | Action string // 操作 | 26 | Action string // 操作 |
26 | WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看 | 27 | WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看 |
27 | WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 | 28 | WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 |
@@ -175,6 +175,7 @@ func (repository *ArticleBackupRepository) ModelToDomainModel(from *models.Artic | @@ -175,6 +175,7 @@ func (repository *ArticleBackupRepository) ModelToDomainModel(from *models.Artic | ||
175 | WhoReview: from.WhoReview, | 175 | WhoReview: from.WhoReview, |
176 | Tags: from.Tags, | 176 | Tags: from.Tags, |
177 | MatchUrl: from.MatchUrl, | 177 | MatchUrl: from.MatchUrl, |
178 | + Videos: from.Videos, | ||
178 | } | 179 | } |
179 | // err := copier.Copy(to, from) | 180 | // err := copier.Copy(to, from) |
180 | return to, nil | 181 | return to, nil |
@@ -201,6 +202,7 @@ func (repository *ArticleBackupRepository) DomainModelToModel(from *domain.Artic | @@ -201,6 +202,7 @@ func (repository *ArticleBackupRepository) DomainModelToModel(from *domain.Artic | ||
201 | Location: from.Location, | 202 | Location: from.Location, |
202 | TargetUser: int(from.TargetUser), | 203 | TargetUser: int(from.TargetUser), |
203 | MatchUrl: from.MatchUrl, | 204 | MatchUrl: from.MatchUrl, |
205 | + Videos: from.Videos, | ||
204 | } | 206 | } |
205 | // err := copier.Copy(to, from) | 207 | // err := copier.Copy(to, from) |
206 | return to, nil | 208 | return to, nil |
@@ -3,6 +3,7 @@ package repository | @@ -3,6 +3,7 @@ package repository | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | "fmt" | 5 | "fmt" |
6 | + "strings" | ||
6 | 7 | ||
7 | "github.com/pkg/errors" | 8 | "github.com/pkg/errors" |
8 | "github.com/tiptok/gocomm/pkg/cache" | 9 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -136,6 +137,13 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -136,6 +137,13 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
136 | if v, ok := queryOptions["authorId"]; ok { | 137 | if v, ok := queryOptions["authorId"]; ok { |
137 | tx = tx.Where("author_id=?", v) | 138 | tx = tx.Where("author_id=?", v) |
138 | } | 139 | } |
140 | + if v, ok := queryOptions["tags"]; ok && len(v.([]int64)) > 0 { | ||
141 | + values := make([]string, 0) | ||
142 | + for _, item := range v.([]int64) { | ||
143 | + values = append(values, fmt.Sprintf("%v", item)) | ||
144 | + } | ||
145 | + tx = tx.Where("tags @> ?", "["+strings.Join(values, ",")+"]") | ||
146 | + } | ||
139 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 147 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
140 | return dms, tx.Error | 148 | return dms, tx.Error |
141 | } | 149 | } |
@@ -168,7 +176,7 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex | @@ -168,7 +176,7 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex | ||
168 | queryFunc := func() (interface{}, error) { | 176 | queryFunc := func() (interface{}, error) { |
169 | tx = tx.Model(&ms). | 177 | tx = tx.Model(&ms). |
170 | Where("company_id=?", companyId). | 178 | Where("company_id=?", companyId). |
171 | - Where("author_id in (?)", append(authors, whoRead)). // 包含自己的文章 | 179 | + Where("author_id in (?)", authors). // 包含自己的文章 |
172 | Where(fmt.Sprintf("author_id = %d or target_user=0 or who_read @>'[%d]'", whoRead, whoRead)). | 180 | Where(fmt.Sprintf("author_id = %d or target_user=0 or who_read @>'[%d]'", whoRead, whoRead)). |
173 | Where("show = 1") | 181 | Where("show = 1") |
174 | if lastId > 0 { | 182 | if lastId > 0 { |
@@ -49,6 +49,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran | @@ -49,6 +49,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran | ||
49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
50 | return nil, err | 50 | return nil, err |
51 | } | 51 | } |
52 | + | ||
52 | return repository.ModelToDomainModel(m) | 53 | return repository.ModelToDomainModel(m) |
53 | } | 54 | } |
54 | 55 |
@@ -110,7 +110,8 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | @@ -110,7 +110,8 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | ||
110 | ArticleId: m.Id, | 110 | ArticleId: m.Id, |
111 | Title: m.Title, | 111 | Title: m.Title, |
112 | Section: sectionBackup, | 112 | Section: sectionBackup, |
113 | - Images: m.Images, | 113 | + Images: make([]Image, len(m.Images)), |
114 | + Videos: make([]Video, len(m.Videos)), | ||
114 | Action: "", | 115 | Action: "", |
115 | TargetUser: m.TargetUser, | 116 | TargetUser: m.TargetUser, |
116 | WhoRead: m.WhoRead, | 117 | WhoRead: m.WhoRead, |
@@ -118,7 +119,8 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | @@ -118,7 +119,8 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | ||
118 | Tags: m.Tags, | 119 | Tags: m.Tags, |
119 | MatchUrl: map[string]string{}, | 120 | MatchUrl: map[string]string{}, |
120 | } | 121 | } |
121 | - | 122 | + copy(b.Videos, m.Videos) |
123 | + copy(b.Images, m.Images) | ||
122 | for k, v := range m.MatchUrl { | 124 | for k, v := range m.MatchUrl { |
123 | b.MatchUrl[k] = v | 125 | b.MatchUrl[k] = v |
124 | } | 126 | } |
@@ -19,6 +19,7 @@ type ArticleBackup struct { | @@ -19,6 +19,7 @@ type ArticleBackup struct { | ||
19 | Title string `json:"title"` // 标题 | 19 | Title string `json:"title"` // 标题 |
20 | Section []ArticleSection `json:"section"` // 分段内容 | 20 | Section []ArticleSection `json:"section"` // 分段内容 |
21 | Images []Image `json:"images"` // 图片 | 21 | Images []Image `json:"images"` // 图片 |
22 | + Videos []Video `json:"videos"` // 视频 | ||
22 | Action string `json:"action"` // 操作 | 23 | Action string `json:"action"` // 操作 |
23 | TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人 | 24 | TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人 |
24 | Location Location `json:"location"` // 定位坐标 | 25 | Location Location `json:"location"` // 定位坐标 |
@@ -70,7 +70,9 @@ type ArticleCommentRepository interface { | @@ -70,7 +70,9 @@ type ArticleCommentRepository interface { | ||
70 | Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) | 70 | Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) |
71 | UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) | 71 | UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) |
72 | Delete(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) | 72 | Delete(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) |
73 | + | ||
73 | FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleComment, error) | 74 | FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleComment, error) |
75 | + | ||
74 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleComment, error) | 76 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleComment, error) |
75 | IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error //点赞数量变动 | 77 | IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error //点赞数量变动 |
76 | IncreaseCountReply(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error // 评论回复数量变动 | 78 | IncreaseCountReply(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error // 评论回复数量变动 |
@@ -73,4 +73,20 @@ CREATE INDEX IF NOT EXISTS idx_message_system_company_id ON "public"."message_sy | @@ -73,4 +73,20 @@ CREATE INDEX IF NOT EXISTS idx_message_system_company_id ON "public"."message_sy | ||
73 | 73 | ||
74 | -- 业务消息表 | 74 | -- 业务消息表 |
75 | -- (公司ID)索引 | 75 | -- (公司ID)索引 |
76 | -CREATE INDEX IF NOT EXISTS idx_message_business_company_id ON "public"."message_business" USING btree(company_id); | ||
76 | +CREATE INDEX IF NOT EXISTS idx_message_business_company_id ON "public"."message_business" USING btree(company_id); | ||
77 | + | ||
78 | + | ||
79 | +-- 迁移准备 | ||
80 | +-- 修改起始的id序号 | ||
81 | +select setval('user_id_seq',10000); | ||
82 | +select setval('department_id_seq',10000); | ||
83 | +select setval('role_id_seq',10000); | ||
84 | +select setval('company_id_seq',10000); | ||
85 | + | ||
86 | +select setval('article_id_seq',100000); | ||
87 | +select setval('article_and_tag_id_seq',100000); | ||
88 | +select setval('article_backup_id_seq',100000); | ||
89 | +select setval('article_comment_id_seq',100000); | ||
90 | +select setval('article_draft_id_seq',100000); | ||
91 | +select setval('article_section_id_seq',100000); | ||
92 | +select setval('article_tag_id_seq',100000); |
-
请 注册 或 登录 后发表评论