...
|
...
|
@@ -37,7 +37,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR |
|
|
var conn = l.svcCtx.DefaultDBConn()
|
|
|
err = l.validateTextLimit(req)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsg(err.Error())
|
|
|
return nil, err
|
|
|
}
|
|
|
// 检查发布人
|
|
|
author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId)
|
...
|
...
|
@@ -216,13 +216,19 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR |
|
|
|
|
|
// validateTextLimit 验证输入文本长度
|
|
|
func (l *MiniCreateArticleLogic) validateTextLimit(req *types.MiniArticleCreateRequest) error {
|
|
|
|
|
|
titleWordNum := utf8.RuneCountInString(req.Title)
|
|
|
if titleWordNum > 64 {
|
|
|
return xerr.NewErrMsg("标题最多只能输入64字")
|
|
|
}
|
|
|
wordNum := 0
|
|
|
for i := range req.Section {
|
|
|
num := utf8.RuneCountInString(req.Section[i])
|
|
|
wordNum += num
|
|
|
}
|
|
|
if wordNum > 1000 {
|
|
|
return xerr.NewErrMsg("最多只能输入1000字")
|
|
|
return xerr.NewErrMsg("内容最多只能输入1000字")
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
} |
...
|
...
|
|