作者 tangxvhui

Merge branch 'dev' into test

@@ -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 数据库连接,样例
@@ -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"
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,19 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) @@ -34,6 +35,19 @@ 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 + for _, word := range req.Section[i] {
  43 + if !unicode.IsSpace(word) {
  44 + wordNum++
  45 + }
  46 + }
  47 + }
  48 + if wordNum > 1000 {
  49 + return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
  50 + }
37 // 检查发布人 51 // 检查发布人
38 author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId) 52 author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId)
39 if err != nil { 53 if err != nil {
@@ -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 }
@@ -29,12 +29,13 @@ func NewMiniCompanySearchJoinedLogic(ctx context.Context, svcCtx *svc.ServiceCon @@ -29,12 +29,13 @@ func NewMiniCompanySearchJoinedLogic(ctx context.Context, svcCtx *svc.ServiceCon
29 29
30 func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.CompanySearchRequest) (resp *types.CompanySearchResponse, err error) { 30 func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.CompanySearchRequest) (resp *types.CompanySearchResponse, err error) {
31 var ( 31 var (
32 - conn = l.svcCtx.DefaultDBConn()  
33 - companyList []*domain.Company  
34 - total int64  
35 - userToken = contextdata.GetUserTokenFromCtx(l.ctx)  
36 - user *domain.User  
37 - companyIds []int64 32 + conn = l.svcCtx.DefaultDBConn()
  33 + companyList []*domain.Company
  34 + total int64
  35 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  36 + user *domain.User
  37 + companyJoinedList []int64
  38 + companyJoiningList []int64
38 ) 39 )
39 queryOptions := domain.NewQueryOptions() 40 queryOptions := domain.NewQueryOptions()
40 if req.Page != 0 { 41 if req.Page != 0 {
@@ -53,15 +54,22 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan @@ -53,15 +54,22 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan
53 MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}). 54 MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
54 WithFindOnly()) 55 WithFindOnly())
55 lo.ForEach(users, func(item *domain.User, index int) { 56 lo.ForEach(users, func(item *domain.User, index int) {
56 - companyIds = append(companyIds, item.CompanyId) 57 + companyJoinedList = append(companyJoinedList, item.CompanyId)
  58 + })
  59 + _, users, _ = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
  60 + MustWithKV("phone", user.Phone).
  61 + MustWithKV("auditStatus", []int{domain.UserAuditStatusWait}).
  62 + WithFindOnly())
  63 + lo.ForEach(users, func(item *domain.User, index int) {
  64 + companyJoiningList = append(companyJoiningList, item.CompanyId)
57 }) 65 })
58 if req.Flag == 1 { 66 if req.Flag == 1 {
59 - total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("ids", companyIds)) 67 + total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("ids", companyJoinedList))
60 if err != nil { 68 if err != nil {
61 return nil, xerr.NewErrMsgErr("公司列表获取失败", err) 69 return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
62 } 70 }
63 } else if req.Flag == 2 { 71 } else if req.Flag == 2 {
64 - total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("excludeIds", companyIds)) 72 + total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("excludeIds", companyJoinedList))
65 if err != nil { 73 if err != nil {
66 return nil, xerr.NewErrMsgErr("公司列表获取失败", err) 74 return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
67 } 75 }
@@ -73,9 +81,13 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan @@ -73,9 +81,13 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan
73 } 81 }
74 lo.ForEach(companyList, func(item *domain.Company, index int) { 82 lo.ForEach(companyList, func(item *domain.Company, index int) {
75 company := NewCompany(item) 83 company := NewCompany(item)
76 - if lo.Contains(companyIds, company.Id) { 84 + company.JoinedFlag = 2
  85 + if lo.Contains(companyJoinedList, company.Id) {
77 company.JoinedFlag = 1 86 company.JoinedFlag = 1
78 } 87 }
  88 + if lo.Contains(companyJoiningList, company.Id) {
  89 + company.JoinedFlag = 0
  90 + }
79 resp.List = append(resp.List, company) 91 resp.List = append(resp.List, company)
80 }) 92 })
81 resp.Total = total 93 resp.Total = total
@@ -171,8 +171,8 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex @@ -171,8 +171,8 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex
171 queryFunc := func() (interface{}, error) { 171 queryFunc := func() (interface{}, error) {
172 tx = tx.Model(&ms). 172 tx = tx.Model(&ms).
173 Where("company_id=?", companyId). 173 Where("company_id=?", companyId).
174 - Where("author_id in (?)", authors).  
175 - Where(fmt.Sprintf("target_user=0 or who_read @>'[%d]'", whoRead)). 174 + Where("author_id in (?)", append(authors, whoRead)). // 包含自己的文章
  175 + Where(fmt.Sprintf("author_id = %d or target_user=0 or who_read @>'[%d]'", whoRead, whoRead)).
176 Where("show = 1") 176 Where("show = 1")
177 if lastId > 0 { 177 if lastId > 0 {
178 tx.Where("id < ?", lastId) 178 tx.Where("id < ?", lastId)
@@ -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) {