ziwen 1 年之前
父節點
當前提交
0b354931ba
共有 6 個文件被更改,包括 95 次插入15 次删除
  1. 65 6
      controllers/yanxuan_special.go
  2. 1 0
      go.mod
  3. 15 2
      go.sum
  4. 4 0
      models/cygx_yanxuan_special.go
  5. 1 7
      models/wechat.go
  6. 9 0
      routers/commentsRouter.go

+ 65 - 6
controllers/yanxuan_special.go

@@ -289,12 +289,6 @@ func (this *YanxuanSpecialController) Save() {
 		item.Status = 2
 	}
 
-	errCode, keyword := models.WxCheckContent(req.Content)
-	if errCode != 0 {
-		br.Msg = "文章内容含有违法违规内容,关键词:"+keyword
-		br.ErrMsg = "文章内容含有违法违规内容,关键词:"+keyword
-		return
-	}
 	if req.Id == 0 {
 		_, err = models.AddCygxYanxuanSpecial(&item)
 		if err != nil {
@@ -923,4 +917,69 @@ func (this *YanxuanSpecialController) Delete() {
 	br.Msg = "删除成功"
 	br.Ret = 200
 	br.Success = true
+}
+
+// @Title 专栏文章敏感词检测
+// @Description 专栏文章敏感词检测
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /check [post]
+func (this *YanxuanSpecialController) Check() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.CygxYanxuanSpecialCheckReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Content == "" {
+		br.Msg = "请输入内容"
+		return
+	}
+	//itemToken, err := services.WxGetToken()
+	//if err != nil {
+	//	br.Msg = "GetWxAccessToken Err:" + err.Error()
+	//	return
+	//}
+	//if itemToken.AccessToken == "" {
+	//	br.Msg = "accessToken is empty"
+	//	return
+	//}
+	//cli := weapp.NewClient(utils.WxAppId, utils.WxAppSecret)
+	//commerr, err := cli.MSGSecCheck(req.Content)
+	//if err != nil {
+	//	br.Msg = "内容校验失败!"
+	//	br.ErrMsg = "内容校验失败,Err:" + err.Error()
+	//	return
+	//}
+	//if commerr.ErrCode != 0 {
+	//	br.Msg = "内容违规,请重新提交!"
+	//	br.ErrMsg = "文字内容违规,Err:" + commerr.ErrMSG
+	//	return
+	//}
+
+	errCode, keyword := models.WxCheckContent(req.Content)
+	if errCode != 0 {
+		br.Msg = "文章内容含有违法违规内容,关键词:"+keyword
+		br.ErrMsg = "文章内容含有违法违规内容,关键词:"+keyword
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "校验成功"
 }

+ 1 - 0
go.mod

@@ -11,6 +11,7 @@ require (
 	github.com/elastic/go-elasticsearch/v7 v7.17.1
 	github.com/go-sql-driver/mysql v1.6.0
 	github.com/medivhzhan/weapp/v2 v2.5.0
+	github.com/medivhzhan/weapp/v3 v3.6.19
 	github.com/olivere/elastic/v7 v7.0.32
 	github.com/pdfcpu/pdfcpu v0.3.13
 	github.com/rdlucklib/rdluck_tools v1.0.3

+ 15 - 2
go.sum

@@ -99,6 +99,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
 github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
+github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
+github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
 github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
 github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
@@ -247,8 +249,14 @@ github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0Q
 github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
 github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
+github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
+github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
 github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
 github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
+github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
+github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
 github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
@@ -257,6 +265,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/medivhzhan/weapp/v2 v2.5.0 h1:WfgSHdZ34xM47w4b/5nGTSzaqHo1uizdDDKJsCRB2bY=
 github.com/medivhzhan/weapp/v2 v2.5.0/go.mod h1:lcP2Go0ow4ElqGsEQwEeyTZiiEhr+lC5zMxGZGA7Bsc=
+github.com/medivhzhan/weapp/v3 v3.6.19 h1:SXY1H1AdX4RvRyuCTb5+sJxEMisyoxHLL87aIwuos/g=
+github.com/medivhzhan/weapp/v3 v3.6.19/go.mod h1:DBlnuMNGIcDYSDaM8JnBIT14I+OqMaMNm9QU8HvhhMU=
 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
 github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
 github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
@@ -265,8 +275,9 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4
 github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
 github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
-github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
 github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
+github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
@@ -525,8 +536,10 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
 golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

+ 4 - 0
models/cygx_yanxuan_special.go

@@ -172,4 +172,8 @@ func DelYanxuanSpecial(id int) (err error) {
 	sql = `DELETE FROM cygx_yanxuan_special WHERE id = ? `
 	_, err = o.Raw(sql, id).Exec()
 	return
+}
+
+type CygxYanxuanSpecialCheckReq struct {
+	Content string // 内容
 }

+ 1 - 7
models/wechat.go

@@ -194,15 +194,9 @@ func WxUsersGet() (openIdStr string) {
 }
 
 type WxCheckContentJson struct {
-	AccessToken  string                   `json:"access_token"`
-	ExpiresIn    int                      `json:"expires_in"`
-	RefreshToken string                   `json:"refresh_token"`
-	Openid       string                   `json:"openid"`
-	Unionid      string                   `json:"unionid"`
-	Scope        string                   `json:"scope"`
+	Detail       []WxCheckContentJsonDetail `json:"detail"`
 	Errcode      int                      `json:"errcode"`
 	Errmsg       string                   `json:"errmsg"`
-	Detail       []WxCheckContentJsonDetail `json:"det"`
 }
 
 type WxCheckContentJsonDetail struct {

+ 9 - 0
routers/commentsRouter.go

@@ -1699,6 +1699,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Check",
+            Router: `/check`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
         beego.ControllerComments{
             Method: "Collect",