|
@@ -6,6 +6,7 @@ import (
|
|
|
"github.com/zeromicro/go-zero/core/errorx"
|
|
|
"wechat-api/ent"
|
|
|
"wechat-api/ent/wxcarduser"
|
|
|
+ "wechat-api/hook/wechat"
|
|
|
"wechat-api/internal/svc"
|
|
|
"wechat-api/internal/types"
|
|
|
"wechat-api/internal/utils/dberrorhandler"
|
|
@@ -45,6 +46,28 @@ func (l *UpdateApiWxCardUserLogic) UpdateApiWxCardUser(req *types.WxCardUserInfo
|
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
|
}
|
|
|
|
|
|
+ // 这里检查昵称的是否含有敏感词
|
|
|
+ AppId := l.svcCtx.Config.Miniprogram.Appid
|
|
|
+ Secret := l.svcCtx.Config.Miniprogram.Secret
|
|
|
+ app, err := wechat.NewClient(AppId, Secret)
|
|
|
+ if err != nil {
|
|
|
+ return nil, errorx.NewApiInternalError("init wechat miniprogram failed")
|
|
|
+ }
|
|
|
+ result, err := app.Security.MsgSecCheck(
|
|
|
+ wxCardUser.OpenID,
|
|
|
+ 1,
|
|
|
+ 2,
|
|
|
+ nickname,
|
|
|
+ nickname,
|
|
|
+ "",
|
|
|
+ "",
|
|
|
+ )
|
|
|
+ if err != nil {
|
|
|
+ return nil, errorx.NewInternalError("网络错误,请稍后重拾")
|
|
|
+ }
|
|
|
+ if result.Result.Label != 100 {
|
|
|
+ return nil, errorx.NewInvalidArgumentError("昵称内容不合法,请修改后重试")
|
|
|
+ }
|
|
|
if wxCardUser != nil {
|
|
|
query := l.svcCtx.DB.WxCardUser.UpdateOneID(userId)
|
|
|
if nickname != "" {
|