正在显示
5 个修改的文件
包含
25 行增加
和
9 行删除
@@ -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,7 +5,7 @@ import ( | @@ -5,7 +5,7 @@ import ( | ||
5 | "strconv" | 5 | "strconv" |
6 | "strings" | 6 | "strings" |
7 | "text/template" | 7 | "text/template" |
8 | - "unicode" | 8 | + "unicode/utf8" |
9 | 9 | ||
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/svc" |
11 | "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" |
@@ -39,13 +39,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -39,13 +39,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
39 | // 检查文字数量 | 39 | // 检查文字数量 |
40 | wordNum := 0 | 40 | wordNum := 0 |
41 | for i := range req.Section { | 41 | for i := range req.Section { |
42 | - for _, word := range req.Section[i] { | ||
43 | - if !unicode.IsSpace(word) { | ||
44 | - wordNum++ | ||
45 | - } | ||
46 | - } | 42 | + num := utf8.RuneCountInString(req.Section[i]) |
43 | + wordNum += num | ||
47 | } | 44 | } |
48 | - if wordNum > 1000 { | 45 | + if wordNum >= 1000 { |
49 | return nil, xerr.NewErrMsgErr("最多只能输入1000字", err) | 46 | return nil, xerr.NewErrMsgErr("最多只能输入1000字", err) |
50 | } | 47 | } |
51 | // 检查发布人 | 48 | // 检查发布人 |
@@ -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 { |
@@ -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 { |
-
请 注册 或 登录 后发表评论