作者 yangfu

Merge branch 'dev' into test

正在显示 28 个修改的文件 包含 350 行增加70 行删除
@@ -7,6 +7,9 @@ @@ -7,6 +7,9 @@
7 管理后台“易数家“前端入口:https://digital-front-platform-dev.fjmaimaimai.com/ 7 管理后台“易数家“前端入口:https://digital-front-platform-dev.fjmaimaimai.com/
8 跳转后的实际管理后台地址: https://sumifcc-x-front-test.sumifcc.com 8 跳转后的实际管理后台地址: https://sumifcc-x-front-test.sumifcc.com
9 9
  10 + 样例账号 18860183050 密码 123456
  11 +
  12 +
10 ### 可设置环境变量 13 ### 可设置环境变量
11 - DataSource 14 - DataSource
12 数据库连接,样例 15 数据库连接,样例
@@ -374,7 +374,7 @@ type ( @@ -374,7 +374,7 @@ type (
374 SystemArticleSearchRequest { 374 SystemArticleSearchRequest {
375 CompanyId int64 `json:"companyId,optional"` 375 CompanyId int64 `json:"companyId,optional"`
376 Title string `json:"title,optional"` //标题 376 Title string `json:"title,optional"` //标题
377 - Author string `json:"author,optional"` //发布人 377 + Author int64 `json:"author,optional"` //发布人
378 BeginTime int64 `json:"beginTime,optional"` //开始时间 378 BeginTime int64 `json:"beginTime,optional"` //开始时间
379 EndTime int64 `json:"endTime,optional"` //结束时间 379 EndTime int64 `json:"endTime,optional"` //结束时间
380 Tags []int64 `json:"tags,optional"` //标签 380 Tags []int64 `json:"tags,optional"` //标签
@@ -389,11 +389,12 @@ type ( @@ -389,11 +389,12 @@ type (
389 SystemArticleSearch { 389 SystemArticleSearch {
390 Id int64 `json:"id"` //id 390 Id int64 `json:"id"` //id
391 Title string `json:"title"` //标题 391 Title string `json:"title"` //标题
  392 + AuthorId int64 `json:"authorId"` //发布人ID
392 Author string `json:"author"` //发布人 393 Author string `json:"author"` //发布人
393 Images []string `json:"images"` //图片 394 Images []string `json:"images"` //图片
394 CreatedAt int64 `json:"createdAt"` //文章的创建日期 395 CreatedAt int64 `json:"createdAt"` //文章的创建日期
395 CountLove int `json:"countLove"` //点赞数量 396 CountLove int `json:"countLove"` //点赞数量
396 - CountComment int `json:"CountComment"` //评论数量 397 + CountComment int `json:"countComment"` //评论数量
397 Show int `json:"show"` //是否隐藏 [0显示、1不显示] 398 Show int `json:"show"` //是否隐藏 [0显示、1不显示]
398 Tags []string `json:"tags"` //标签 399 Tags []string `json:"tags"` //标签
399 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] 400 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
@@ -76,6 +76,10 @@ service Core { @@ -76,6 +76,10 @@ service Core {
76 @doc "管理后台变更评论" 76 @doc "管理后台变更评论"
77 @handler SystemEditAticleComment 77 @handler SystemEditAticleComment
78 post /article_comment/edit (SystemEditCommentRequest)returns (SystemEditCommentResponse) 78 post /article_comment/edit (SystemEditCommentRequest)returns (SystemEditCommentResponse)
  79 +
  80 + @doc "编辑评论的运营点赞数"
  81 + @handler SystemEditAticleCommentLove
  82 + post /article_comment/edit/love (SystemEditCommentLoveRequest)returns (SystemEditCommentLoveResponse)
79 } 83 }
80 84
81 //评论的填写人 85 //评论的填写人
@@ -254,7 +258,7 @@ type ( @@ -254,7 +258,7 @@ type (
254 Size int `json:"size"` 258 Size int `json:"size"`
255 ArticleId int64 `json:"articleId"` // 文章ID 259 ArticleId int64 `json:"articleId"` // 文章ID
256 TopId int64 `json:"topId,optional"` // 文章顶层ID 260 TopId int64 `json:"topId,optional"` // 文章顶层ID
257 - Author string `json:"author,optional"` // 用户 261 + Author int64 `json:"author,optional"` // 用户
258 Show int `json:"show,optional"` // 显示状态 262 Show int `json:"show,optional"` // 显示状态
259 BeginTime int64 `json:"beginTime,optional"` // 开始时间 263 BeginTime int64 `json:"beginTime,optional"` // 开始时间
260 EndTime int64 `json:"endTime,optional"` // 结束时间 264 EndTime int64 `json:"endTime,optional"` // 结束时间
@@ -289,7 +293,7 @@ type ( @@ -289,7 +293,7 @@ type (
289 Size int `json:"size"` 293 Size int `json:"size"`
290 CompanyId int64 `json:",optional"` // 294 CompanyId int64 `json:",optional"` //
291 TopId int64 `json:"topId,optional"` // 评论的顶层ID 295 TopId int64 `json:"topId,optional"` // 评论的顶层ID
292 - FromUser string `json:"fromUser,optional"` // 用户 296 + FromUserId int64 `json:"fromUserId,optional"` // 用户
293 Show int `json:"show,optional"` // 显示状态 297 Show int `json:"show,optional"` // 显示状态
294 BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间 298 BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间
295 EndTime int64 `json:"endTime,optional"` // 填写评论的结束时间 299 EndTime int64 `json:"endTime,optional"` // 填写评论的结束时间
@@ -368,3 +372,18 @@ type ( @@ -368,3 +372,18 @@ type (
368 Id int64 `json:"id"` 372 Id int64 `json:"id"`
369 } 373 }
370 ) 374 )
  375 +
  376 +// 管理后台变更评论的运营点赞
  377 +type (
  378 + SystemEditCommentLoveRequest {
  379 + CompanyId int64 `json:",optional"`
  380 + ParamList []SystemEditLove `json:"paramList"`
  381 + }
  382 + SystemEditLove {
  383 + Id int64 `json:"id"`
  384 + CountAdminLove int `json:"countAdminLove,optional"`
  385 + }
  386 + SystemEditCommentLoveResponse {
  387 + ParamList []SystemEditLove `json:"paramList"`
  388 + }
  389 +)
@@ -15,7 +15,7 @@ func SystemEditAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -15,7 +15,7 @@ func SystemEditAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.SystemEditCommentRequest 16 var req types.SystemEditCommentRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
  1 +package comment
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  12 +)
  13 +
  14 +// 单独编辑评论的运营点赞数量
  15 +func SystemEditAticleCommentLoveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  16 + return func(w http.ResponseWriter, r *http.Request) {
  17 + var req types.SystemEditCommentLoveRequest
  18 + if err := httpx.Parse(r, &req); err != nil {
  19 + result.HttpResult(r, w, nil, err)
  20 + return
  21 + }
  22 + token := contextdata.GetUserTokenFromCtx(r.Context())
  23 + req.CompanyId = token.CompanyId
  24 + l := comment.NewSystemEditAticleCommentLoveLogic(r.Context(), svcCtx)
  25 + resp, err := l.SystemEditAticleCommentLove(&req)
  26 + result.HttpResult(r, w, resp, err)
  27 + }
  28 +}
@@ -11,6 +11,7 @@ import ( @@ -11,6 +11,7 @@ import (
11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" 11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
12 ) 12 )
13 13
  14 +// 管理后台的评论列表
14 func SystemListAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 15 func SystemListAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
15 return func(w http.ResponseWriter, r *http.Request) { 16 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.SystemListCommentRequest 17 var req types.SystemListCommentRequest
@@ -133,6 +133,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -133,6 +133,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
133 Path: "/article_comment/edit", 133 Path: "/article_comment/edit",
134 Handler: comment.SystemEditAticleCommentHandler(serverCtx), 134 Handler: comment.SystemEditAticleCommentHandler(serverCtx),
135 }, 135 },
  136 + {
  137 + Method: http.MethodPost,
  138 + Path: "/article_comment/edit/love",
  139 + Handler: comment.SystemEditAticleCommentLoveHandler(serverCtx),
  140 + },
136 }..., 141 }...,
137 ), 142 ),
138 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 143 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
@@ -28,6 +28,9 @@ func NewMiniArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext @@ -28,6 +28,9 @@ func NewMiniArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext
28 // MiniArticleSearchMe 获取我发布的文章 28 // MiniArticleSearchMe 获取我发布的文章
29 func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) { 29 func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) {
30 var conn = l.svcCtx.DefaultDBConn() 30 var conn = l.svcCtx.DefaultDBConn()
  31 + if req.Size > 100 {
  32 + req.Size = 100
  33 + }
31 queryOptions := domain.NewQueryOptions(). 34 queryOptions := domain.NewQueryOptions().
32 WithOffsetLimit(req.Page, req.Size). 35 WithOffsetLimit(req.Page, req.Size).
33 MustWithKV("authorId", req.AuthorId) 36 MustWithKV("authorId", req.AuthorId)
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "strconv" 5 "strconv"
6 "strings" 6 "strings"
7 "text/template" 7 "text/template"
  8 + "unicode/utf8"
8 9
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -34,6 +35,16 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) @@ -34,6 +35,16 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext)
34 // 创建新文章 35 // 创建新文章
35 func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) { 36 func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) {
36 var conn = l.svcCtx.DefaultDBConn() 37 var conn = l.svcCtx.DefaultDBConn()
  38 +
  39 + // 检查文字数量
  40 + wordNum := 0
  41 + for i := range req.Section {
  42 + num := utf8.RuneCountInString(req.Section[i])
  43 + wordNum += num
  44 + }
  45 + if wordNum >= 1000 {
  46 + return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
  47 + }
37 // 检查发布人 48 // 检查发布人
38 author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId) 49 author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId)
39 if err != nil { 50 if err != nil {
@@ -28,7 +28,9 @@ func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceCo @@ -28,7 +28,9 @@ func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceCo
28 // 查询我的草稿箱内容列表 28 // 查询我的草稿箱内容列表
29 func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) { 29 func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) {
30 var conn = l.svcCtx.DefaultDBConn() 30 var conn = l.svcCtx.DefaultDBConn()
31 - 31 + if req.Size > 100 {
  32 + req.Size = 100
  33 + }
32 queryOption := domain.NewQueryOptions(). 34 queryOption := domain.NewQueryOptions().
33 WithOffsetLimit(req.Page, req.Size). 35 WithOffsetLimit(req.Page, req.Size).
34 MustWithKV("authorId", req.AuthorId) 36 MustWithKV("authorId", req.AuthorId)
@@ -29,7 +29,9 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte @@ -29,7 +29,9 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte
29 func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) { 29 func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) {
30 30
31 var conn = l.svcCtx.DefaultDBConn() 31 var conn = l.svcCtx.DefaultDBConn()
32 - 32 + if req.Size > 100 {
  33 + req.Size = 100
  34 + }
33 cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId, 35 cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId,
34 req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size) 36 req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size)
35 if err != nil { 37 if err != nil {
@@ -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 }
@@ -3,6 +3,7 @@ package article @@ -3,6 +3,7 @@ package article
3 import ( 3 import (
4 "context" 4 "context"
5 "strconv" 5 "strconv"
  6 + "unicode/utf8"
6 7
7 "strings" 8 "strings"
8 9
@@ -42,6 +43,17 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU @@ -42,6 +43,17 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
42 //TargetUser 设定为分发给所有人,清空 WhoRead 43 //TargetUser 设定为分发给所有人,清空 WhoRead
43 req.WhoRead = make([]int64, 0) 44 req.WhoRead = make([]int64, 0)
44 } 45 }
  46 +
  47 + // 检查文字数量
  48 + wordNum := 0
  49 + for i := range req.Section {
  50 + num := utf8.RuneCountInString(req.Section[i].Content)
  51 + wordNum += num
  52 + }
  53 + if wordNum >= 1000 {
  54 + return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
  55 + }
  56 +
45 // 获取当前用户信息 57 // 获取当前用户信息
46 userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) 58 userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken})
47 if err != nil { 59 if err != nil {
@@ -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 }
@@ -45,7 +45,7 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt @@ -45,7 +45,7 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt
45 } 45 }
46 46
47 if commentInfo.Show == domain.CommentShowDisable { 47 if commentInfo.Show == domain.CommentShowDisable {
48 - return nil, xerr.NewErrMsg("具体评论已被关闭") 48 + return nil, xerr.NewErrMsg("抱歉,此内容根据运营管理规则已隐藏,暂不可见")
49 } 49 }
50 50
51 queryOption := domain.NewQueryOptions(). 51 queryOption := domain.NewQueryOptions().
@@ -36,8 +36,8 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList @@ -36,8 +36,8 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
36 if err != nil { 36 if err != nil {
37 return nil, xerr.NewErrMsgErr("获取评论信息失败", err) 37 return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
38 } 38 }
39 - if req.Size > 40 {  
40 - req.Size = 40 39 + if req.Size > 100 {
  40 + req.Size = 100
41 } 41 }
42 42
43 queryOption := domain.NewQueryOptions(). 43 queryOption := domain.NewQueryOptions().
@@ -119,7 +119,7 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList @@ -119,7 +119,7 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
119 } 119 }
120 120
121 //获取回复的评论 121 //获取回复的评论
122 - cntReply, reply := l.listCommentReply(item.Comment.Id, flagMap) 122 + cntReply, reply := l.listCommentReply(companyInfo.Id, item.Comment.Id, flagMap)
123 resp.List[i] = item 123 resp.List[i] = item
124 resp.List[i].Reply = reply 124 resp.List[i].Reply = reply
125 resp.List[i].TotalReply = cntReply 125 resp.List[i].TotalReply = cntReply
@@ -128,9 +128,9 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList @@ -128,9 +128,9 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
128 } 128 }
129 129
130 // listCommentReply 130 // listCommentReply
131 -func (l *MiniListArticleCommentLogic) listCommentReply(commentId int64, loveFlagMap map[int64]struct{}) (cnt int64, replyList []types.ArticleCommentItem) { 131 +func (l *MiniListArticleCommentLogic) listCommentReply(companyId int64, commentId int64, loveFlagMap map[int64]struct{}) (cnt int64, replyList []types.ArticleCommentItem) {
132 var conn = l.svcCtx.DefaultDBConn() 132 var conn = l.svcCtx.DefaultDBConn()
133 - companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, commentId) 133 + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, companyId)
134 if err != nil { 134 if err != nil {
135 return 0, []types.ArticleCommentItem{} 135 return 0, []types.ArticleCommentItem{}
136 } 136 }
@@ -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 }
  1 +package comment
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  11 +
  12 + "github.com/zeromicro/go-zero/core/logx"
  13 +)
  14 +
  15 +type SystemEditAticleCommentLoveLogic struct {
  16 + logx.Logger
  17 + ctx context.Context
  18 + svcCtx *svc.ServiceContext
  19 +}
  20 +
  21 +func NewSystemEditAticleCommentLoveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemEditAticleCommentLoveLogic {
  22 + return &SystemEditAticleCommentLoveLogic{
  23 + Logger: logx.WithContext(ctx),
  24 + ctx: ctx,
  25 + svcCtx: svcCtx,
  26 + }
  27 +}
  28 +
  29 +func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *types.SystemEditCommentLoveRequest) (resp *types.SystemEditCommentLoveResponse, err error) {
  30 + var conn = l.svcCtx.DefaultDBConn()
  31 +
  32 + if len(req.ParamList) <= 0 {
  33 + return &types.SystemEditCommentLoveResponse{}, nil
  34 + }
  35 + paramMap := map[int64]int{}
  36 + ids := []int64{}
  37 + for _, val := range req.ParamList {
  38 + if val.CountAdminLove < 0 {
  39 + return nil, xerr.NewErrMsg("运营点赞数不能小于0")
  40 + }
  41 + ids = append(ids, val.Id)
  42 + paramMap[val.Id] = val.CountAdminLove
  43 + }
  44 +
  45 + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", ids)
  46 + _, commetList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
  47 + if err != nil {
  48 + return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
  49 + }
  50 + resp = &types.SystemEditCommentLoveResponse{}
  51 + for _, val := range commetList {
  52 + if val.CompanyId != req.CompanyId {
  53 + return nil, xerr.NewErrMsg("没有操作权限")
  54 + }
  55 + if u, ok := paramMap[val.Id]; ok {
  56 + val.CountAdminLove = u
  57 + resp.ParamList = append(resp.ParamList, types.SystemEditLove{
  58 + Id: val.Id,
  59 + CountAdminLove: val.CountAdminLove,
  60 + })
  61 + }
  62 + }
  63 + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
  64 + for _, val := range commetList {
  65 + _, err := l.svcCtx.ArticleCommentRepository.UpdateWithVersion(ctx, c, val)
  66 + if err != nil {
  67 + return err
  68 + }
  69 + }
  70 + return nil
  71 + }, true)
  72 + if err != nil {
  73 + return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
  74 + }
  75 +
  76 + return resp, nil
  77 +}
@@ -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
@@ -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/pkg/xerr" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
9 10
10 "github.com/zeromicro/go-zero/core/logx" 11 "github.com/zeromicro/go-zero/core/logx"
@@ -14,6 +15,7 @@ type SystemListAticleCommentLogic struct { @@ -14,6 +15,7 @@ type SystemListAticleCommentLogic struct {
14 logx.Logger 15 logx.Logger
15 ctx context.Context 16 ctx context.Context
16 svcCtx *svc.ServiceContext 17 svcCtx *svc.ServiceContext
  18 + userCache map[int64]types.CommentAuthor
17 } 19 }
18 20
19 func NewSystemListAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemListAticleCommentLogic { 21 func NewSystemListAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemListAticleCommentLogic {
@@ -21,6 +23,7 @@ func NewSystemListAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCon @@ -21,6 +23,7 @@ func NewSystemListAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCon
21 Logger: logx.WithContext(ctx), 23 Logger: logx.WithContext(ctx),
22 ctx: ctx, 24 ctx: ctx,
23 svcCtx: svcCtx, 25 svcCtx: svcCtx,
  26 + userCache: make(map[int64]types.CommentAuthor),
24 } 27 }
25 } 28 }
26 29
@@ -29,7 +32,7 @@ func (l *SystemListAticleCommentLogic) SystemListAticleComment(req *types.System @@ -29,7 +32,7 @@ func (l *SystemListAticleCommentLogic) SystemListAticleComment(req *types.System
29 var conn = l.svcCtx.DefaultDBConn() 32 var conn = l.svcCtx.DefaultDBConn()
30 33
31 cnt, commentList, err := l.svcCtx.ArticleCommentRepository.CustomSearchBy(l.ctx, conn, req.CompanyId, req.Page, req.Size, 34 cnt, commentList, err := l.svcCtx.ArticleCommentRepository.CustomSearchBy(l.ctx, conn, req.CompanyId, req.Page, req.Size,
32 - req.TopId, req.ArticleTitle, req.Content, req.FromUser, req.Show, [2]int64{req.BeginTime, req.EndTime}, 35 + req.TopId, req.ArticleTitle, req.Content, req.FromUserId, req.Show, [2]int64{req.BeginTime, req.EndTime},
33 ) 36 )
34 if err != nil { 37 if err != nil {
35 return nil, xerr.NewErrMsgErr("获取评论列表失败", err) 38 return nil, xerr.NewErrMsgErr("获取评论列表失败", err)
@@ -47,13 +50,7 @@ func (l *SystemListAticleCommentLogic) SystemListAticleComment(req *types.System @@ -47,13 +50,7 @@ func (l *SystemListAticleCommentLogic) SystemListAticleComment(req *types.System
47 TopId: val.TopId, 50 TopId: val.TopId,
48 ArticleTitle: val.ArticleTitle, 51 ArticleTitle: val.ArticleTitle,
49 FromUserId: val.FromUserId, 52 FromUserId: val.FromUserId,
50 - FromUser: types.CommentAuthor{  
51 - Id: val.FromUser.Id,  
52 - Name: val.FromUser.Name,  
53 - Avatar: val.FromUser.Avatar,  
54 - Position: val.FromUser.Position,  
55 - Company: val.FromUser.Company,  
56 - }, 53 + FromUser: l.getCommentAuthor(conn, val.FromUserId, ""),
57 CreatedAt: val.CreatedAt, 54 CreatedAt: val.CreatedAt,
58 Content: val.Content, 55 Content: val.Content,
59 Show: val.Show, 56 Show: val.Show,
@@ -65,3 +62,22 @@ func (l *SystemListAticleCommentLogic) SystemListAticleComment(req *types.System @@ -65,3 +62,22 @@ func (l *SystemListAticleCommentLogic) SystemListAticleComment(req *types.System
65 62
66 return resp, nil 63 return resp, nil
67 } 64 }
  65 +
  66 +func (l *SystemListAticleCommentLogic) getCommentAuthor(conn transaction.Conn, userid int64, companyName string) types.CommentAuthor {
  67 + if u, ok := l.userCache[userid]; ok {
  68 + return u
  69 + }
  70 + toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid)
  71 + if err == nil {
  72 + commentToUser := types.CommentAuthor{
  73 + Id: toUser.Id,
  74 + Name: toUser.Name,
  75 + Avatar: toUser.Avatar,
  76 + Position: toUser.Position,
  77 + Company: companyName,
  78 + }
  79 + l.userCache[toUser.Id] = commentToUser
  80 + return commentToUser
  81 + }
  82 + return types.CommentAuthor{}
  83 +}
@@ -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)
@@ -169,7 +169,7 @@ type SystemArticleCommentSearchRequest struct { @@ -169,7 +169,7 @@ type SystemArticleCommentSearchRequest struct {
169 Size int `json:"size"` 169 Size int `json:"size"`
170 ArticleId int64 `json:"articleId"` // 文章ID 170 ArticleId int64 `json:"articleId"` // 文章ID
171 TopId int64 `json:"topId,optional"` // 文章顶层ID 171 TopId int64 `json:"topId,optional"` // 文章顶层ID
172 - Author string `json:"author,optional"` // 用户 172 + Author int64 `json:"author,optional"` // 用户
173 Show int `json:"show,optional"` // 显示状态 173 Show int `json:"show,optional"` // 显示状态
174 BeginTime int64 `json:"beginTime,optional"` // 开始时间 174 BeginTime int64 `json:"beginTime,optional"` // 开始时间
175 EndTime int64 `json:"endTime,optional"` // 结束时间 175 EndTime int64 `json:"endTime,optional"` // 结束时间
@@ -203,7 +203,7 @@ type SystemListCommentRequest struct { @@ -203,7 +203,7 @@ type SystemListCommentRequest struct {
203 Size int `json:"size"` 203 Size int `json:"size"`
204 CompanyId int64 `json:",optional"` // 204 CompanyId int64 `json:",optional"` //
205 TopId int64 `json:"topId,optional"` // 评论的顶层ID 205 TopId int64 `json:"topId,optional"` // 评论的顶层ID
206 - FromUser string `json:"fromUser,optional"` // 用户 206 + FromUserId int64 `json:"fromUserId,optional"` // 用户
207 Show int `json:"show,optional"` // 显示状态 207 Show int `json:"show,optional"` // 显示状态
208 BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间 208 BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间
209 EndTime int64 `json:"endTime,optional"` // 填写评论的结束时间 209 EndTime int64 `json:"endTime,optional"` // 填写评论的结束时间
@@ -275,6 +275,20 @@ type SystemEditCommentResponse struct { @@ -275,6 +275,20 @@ type SystemEditCommentResponse struct {
275 Id int64 `json:"id"` 275 Id int64 `json:"id"`
276 } 276 }
277 277
  278 +type SystemEditCommentLoveRequest struct {
  279 + CompanyId int64 `json:",optional"`
  280 + ParamList []SystemEditLove `json:"paramList"`
  281 +}
  282 +
  283 +type SystemEditLove struct {
  284 + Id int64 `json:"id"`
  285 + CountAdminLove int `json:"countAdminLove,optional"`
  286 +}
  287 +
  288 +type SystemEditCommentLoveResponse struct {
  289 + ParamList []SystemEditLove `json:"paramList"`
  290 +}
  291 +
278 type MessageRequest struct { 292 type MessageRequest struct {
279 Page int `json:"page"` 293 Page int `json:"page"`
280 Size int `json:"size"` 294 Size int `json:"size"`
@@ -1142,7 +1156,7 @@ type SystemArticleGetResponse struct { @@ -1142,7 +1156,7 @@ type SystemArticleGetResponse struct {
1142 type SystemArticleSearchRequest struct { 1156 type SystemArticleSearchRequest struct {
1143 CompanyId int64 `json:"companyId,optional"` 1157 CompanyId int64 `json:"companyId,optional"`
1144 Title string `json:"title,optional"` //标题 1158 Title string `json:"title,optional"` //标题
1145 - Author string `json:"author,optional"` //发布人 1159 + Author int64 `json:"author,optional"` //发布人
1146 BeginTime int64 `json:"beginTime,optional"` //开始时间 1160 BeginTime int64 `json:"beginTime,optional"` //开始时间
1147 EndTime int64 `json:"endTime,optional"` //结束时间 1161 EndTime int64 `json:"endTime,optional"` //结束时间
1148 Tags []int64 `json:"tags,optional"` //标签 1162 Tags []int64 `json:"tags,optional"` //标签
@@ -1158,11 +1172,12 @@ type SystemArticleSearchResponse struct { @@ -1158,11 +1172,12 @@ type SystemArticleSearchResponse struct {
1158 type SystemArticleSearch struct { 1172 type SystemArticleSearch struct {
1159 Id int64 `json:"id"` //id 1173 Id int64 `json:"id"` //id
1160 Title string `json:"title"` //标题 1174 Title string `json:"title"` //标题
  1175 + AuthorId int64 `json:"authorId"` //发布人ID
1161 Author string `json:"author"` //发布人 1176 Author string `json:"author"` //发布人
1162 Images []string `json:"images"` //图片 1177 Images []string `json:"images"` //图片
1163 CreatedAt int64 `json:"createdAt"` //文章的创建日期 1178 CreatedAt int64 `json:"createdAt"` //文章的创建日期
1164 CountLove int `json:"countLove"` //点赞数量 1179 CountLove int `json:"countLove"` //点赞数量
1165 - CountComment int `json:"CountComment"` //评论数量 1180 + CountComment int `json:"countComment"` //评论数量
1166 Show int `json:"show"` //是否隐藏 [0显示、1不显示] 1181 Show int `json:"show"` //是否隐藏 [0显示、1不显示]
1167 Tags []string `json:"tags"` //标签 1182 Tags []string `json:"tags"` //标签
1168 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] 1183 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
@@ -143,8 +143,8 @@ with @@ -143,8 +143,8 @@ with
143 -- 过滤出可展示的文章id 143 -- 过滤出可展示的文章id
144 t_article_and_tag_2 as ( 144 t_article_and_tag_2 as (
145 select article_and_tag.article_id,article_and_tag.tag_id 145 select article_and_tag.article_id,article_and_tag.tag_id
146 - from article_and_tag  
147 - join article on article_and_tag.article_id = article.id 146 + from article
  147 + join article_and_tag on article_and_tag.article_id = article.id
148 where article.deleted_at=0 148 where article.deleted_at=0
149 and article.company_id = ? 149 and article.company_id = ?
150 and article."show" = ? 150 and article."show" = ?
@@ -337,7 +337,7 @@ func (repository *ArticleCommentRepository) Top5Comment(ctx context.Context, con @@ -337,7 +337,7 @@ func (repository *ArticleCommentRepository) Top5Comment(ctx context.Context, con
337 } 337 }
338 338
339 func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int, 339 func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
340 - topId int64, articleTitle string, contentLike string, fromUserName string, show int, createdAtRange [2]int64) (int, []*domain.ArticleCommentShow, error) { 340 + topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*domain.ArticleCommentShow, error) {
341 341
342 if size <= 0 { 342 if size <= 0 {
343 size = 20 343 size = 20
@@ -358,9 +358,9 @@ func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context, @@ -358,9 +358,9 @@ func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context,
358 condition = append(condition, "%"+contentLike+"%") 358 condition = append(condition, "%"+contentLike+"%")
359 } 359 }
360 360
361 - if len(fromUserName) > 0 {  
362 - where += ` and article_comment.from_user ->>'name' like ? `  
363 - condition = append(condition, "%"+fromUserName+"%") 361 + if fromUserId > 0 {
  362 + where += ` and article_comment.from_user_id = ? `
  363 + condition = append(condition, fromUserId)
364 } 364 }
365 if show > 0 { 365 if show > 0 {
366 where += ` and article_comment."show" =? ` 366 where += ` and article_comment."show" =? `
@@ -425,7 +425,6 @@ func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context, @@ -425,7 +425,6 @@ func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context,
425 ArticleTitle: val.ArticleTitle, 425 ArticleTitle: val.ArticleTitle,
426 Id: val.Id, 426 Id: val.Id,
427 FromUserId: val.FromUserId, 427 FromUserId: val.FromUserId,
428 - FromUser: val.FromUser,  
429 Content: val.Content, 428 Content: val.Content,
430 CountReply: val.CountReply, 429 CountReply: val.CountReply,
431 CountUserLove: val.CountUserLove, 430 CountUserLove: val.CountUserLove,
@@ -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 }
@@ -57,7 +57,6 @@ type ArticleCommentShow struct { @@ -57,7 +57,6 @@ type ArticleCommentShow struct {
57 TopId int64 57 TopId int64
58 ArticleTitle string // 文章标题 58 ArticleTitle string // 文章标题
59 FromUserId int64 // 评论填写人的id 59 FromUserId int64 // 评论填写人的id
60 - FromUser UserSimple // 评论填写人  
61 Content string // 评论内容 60 Content string // 评论内容
62 CountReply int // 回复数量 61 CountReply int // 回复数量
63 CountUserLove int // 用户点赞数量 62 CountUserLove int // 用户点赞数量
@@ -78,5 +77,5 @@ type ArticleCommentRepository interface { @@ -78,5 +77,5 @@ type ArticleCommentRepository interface {
78 Top5Comment(ctx context.Context, conn transaction.Conn, companyId int64, articleId int64) ([]*ArticleComment, error) 77 Top5Comment(ctx context.Context, conn transaction.Conn, companyId int64, articleId int64) ([]*ArticleComment, error)
79 // 特定的查询 78 // 特定的查询
80 CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int, 79 CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
81 - topId int64, articleTitle string, contentLike string, fromUserName string, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error) 80 + topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error)
82 } 81 }
@@ -2,8 +2,9 @@ package domain @@ -2,8 +2,9 @@ package domain
2 2
3 import ( 3 import (
4 "context" 4 "context"
5 - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"  
6 "reflect" 5 "reflect"
  6 +
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
7 ) 8 )
8 9
9 func OffsetLimit(page, size int) (offset int, limit int) { 10 func OffsetLimit(page, size int) (offset int, limit int) {
@@ -74,3 +74,19 @@ CREATE INDEX IF NOT EXISTS idx_message_system_company_id ON "public"."message_sy @@ -74,3 +74,19 @@ CREATE INDEX IF NOT EXISTS idx_message_system_company_id ON "public"."message_sy
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);