Explorar o código

Merge branch 'yb/5.0' into debug

hsun %!s(int64=2) %!d(string=hai) anos
pai
achega
38fe822149
Modificáronse 2 ficheiros con 6 adicións e 1 borrados
  1. 5 0
      controller/community/question.go
  2. 1 1
      services/community/question.go

+ 5 - 0
controller/community/question.go

@@ -92,6 +92,11 @@ func QuestionAsk(c *gin.Context) {
 		response.Fail("内容不可为空", c)
 		return
 	}
+	contentRune := []rune(req.QuestionContent)
+	if len(contentRune) > 50 {
+		response.Fail("内容不可超过50个字符", c)
+		return
+	}
 	userinfo := user.GetInfoByClaims(c)
 	if err := community.CreateQuestion(int(userinfo.UserID), userinfo.Mobile, userinfo.RealName, req.QuestionContent); err != nil {
 		response.FailMsg("提交失败", "QuestionAsk ErrMsg:"+err.Error(), c)

+ 1 - 1
services/community/question.go

@@ -165,7 +165,7 @@ func GetQuestionDetail(questionId int, userInfo user.UserInfo) (item *response.C
 func CreateQuestion(userId int, mobile, realName, content string) (err error) {
 	// 获取用户公众号openid, 获取不到则置空
 	userRecord, e := user_record.GetByUserId(userId, utils.USER_RECORD_PLATFORM_RDDP)
-	if e != nil && e == utils.ErrNoRow {
+	if e != nil && e != utils.ErrNoRow {
 		err = errors.New("获取用户公众号openid失败 Err:" + e.Error())
 		return
 	}