作者 tangxvhui

调整字数检查

... ... @@ -28,6 +28,9 @@ func NewMiniArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext
// MiniArticleSearchMe 获取我发布的文章
func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
}
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
MustWithKV("authorId", req.AuthorId)
... ...
... ... @@ -5,7 +5,7 @@ import (
"strconv"
"strings"
"text/template"
"unicode"
"unicode/utf8"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -39,13 +39,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
// 检查文字数量
wordNum := 0
for i := range req.Section {
for _, word := range req.Section[i] {
if !unicode.IsSpace(word) {
wordNum++
}
}
num := utf8.RuneCountInString(req.Section[i])
wordNum += num
}
if wordNum > 1000 {
if wordNum >= 1000 {
return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
}
// 检查发布人
... ...
... ... @@ -28,7 +28,9 @@ func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceCo
// 查询我的草稿箱内容列表
func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
}
queryOption := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
MustWithKV("authorId", req.AuthorId)
... ...
... ... @@ -29,7 +29,9 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte
func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
}
cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId,
req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size)
if err != nil {
... ...
... ... @@ -3,6 +3,7 @@ package article
import (
"context"
"strconv"
"unicode/utf8"
"strings"
... ... @@ -42,6 +43,17 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
//TargetUser 设定为分发给所有人,清空 WhoRead
req.WhoRead = make([]int64, 0)
}
// 检查文字数量
wordNum := 0
for i := range req.Section {
num := utf8.RuneCountInString(req.Section[i].Content)
wordNum += num
}
if wordNum >= 1000 {
return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
}
// 获取当前用户信息
userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken})
if err != nil {
... ...