作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -7,6 +7,9 @@
管理后台“易数家“前端入口:https://digital-front-platform-dev.fjmaimaimai.com/
跳转后的实际管理后台地址: https://sumifcc-x-front-test.sumifcc.com
样例账号 18860183050 密码 123456
### 可设置环境变量
- DataSource
数据库连接,样例
... ...
... ... @@ -5,6 +5,7 @@ import (
"strconv"
"strings"
"text/template"
"unicode"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -34,6 +35,19 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext)
// 创建新文章
func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
// 检查文字数量
wordNum := 0
for i := range req.Section {
for _, word := range req.Section[i] {
if !unicode.IsSpace(word) {
wordNum++
}
}
}
if wordNum > 1000 {
return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
}
// 检查发布人
author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId)
if err != nil {
... ...
... ... @@ -36,8 +36,8 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
if req.Size > 40 {
req.Size = 40
if req.Size > 100 {
req.Size = 100
}
queryOption := domain.NewQueryOptions().
... ... @@ -119,7 +119,7 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
}
//获取回复的评论
cntReply, reply := l.listCommentReply(item.Comment.Id, flagMap)
cntReply, reply := l.listCommentReply(companyInfo.Id, item.Comment.Id, flagMap)
resp.List[i] = item
resp.List[i].Reply = reply
resp.List[i].TotalReply = cntReply
... ... @@ -128,9 +128,9 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
}
// listCommentReply
func (l *MiniListArticleCommentLogic) listCommentReply(commentId int64, loveFlagMap map[int64]struct{}) (cnt int64, replyList []types.ArticleCommentItem) {
func (l *MiniListArticleCommentLogic) listCommentReply(companyId int64, commentId int64, loveFlagMap map[int64]struct{}) (cnt int64, replyList []types.ArticleCommentItem) {
var conn = l.svcCtx.DefaultDBConn()
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, commentId)
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, companyId)
if err != nil {
return 0, []types.ArticleCommentItem{}
}
... ...
... ... @@ -29,12 +29,13 @@ func NewMiniCompanySearchJoinedLogic(ctx context.Context, svcCtx *svc.ServiceCon
func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.CompanySearchRequest) (resp *types.CompanySearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
companyList []*domain.Company
total int64
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
companyIds []int64
conn = l.svcCtx.DefaultDBConn()
companyList []*domain.Company
total int64
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
companyJoinedList []int64
companyJoiningList []int64
)
queryOptions := domain.NewQueryOptions()
if req.Page != 0 {
... ... @@ -53,15 +54,22 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
WithFindOnly())
lo.ForEach(users, func(item *domain.User, index int) {
companyIds = append(companyIds, item.CompanyId)
companyJoinedList = append(companyJoinedList, item.CompanyId)
})
_, users, _ = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
MustWithKV("phone", user.Phone).
MustWithKV("auditStatus", []int{domain.UserAuditStatusWait}).
WithFindOnly())
lo.ForEach(users, func(item *domain.User, index int) {
companyJoiningList = append(companyJoiningList, item.CompanyId)
})
if req.Flag == 1 {
total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("ids", companyIds))
total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("ids", companyJoinedList))
if err != nil {
return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
}
} else if req.Flag == 2 {
total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("excludeIds", companyIds))
total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("excludeIds", companyJoinedList))
if err != nil {
return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
}
... ... @@ -73,9 +81,13 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan
}
lo.ForEach(companyList, func(item *domain.Company, index int) {
company := NewCompany(item)
if lo.Contains(companyIds, company.Id) {
company.JoinedFlag = 2
if lo.Contains(companyJoinedList, company.Id) {
company.JoinedFlag = 1
}
if lo.Contains(companyJoiningList, company.Id) {
company.JoinedFlag = 0
}
resp.List = append(resp.List, company)
})
resp.Total = total
... ...
... ... @@ -171,8 +171,8 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).
Where("company_id=?", companyId).
Where("author_id in (?)", authors).
Where(fmt.Sprintf("target_user=0 or who_read @>'[%d]'", whoRead)).
Where("author_id in (?)", append(authors, whoRead)). // 包含自己的文章
Where(fmt.Sprintf("author_id = %d or target_user=0 or who_read @>'[%d]'", whoRead, whoRead)).
Where("show = 1")
if lastId > 0 {
tx.Where("id < ?", lastId)
... ...
... ... @@ -2,8 +2,9 @@ package domain
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"reflect"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
func OffsetLimit(page, size int) (offset int, limit int) {
... ...