|
@@ -37,7 +37,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR |
|
@@ -37,7 +37,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR |
37
|
var conn = l.svcCtx.DefaultDBConn()
|
37
|
var conn = l.svcCtx.DefaultDBConn()
|
38
|
err = l.validateTextLimit(req)
|
38
|
err = l.validateTextLimit(req)
|
39
|
if err != nil {
|
39
|
if err != nil {
|
40
|
- return nil, xerr.NewErrMsg(err.Error())
|
40
|
+ return nil, err
|
41
|
}
|
41
|
}
|
42
|
// 检查发布人
|
42
|
// 检查发布人
|
43
|
author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId)
|
43
|
author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId)
|
|
@@ -216,13 +216,19 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR |
|
@@ -216,13 +216,19 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR |
216
|
|
216
|
|
217
|
// validateTextLimit 验证输入文本长度
|
217
|
// validateTextLimit 验证输入文本长度
|
218
|
func (l *MiniCreateArticleLogic) validateTextLimit(req *types.MiniArticleCreateRequest) error {
|
218
|
func (l *MiniCreateArticleLogic) validateTextLimit(req *types.MiniArticleCreateRequest) error {
|
|
|
219
|
+
|
|
|
220
|
+ titleWordNum := utf8.RuneCountInString(req.Title)
|
|
|
221
|
+ if titleWordNum > 64 {
|
|
|
222
|
+ return xerr.NewErrMsg("标题最多只能输入64字")
|
|
|
223
|
+ }
|
219
|
wordNum := 0
|
224
|
wordNum := 0
|
220
|
for i := range req.Section {
|
225
|
for i := range req.Section {
|
221
|
num := utf8.RuneCountInString(req.Section[i])
|
226
|
num := utf8.RuneCountInString(req.Section[i])
|
222
|
wordNum += num
|
227
|
wordNum += num
|
223
|
}
|
228
|
}
|
224
|
if wordNum > 1000 {
|
229
|
if wordNum > 1000 {
|
225
|
- return xerr.NewErrMsg("最多只能输入1000字")
|
230
|
+ return xerr.NewErrMsg("内容最多只能输入1000字")
|
226
|
}
|
231
|
}
|
|
|
232
|
+
|
227
|
return nil
|
233
|
return nil
|
228
|
} |
234
|
} |