|
@@ -10,10 +10,12 @@ import (
|
|
|
"hongze/hongze_yb/services"
|
|
|
"hongze/hongze_yb/services/community"
|
|
|
"hongze/hongze_yb/services/user"
|
|
|
+ "hongze/hongze_yb/services/wx_app"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
"io/ioutil"
|
|
|
"os"
|
|
|
"path"
|
|
|
+ "strconv"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -88,7 +90,6 @@ func QuestionAsk(c *gin.Context) {
|
|
|
response.Fail("参数有误", c)
|
|
|
return
|
|
|
}
|
|
|
- // TODO:敏感词校验
|
|
|
if req.QuestionContent == "" {
|
|
|
response.Fail("内容不可为空", c)
|
|
|
return
|
|
@@ -98,7 +99,18 @@ func QuestionAsk(c *gin.Context) {
|
|
|
response.Fail("内容不可超过50个字符", c)
|
|
|
return
|
|
|
}
|
|
|
+ // 敏感词校验, 只有小程序的用户才能走敏感词过滤接口
|
|
|
userinfo := user.GetInfoByClaims(c)
|
|
|
+ if userinfo.RecordInfo.OpenID != "" && userinfo.RecordInfo.CreatePlatform == 6 {
|
|
|
+ checkResult, e := wx_app.MsgSecCheck(userinfo.RecordInfo.OpenID, req.QuestionContent)
|
|
|
+ if e == nil {
|
|
|
+ if checkResult.Result != nil && checkResult.Result.Suggest != "pass" {
|
|
|
+ errMsg := "含有违禁词, 不允许发布: " + checkResult.Result.Suggest + ", 命中标签: " + strconv.Itoa(checkResult.Result.Label)
|
|
|
+ response.FailMsg("含有违禁词, 不允许发布", errMsg, c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if err := community.CreateQuestion(int(userinfo.UserID), userinfo.Mobile, userinfo.RealName, req.QuestionContent); err != nil {
|
|
|
response.FailMsg("提交失败", "QuestionAsk ErrMsg:"+err.Error(), c)
|
|
|
return
|