ziwen hai 1 ano
pai
achega
bece382ade
Modificáronse 2 ficheiros con 12 adicións e 7 borrados
  1. 4 4
      controllers/yanxuan_special.go
  2. 8 3
      models/wechat.go

+ 4 - 4
controllers/yanxuan_special.go

@@ -289,10 +289,10 @@ func (this *YanxuanSpecialController) Save() {
 		item.Status = 2
 	}
 
-	detail := models.WxCheckContent(req.Content)
-	if detail.Errcode != 0 {
-		br.Msg = "文章内容含有违法违规内容,关键词:"+detail.KeyWord
-		br.ErrMsg = "文章内容含有违法违规内容,关键词:"+detail.KeyWord
+	errCode, keyword := models.WxCheckContent(req.Content)
+	if errCode != 0 {
+		br.Msg = "文章内容含有违法违规内容,关键词:"+keyword
+		br.ErrMsg = "文章内容含有违法违规内容,关键词:"+keyword
 		return
 	}
 	if req.Id == 0 {

+ 8 - 3
models/wechat.go

@@ -202,7 +202,7 @@ type WxCheckContentJson struct {
 	Scope        string                   `json:"scope"`
 	Errcode      int                      `json:"errcode"`
 	Errmsg       string                   `json:"errmsg"`
-	Detail       WxCheckContentJsonDetail `json:"det"`
+	Detail       []WxCheckContentJsonDetail `json:"det"`
 }
 
 type WxCheckContentJsonDetail struct {
@@ -213,7 +213,7 @@ type WxCheckContentJsonDetail struct {
 	Errcode  int
 }
 
-func WxCheckContent(content string) (detail WxCheckContentJsonDetail) {
+func WxCheckContent(content string) (errCode int, keyWord string) {
 	accessToken, err := GetWxAccessToken()
 	if err != nil {
 		utils.FileLog.Info("GetWxAccessToken Err:%s", err.Error())
@@ -233,6 +233,11 @@ func WxCheckContent(content string) (detail WxCheckContentJsonDetail) {
 		fmt.Println("Unmarshal Err:", err.Error())
 		return
 	}
+	if len(item.Detail) > 0{
+		for _, v := range item.Detail {
+			keyWord += v.KeyWord
+		}
+	}
 	fmt.Println(result)
-	return item.Detail
+	return
 }