正在显示
20 个修改的文件
包含
214 行增加
和
57 行删除
| @@ -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"` // 谁可评论 |
| @@ -374,7 +385,7 @@ type ( | @@ -374,7 +385,7 @@ type ( | ||
| 374 | SystemArticleSearchRequest { | 385 | SystemArticleSearchRequest { |
| 375 | CompanyId int64 `json:"companyId,optional"` | 386 | CompanyId int64 `json:"companyId,optional"` |
| 376 | Title string `json:"title,optional"` //标题 | 387 | Title string `json:"title,optional"` //标题 |
| 377 | - Author string `json:"author,optional"` //发布人 | 388 | + Author int64 `json:"author,optional"` //发布人 |
| 378 | BeginTime int64 `json:"beginTime,optional"` //开始时间 | 389 | BeginTime int64 `json:"beginTime,optional"` //开始时间 |
| 379 | EndTime int64 `json:"endTime,optional"` //结束时间 | 390 | EndTime int64 `json:"endTime,optional"` //结束时间 |
| 380 | Tags []int64 `json:"tags,optional"` //标签 | 391 | Tags []int64 `json:"tags,optional"` //标签 |
| @@ -389,11 +400,12 @@ type ( | @@ -389,11 +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"` //标题 |
| 403 | + AuthorId int64 `json:"authorId"` //发布人ID | ||
| 392 | Author string `json:"author"` //发布人 | 404 | Author string `json:"author"` //发布人 |
| 393 | Images []string `json:"images"` //图片 | 405 | Images []string `json:"images"` //图片 |
| 394 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 406 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
| 395 | CountLove int `json:"countLove"` //点赞数量 | 407 | CountLove int `json:"countLove"` //点赞数量 |
| 396 | - CountComment int `json:"CountComment"` //评论数量 | 408 | + CountComment int `json:"countComment"` //评论数量 |
| 397 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 409 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 398 | Tags []string `json:"tags"` //标签 | 410 | Tags []string `json:"tags"` //标签 |
| 399 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 411 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| @@ -409,6 +421,7 @@ type ( | @@ -409,6 +421,7 @@ type ( | ||
| 409 | Section []ArticleSection `json:"section"` // 填写的内容 | 421 | Section []ArticleSection `json:"section"` // 填写的内容 |
| 410 | Title string `json:"title"` // 标题 | 422 | Title string `json:"title"` // 标题 |
| 411 | Images []string `json:"images"` // 图片 | 423 | Images []string `json:"images"` // 图片 |
| 424 | + Videos []Video `json:"video"` // 视频 | ||
| 412 | WhoRead []int64 `json:"whoRead"` // 谁可以看 | 425 | WhoRead []int64 `json:"whoRead"` // 谁可以看 |
| 413 | WhoReview []int64 `json:"whoReview"` // 评论人 | 426 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 414 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | 427 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
| @@ -422,6 +435,7 @@ type ( | @@ -422,6 +435,7 @@ type ( | ||
| 422 | Images []string `json:"images"` //图片 | 435 | Images []string `json:"images"` //图片 |
| 423 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 436 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
| 424 | CountLove int `json:"countLove"` //点赞数量 | 437 | CountLove int `json:"countLove"` //点赞数量 |
| 438 | + Videos []Video `json:"video"` // 视频 | ||
| 425 | CountComment int `json:"countComment"` //评论数量 | 439 | CountComment int `json:"countComment"` //评论数量 |
| 426 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 440 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 427 | Tags []int64 `json:"tags"` //标签 | 441 | Tags []int64 `json:"tags"` //标签 |
| @@ -463,6 +477,7 @@ type ( | @@ -463,6 +477,7 @@ type ( | ||
| 463 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | 477 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 |
| 464 | Section []ArticleSection `json:"section"` // 文章的文本内容 | 478 | Section []ArticleSection `json:"section"` // 文章的文本内容 |
| 465 | Images []string `json:"images"` // 图片 | 479 | Images []string `json:"images"` // 图片 |
| 480 | + Videos []Video `json:"video"` | ||
| 466 | WhoRead []int64 `json:"whoRead"` // 谁可查看 | 481 | WhoRead []int64 `json:"whoRead"` // 谁可查看 |
| 467 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | 482 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 |
| 468 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 483 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
| @@ -258,7 +258,7 @@ type ( | @@ -258,7 +258,7 @@ type ( | ||
| 258 | Size int `json:"size"` | 258 | Size int `json:"size"` |
| 259 | ArticleId int64 `json:"articleId"` // 文章ID | 259 | ArticleId int64 `json:"articleId"` // 文章ID |
| 260 | TopId int64 `json:"topId,optional"` // 文章顶层ID | 260 | TopId int64 `json:"topId,optional"` // 文章顶层ID |
| 261 | - Author string `json:"author,optional"` // 用户 | 261 | + Author int64 `json:"author,optional"` // 用户 |
| 262 | Show int `json:"show,optional"` // 显示状态 | 262 | Show int `json:"show,optional"` // 显示状态 |
| 263 | BeginTime int64 `json:"beginTime,optional"` // 开始时间 | 263 | BeginTime int64 `json:"beginTime,optional"` // 开始时间 |
| 264 | EndTime int64 `json:"endTime,optional"` // 结束时间 | 264 | EndTime int64 `json:"endTime,optional"` // 结束时间 |
| @@ -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 | } |
| @@ -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 { |
| @@ -30,7 +30,8 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | @@ -30,7 +30,8 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | ||
| 30 | queryOptions := domain.NewQueryOptions(). | 30 | queryOptions := domain.NewQueryOptions(). |
| 31 | WithOffsetLimit(req.Page, req.Size). | 31 | WithOffsetLimit(req.Page, req.Size). |
| 32 | WithKV("title", req.Title). | 32 | WithKV("title", req.Title). |
| 33 | - WithKV("author", 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) |
| @@ -41,23 +42,49 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | @@ -41,23 +42,49 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | ||
| 41 | Total: int(total), | 42 | Total: int(total), |
| 42 | List: make([]types.SystemArticleSearch, 0), | 43 | List: make([]types.SystemArticleSearch, 0), |
| 43 | } | 44 | } |
| 45 | + authorIds := make([]int64, 0) | ||
| 44 | 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 | + //图片 | ||
| 45 | images := make([]string, 0) | 55 | images := make([]string, 0) |
| 46 | lo.ForEach(item.Images, func(img domain.Image, n int) { | 56 | lo.ForEach(item.Images, func(img domain.Image, n int) { |
| 47 | images = append(images, img.Url) | 57 | images = append(images, img.Url) |
| 48 | }) | 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 | + }) | ||
| 49 | resp.List = append(resp.List, types.SystemArticleSearch{ | 75 | resp.List = append(resp.List, types.SystemArticleSearch{ |
| 50 | Id: item.Id, | 76 | Id: item.Id, |
| 51 | Title: item.Title, | 77 | Title: item.Title, |
| 52 | - Author: item.Author.Name, | 78 | + AuthorId: item.AuthorId, |
| 79 | + Author: author, | ||
| 53 | Images: images, | 80 | Images: images, |
| 54 | CreatedAt: item.CreatedAt, | 81 | CreatedAt: item.CreatedAt, |
| 55 | CountLove: item.CountLove, | 82 | CountLove: item.CountLove, |
| 56 | CountComment: item.CountComment, | 83 | CountComment: item.CountComment, |
| 57 | Show: int(item.Show), | 84 | Show: int(item.Show), |
| 58 | - Tags: nil, | 85 | + Tags: articleTags, |
| 59 | TargetUser: int(item.TargetUser), | 86 | TargetUser: int(item.TargetUser), |
| 60 | }) | 87 | }) |
| 61 | }) | 88 | }) |
| 62 | - return resp, nil | 89 | + return |
| 63 | } | 90 | } |
| @@ -2,7 +2,6 @@ package comment | @@ -2,7 +2,6 @@ package comment | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | - | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 5 | "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" | 6 | "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" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
| @@ -29,61 +28,69 @@ func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCo | @@ -29,61 +28,69 @@ func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCo | ||
| 29 | // 小程序端人人员删除评论 | 28 | // 小程序端人人员删除评论 |
| 30 | func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) { | 29 | func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) { |
| 31 | var conn = l.svcCtx.DefaultDBConn() | 30 | var conn = l.svcCtx.DefaultDBConn() |
| 32 | - commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId) | 31 | + commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId) |
| 33 | if err != nil { | 32 | if err != nil { |
| 34 | return nil, xerr.NewErrMsgErr("删除评论信息失败", err) | 33 | return nil, xerr.NewErrMsgErr("删除评论信息失败", err) |
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | - if commetInfo.FromUserId != req.UserId { | 36 | + if commentInfo.FromUserId != req.UserId { |
| 38 | return nil, xerr.NewErrMsg("没有操作权限") | 37 | return nil, xerr.NewErrMsg("没有操作权限") |
| 39 | } | 38 | } |
| 40 | 39 | ||
| 41 | - if commetInfo.Show == domain.CommentShowDisable { | 40 | + if commentInfo.Show == domain.CommentShowDisable { |
| 42 | resp = &types.MiniDeleteArticleCommentResponse{ | 41 | resp = &types.MiniDeleteArticleCommentResponse{ |
| 43 | - Id: commetInfo.Id, | 42 | + Id: commentInfo.Id, |
| 44 | } | 43 | } |
| 45 | return resp, nil | 44 | return resp, nil |
| 46 | } | 45 | } |
| 47 | - commetInfo.Show = domain.CommentShowDisable | 46 | + commentInfo.Show = domain.CommentShowDisable |
| 48 | 47 | ||
| 49 | // 变更回复数量 | 48 | // 变更回复数量 |
| 50 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 49 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
| 51 | - _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) | 50 | + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo) |
| 52 | if err != nil { | 51 | if err != nil { |
| 53 | return err | 52 | return err |
| 54 | } | 53 | } |
| 55 | // 减少上级评论的回复数量 | 54 | // 减少上级评论的回复数量 |
| 56 | - if commetInfo.Pid != 0 { | ||
| 57 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid) | 55 | + if commentInfo.Pid != 0 { |
| 56 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) | ||
| 58 | if err != nil { | 57 | if err != nil { |
| 59 | return err | 58 | return err |
| 60 | } | 59 | } |
| 61 | } | 60 | } |
| 62 | // 减少最顶层的评论回复计数 | 61 | // 减少最顶层的评论回复计数 |
| 63 | - if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { | ||
| 64 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId) | 62 | + if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId { |
| 63 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId) | ||
| 65 | if err != nil { | 64 | if err != nil { |
| 66 | return err | 65 | return err |
| 67 | } | 66 | } |
| 68 | } | 67 | } |
| 69 | //减少加段落评论计数 | 68 | //减少加段落评论计数 |
| 70 | - if commetInfo.SectionId > 0 { | ||
| 71 | - err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId) | 69 | + if commentInfo.SectionId > 0 { |
| 70 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId) | ||
| 72 | if err != nil { | 71 | if err != nil { |
| 73 | return err | 72 | return err |
| 74 | } | 73 | } |
| 75 | } | 74 | } |
| 76 | // 减少文章的评论数 | 75 | // 减少文章的评论数 |
| 77 | - err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId) | 76 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId) |
| 78 | if err != nil { | 77 | if err != nil { |
| 79 | return err | 78 | return err |
| 80 | } | 79 | } |
| 80 | + | ||
| 81 | + //// 评论被隐藏消息 | ||
| 82 | + //var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx) | ||
| 83 | + //err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content) | ||
| 84 | + //if err != nil { | ||
| 85 | + // return err | ||
| 86 | + //} | ||
| 87 | + | ||
| 81 | return nil | 88 | return nil |
| 82 | }, true) | 89 | }, true) |
| 83 | 90 | ||
| 84 | if err != nil { | 91 | if err != nil { |
| 85 | return nil, xerr.NewErrMsgErr("删除评论信息失败", err) | 92 | return nil, xerr.NewErrMsgErr("删除评论信息失败", err) |
| 86 | } | 93 | } |
| 87 | - resp = &types.MiniDeleteArticleCommentResponse{Id: commetInfo.Id} | 94 | + resp = &types.MiniDeleteArticleCommentResponse{Id: commentInfo.Id} |
| 88 | return resp, nil | 95 | return resp, nil |
| 89 | } | 96 | } |
| @@ -35,9 +35,11 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types. | @@ -35,9 +35,11 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types. | ||
| 35 | WithKV("articleId", req.ArticleId). | 35 | WithKV("articleId", req.ArticleId). |
| 36 | WithKV("topId", req.TopId). | 36 | WithKV("topId", req.TopId). |
| 37 | WithKV("show", req.Show). | 37 | WithKV("show", req.Show). |
| 38 | - WithKV("fromUserName", req.Author). | ||
| 39 | WithKV("beginCreatedAt", req.BeginTime). | 38 | WithKV("beginCreatedAt", req.BeginTime). |
| 40 | WithKV("endCreatedAt", req.EndTime) | 39 | WithKV("endCreatedAt", req.EndTime) |
| 40 | + if req.Author > 0 { | ||
| 41 | + queryOptions = queryOptions.WithKV("fromUserId", req.Author) | ||
| 42 | + } | ||
| 41 | total, comments, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOptions) | 43 | total, comments, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOptions) |
| 42 | if err != nil { | 44 | if err != nil { |
| 43 | return nil, xerr.NewErrMsgErr("获取文章评论失败", err) | 45 | return nil, xerr.NewErrMsgErr("获取文章评论失败", err) |
| @@ -46,6 +48,7 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types. | @@ -46,6 +48,7 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types. | ||
| 46 | Total: total, | 48 | Total: total, |
| 47 | List: make([]types.SystemArticleCommentSearchItem, 0), | 49 | List: make([]types.SystemArticleCommentSearchItem, 0), |
| 48 | } | 50 | } |
| 51 | + authorIds := make([]int64, 0) | ||
| 49 | lo.ForEach(comments, func(item *domain.ArticleComment, index int) { | 52 | lo.ForEach(comments, func(item *domain.ArticleComment, index int) { |
| 50 | resp.List = append(resp.List, types.SystemArticleCommentSearchItem{ | 53 | resp.List = append(resp.List, types.SystemArticleCommentSearchItem{ |
| 51 | Id: item.Id, | 54 | Id: item.Id, |
| @@ -68,6 +71,22 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types. | @@ -68,6 +71,22 @@ func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types. | ||
| 68 | Content: item.Content, | 71 | Content: item.Content, |
| 69 | Show: int(item.Show), | 72 | Show: int(item.Show), |
| 70 | }) | 73 | }) |
| 74 | + authorIds = append(authorIds, item.FromUserId) | ||
| 75 | + }) | ||
| 76 | + //查询用户数据,重新赋值更新用户名称 | ||
| 77 | + _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds)) | ||
| 78 | + lo.ForEach(resp.List, func(item types.SystemArticleCommentSearchItem, index int) { | ||
| 79 | + for _, user := range users { | ||
| 80 | + if user.Id == item.FromUserId { | ||
| 81 | + resp.List[index].FromUser = types.CommentAuthor{ | ||
| 82 | + Id: user.Id, | ||
| 83 | + Name: user.Name, | ||
| 84 | + Avatar: user.Avatar, | ||
| 85 | + Position: user.Position, | ||
| 86 | + Company: item.FromUser.Company, | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + } | ||
| 71 | }) | 90 | }) |
| 72 | return | 91 | return |
| 73 | } | 92 | } |
| @@ -2,6 +2,7 @@ package comment | @@ -2,6 +2,7 @@ package comment | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | ||
| 5 | 6 | ||
| 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/svc" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| @@ -61,49 +62,57 @@ func (l *SystemEditAticleCommentShowLogic) SystemEditAticleCommentShow(req *type | @@ -61,49 +62,57 @@ func (l *SystemEditAticleCommentShowLogic) SystemEditAticleCommentShow(req *type | ||
| 61 | 62 | ||
| 62 | func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyId int64) error { | 63 | func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyId int64) error { |
| 63 | var conn = l.svcCtx.DefaultDBConn() | 64 | var conn = l.svcCtx.DefaultDBConn() |
| 64 | - commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId) | 65 | + commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId) |
| 65 | if err != nil { | 66 | if err != nil { |
| 66 | return xerr.NewErrMsgErr("删除评论信息失败", err) | 67 | return xerr.NewErrMsgErr("删除评论信息失败", err) |
| 67 | } | 68 | } |
| 68 | - if commetInfo.CompanyId != companyId { | 69 | + if commentInfo.CompanyId != companyId { |
| 69 | return xerr.NewErrMsg("没有操作权限") | 70 | return xerr.NewErrMsg("没有操作权限") |
| 70 | } | 71 | } |
| 71 | - if commetInfo.Show == domain.CommentShowDisable { | 72 | + if commentInfo.Show == domain.CommentShowDisable { |
| 72 | return nil | 73 | return nil |
| 73 | } | 74 | } |
| 74 | - commetInfo.Show = domain.CommentShowDisable | 75 | + commentInfo.Show = domain.CommentShowDisable |
| 75 | // 变更回复数量 | 76 | // 变更回复数量 |
| 76 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 77 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
| 77 | - _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) | 78 | + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commentInfo) |
| 78 | if err != nil { | 79 | if err != nil { |
| 79 | return err | 80 | return err |
| 80 | } | 81 | } |
| 81 | // 减少上级评论的回复数量 | 82 | // 减少上级评论的回复数量 |
| 82 | - if commetInfo.Pid != 0 { | ||
| 83 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid) | 83 | + if commentInfo.Pid != 0 { |
| 84 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid) | ||
| 84 | if err != nil { | 85 | if err != nil { |
| 85 | return err | 86 | return err |
| 86 | } | 87 | } |
| 87 | } | 88 | } |
| 88 | // 减少最顶层的评论回复计数 | 89 | // 减少最顶层的评论回复计数 |
| 89 | - if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { | ||
| 90 | - err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId) | 90 | + if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId { |
| 91 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId) | ||
| 91 | if err != nil { | 92 | if err != nil { |
| 92 | return err | 93 | return err |
| 93 | } | 94 | } |
| 94 | } | 95 | } |
| 95 | //减少加段落评论计数 | 96 | //减少加段落评论计数 |
| 96 | - if commetInfo.SectionId > 0 { | ||
| 97 | - err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId) | 97 | + if commentInfo.SectionId > 0 { |
| 98 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId) | ||
| 98 | if err != nil { | 99 | if err != nil { |
| 99 | return err | 100 | return err |
| 100 | } | 101 | } |
| 101 | } | 102 | } |
| 102 | // 减少文章的评论数 | 103 | // 减少文章的评论数 |
| 103 | - err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId) | 104 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId) |
| 104 | if err != nil { | 105 | if err != nil { |
| 105 | return err | 106 | return err |
| 106 | } | 107 | } |
| 108 | + | ||
| 109 | + // 评论被隐藏消息 | ||
| 110 | + var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx) | ||
| 111 | + err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content) | ||
| 112 | + if err != nil { | ||
| 113 | + return err | ||
| 114 | + } | ||
| 115 | + | ||
| 107 | return nil | 116 | return nil |
| 108 | }, true) | 117 | }, true) |
| 109 | 118 |
| @@ -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) |
| @@ -165,14 +165,14 @@ type SystemArticleCommentSearchMeResponse struct { | @@ -165,14 +165,14 @@ type SystemArticleCommentSearchMeResponse struct { | ||
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | type SystemArticleCommentSearchRequest struct { | 167 | type SystemArticleCommentSearchRequest struct { |
| 168 | - Page int `json:"page"` | ||
| 169 | - Size int `json:"size"` | ||
| 170 | - ArticleId int64 `json:"articleId"` // 文章ID | ||
| 171 | - TopId int64 `json:"topId,optional"` // 文章顶层ID | ||
| 172 | - Author string `json:"author,optional"` // 用户 | ||
| 173 | - Show int `json:"show,optional"` // 显示状态 | ||
| 174 | - BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
| 175 | - EndTime int64 `json:"endTime,optional"` // 结束时间 | 168 | + Page int `json:"page"` |
| 169 | + Size int `json:"size"` | ||
| 170 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
| 171 | + TopId int64 `json:"topId,optional"` // 文章顶层ID | ||
| 172 | + Author int64 `json:"author,optional"` // 用户 | ||
| 173 | + Show int `json:"show,optional"` // 显示状态 | ||
| 174 | + BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
| 175 | + EndTime int64 `json:"endTime,optional"` // 结束时间 | ||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | type SystemArticleCommentSearchResponse struct { | 178 | type SystemArticleCommentSearchResponse struct { |
| @@ -825,6 +825,13 @@ type Location struct { | @@ -825,6 +825,13 @@ type Location struct { | ||
| 825 | Descript string `json:"descript,optional"` //地点描述 | 825 | Descript string `json:"descript,optional"` //地点描述 |
| 826 | } | 826 | } |
| 827 | 827 | ||
| 828 | +type Video struct { | ||
| 829 | + Url string `json:"url"` //视频文件的地址 | ||
| 830 | + Cover string `json:"cover"` //封面 | ||
| 831 | + Width int `json:"width"` //封面图片宽 | ||
| 832 | + Height int `json:"height"` //封面图片长 | ||
| 833 | +} | ||
| 834 | + | ||
| 828 | type ArticleAuthor struct { | 835 | type ArticleAuthor struct { |
| 829 | Id int64 `json:"id"` // 人员id | 836 | Id int64 `json:"id"` // 人员id |
| 830 | Name string `json:"name"` // 人员的名字 | 837 | Name string `json:"name"` // 人员的名字 |
| @@ -862,6 +869,7 @@ type MiniArticleGetResponse struct { | @@ -862,6 +869,7 @@ type MiniArticleGetResponse struct { | ||
| 862 | CreatedAt int64 `json:"createdAt"` //文章的发布时间 | 869 | CreatedAt int64 `json:"createdAt"` //文章的发布时间 |
| 863 | Section []ArticleSection `json:"section"` //文章的文本内容 | 870 | Section []ArticleSection `json:"section"` //文章的文本内容 |
| 864 | Images []string `json:"images"` //图片 | 871 | Images []string `json:"images"` //图片 |
| 872 | + Videos []Video `json:"videos"` //视频 | ||
| 865 | WhoRead []int64 `json:"whoRead"` //谁可查看 | 873 | WhoRead []int64 `json:"whoRead"` //谁可查看 |
| 866 | WhoReview []int64 `json:"whoReview"` //谁可评论 | 874 | WhoReview []int64 `json:"whoReview"` //谁可评论 |
| 867 | Location Location `json:"location"` //定位坐标 | 875 | Location Location `json:"location"` //定位坐标 |
| @@ -1140,6 +1148,7 @@ type SystemArticleGetResponse struct { | @@ -1140,6 +1148,7 @@ type SystemArticleGetResponse struct { | ||
| 1140 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | 1148 | CreatedAt int64 `json:"createdAt"` // 文章的发布时间 |
| 1141 | Section []ArticleSection `json:"section"` // 文章的文本内容 | 1149 | Section []ArticleSection `json:"section"` // 文章的文本内容 |
| 1142 | Images []string `json:"images"` // 图片 | 1150 | Images []string `json:"images"` // 图片 |
| 1151 | + Videos []Video `json:"videos"` // 视频 | ||
| 1143 | WhoRead []int64 `json:"whoRead"` // 谁可查看 | 1152 | WhoRead []int64 `json:"whoRead"` // 谁可查看 |
| 1144 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | 1153 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 |
| 1145 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 1154 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
| @@ -1156,7 +1165,7 @@ type SystemArticleGetResponse struct { | @@ -1156,7 +1165,7 @@ type SystemArticleGetResponse struct { | ||
| 1156 | type SystemArticleSearchRequest struct { | 1165 | type SystemArticleSearchRequest struct { |
| 1157 | CompanyId int64 `json:"companyId,optional"` | 1166 | CompanyId int64 `json:"companyId,optional"` |
| 1158 | Title string `json:"title,optional"` //标题 | 1167 | Title string `json:"title,optional"` //标题 |
| 1159 | - Author string `json:"author,optional"` //发布人 | 1168 | + Author int64 `json:"author,optional"` //发布人 |
| 1160 | BeginTime int64 `json:"beginTime,optional"` //开始时间 | 1169 | BeginTime int64 `json:"beginTime,optional"` //开始时间 |
| 1161 | EndTime int64 `json:"endTime,optional"` //结束时间 | 1170 | EndTime int64 `json:"endTime,optional"` //结束时间 |
| 1162 | Tags []int64 `json:"tags,optional"` //标签 | 1171 | Tags []int64 `json:"tags,optional"` //标签 |
| @@ -1172,11 +1181,12 @@ type SystemArticleSearchResponse struct { | @@ -1172,11 +1181,12 @@ type SystemArticleSearchResponse struct { | ||
| 1172 | type SystemArticleSearch struct { | 1181 | type SystemArticleSearch struct { |
| 1173 | Id int64 `json:"id"` //id | 1182 | Id int64 `json:"id"` //id |
| 1174 | Title string `json:"title"` //标题 | 1183 | Title string `json:"title"` //标题 |
| 1184 | + AuthorId int64 `json:"authorId"` //发布人ID | ||
| 1175 | Author string `json:"author"` //发布人 | 1185 | Author string `json:"author"` //发布人 |
| 1176 | Images []string `json:"images"` //图片 | 1186 | Images []string `json:"images"` //图片 |
| 1177 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 1187 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
| 1178 | CountLove int `json:"countLove"` //点赞数量 | 1188 | CountLove int `json:"countLove"` //点赞数量 |
| 1179 | - CountComment int `json:"CountComment"` //评论数量 | 1189 | + CountComment int `json:"countComment"` //评论数量 |
| 1180 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 1190 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 1181 | Tags []string `json:"tags"` //标签 | 1191 | Tags []string `json:"tags"` //标签 |
| 1182 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 1192 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| @@ -1189,6 +1199,7 @@ type SystemArticleUpdateRequest struct { | @@ -1189,6 +1199,7 @@ type SystemArticleUpdateRequest struct { | ||
| 1189 | Section []ArticleSection `json:"section"` // 填写的内容 | 1199 | Section []ArticleSection `json:"section"` // 填写的内容 |
| 1190 | Title string `json:"title"` // 标题 | 1200 | Title string `json:"title"` // 标题 |
| 1191 | Images []string `json:"images"` // 图片 | 1201 | Images []string `json:"images"` // 图片 |
| 1202 | + Videos []Video `json:"video"` // 视频 | ||
| 1192 | WhoRead []int64 `json:"whoRead"` // 谁可以看 | 1203 | WhoRead []int64 `json:"whoRead"` // 谁可以看 |
| 1193 | WhoReview []int64 `json:"whoReview"` // 评论人 | 1204 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 1194 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | 1205 | TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] |
| @@ -1203,6 +1214,7 @@ type SystemArticleUpdateResponse struct { | @@ -1203,6 +1214,7 @@ type SystemArticleUpdateResponse struct { | ||
| 1203 | Images []string `json:"images"` //图片 | 1214 | Images []string `json:"images"` //图片 |
| 1204 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 1215 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
| 1205 | CountLove int `json:"countLove"` //点赞数量 | 1216 | CountLove int `json:"countLove"` //点赞数量 |
| 1217 | + Videos []Video `json:"video"` // 视频 | ||
| 1206 | CountComment int `json:"countComment"` //评论数量 | 1218 | CountComment int `json:"countComment"` //评论数量 |
| 1207 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 1219 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 1208 | Tags []int64 `json:"tags"` //标签 | 1220 | Tags []int64 `json:"tags"` //标签 |
| @@ -1236,12 +1248,13 @@ type SystemArticleGetHistoryRequest struct { | @@ -1236,12 +1248,13 @@ type SystemArticleGetHistoryRequest struct { | ||
| 1236 | } | 1248 | } |
| 1237 | 1249 | ||
| 1238 | type SystemArticleGetHistoryResponse struct { | 1250 | type SystemArticleGetHistoryResponse struct { |
| 1239 | - Id int64 `json:"id"` // id | ||
| 1240 | - ArticleId int64 `json:"articleId"` // 文章ID | ||
| 1241 | - Title string `json:"title"` // 标题 | ||
| 1242 | - CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | ||
| 1243 | - Section []ArticleSection `json:"section"` // 文章的文本内容 | ||
| 1244 | - Images []string `json:"images"` // 图片 | 1251 | + Id int64 `json:"id"` // id |
| 1252 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
| 1253 | + Title string `json:"title"` // 标题 | ||
| 1254 | + CreatedAt int64 `json:"createdAt"` // 文章的发布时间 | ||
| 1255 | + Section []ArticleSection `json:"section"` // 文章的文本内容 | ||
| 1256 | + Images []string `json:"images"` // 图片 | ||
| 1257 | + Videos []Video `json:"video"` | ||
| 1245 | WhoRead []int64 `json:"whoRead"` // 谁可查看 | 1258 | WhoRead []int64 `json:"whoRead"` // 谁可查看 |
| 1246 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 | 1259 | WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看 |
| 1247 | WhoReview []int64 `json:"whoReview"` // 谁可评论 | 1260 | WhoReview []int64 `json:"whoReview"` // 谁可评论 |
| @@ -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" |
| @@ -127,9 +128,6 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -127,9 +128,6 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
| 127 | if v, ok := queryOptions["title"]; ok && v.(string) != "" { | 128 | if v, ok := queryOptions["title"]; ok && v.(string) != "" { |
| 128 | tx = tx.Where("title like ?", "%"+v.(string)+"%") | 129 | tx = tx.Where("title like ?", "%"+v.(string)+"%") |
| 129 | } | 130 | } |
| 130 | - if v, ok := queryOptions["author"]; ok && v.(string) != "" { | ||
| 131 | - tx = tx.Where(`author #>> '{"name"}' like ?`, "%"+v.(string)+"%") | ||
| 132 | - } | ||
| 133 | if v, ok := queryOptions["beginCreatedAt"]; ok { | 131 | if v, ok := queryOptions["beginCreatedAt"]; ok { |
| 134 | tx = tx.Where("created_at >= ?", v) | 132 | tx = tx.Where("created_at >= ?", v) |
| 135 | } | 133 | } |
| @@ -139,6 +137,13 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -139,6 +137,13 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
| 139 | if v, ok := queryOptions["authorId"]; ok { | 137 | if v, ok := queryOptions["authorId"]; ok { |
| 140 | tx = tx.Where("author_id=?", v) | 138 | tx = tx.Where("author_id=?", v) |
| 141 | } | 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 | + } | ||
| 142 | 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 { |
| 143 | return dms, tx.Error | 148 | return dms, tx.Error |
| 144 | } | 149 | } |
| @@ -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); |
-
请 注册 或 登录 后发表评论