diff --git a/CHANGELOG.md b/CHANGELOG.md index 16c66018..82629202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v1.0.111 + +- update [wechatopen](service%2Fwechatopen) +- update [wechatminiprogram](service%2Fwechatminiprogram) + ## v1.0.110 - add [caiyunapp](service%2Fcaiyunapp) diff --git a/library.go b/library.go index a9352d1b..d2b9fb40 100644 --- a/library.go +++ b/library.go @@ -1,5 +1,5 @@ package go_library func Version() string { - return "1.0.110" + return "1.0.111" } diff --git a/service/wechatminiprogram/wxa.getuserriskrank.go b/service/wechatminiprogram/wxa.getuserriskrank.go index 0b69174d..87fe61d7 100644 --- a/service/wechatminiprogram/wxa.getuserriskrank.go +++ b/service/wechatminiprogram/wxa.getuserriskrank.go @@ -1 +1,40 @@ package wechatminiprogram + +import ( + "context" + "fmt" + "github.com/dtapps/go-library/utils/gojson" + "github.com/dtapps/go-library/utils/gorequest" + "net/http" +) + +type WxaGetUserRiskRankResponse struct { + Errcode int `json:"errcode"` // 错误码 + Errmsg string `json:"errmsg"` // 错误信息 + RiskRank int `json:"risk_rank"` // 用户风险等级,合法值为0,1,2,3,4,数字越大风险越高。 + UnoinId int64 `json:"unoin_id"` // 唯一请求标识,标记单次请求 +} + +type WxaGetUserRiskRankResult struct { + Result WxaGetUserRiskRankResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newWxaGetUserRiskRankResult(result WxaGetUserRiskRankResponse, body []byte, http gorequest.Response, err error) *WxaGetUserRiskRankResult { + return &WxaGetUserRiskRankResult{Result: result, Body: body, Http: http, Err: err} +} + +// WxaGetUserRiskRank 获取用户安全等级 +// https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/safety-control-capability/getUserRiskRank.html +func (c *Client) WxaGetUserRiskRank(ctx context.Context, notMustParams ...gorequest.Params) *WxaGetUserRiskRankResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求 + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/getuserriskrank?access_token=%s", c.getAccessToken(ctx)), params, http.MethodPost) + // 定义 + var response WxaGetUserRiskRankResponse + err = gojson.Unmarshal(request.ResponseBody, &response) + return newWxaGetUserRiskRankResult(response, request.ResponseBody, request, err) +} diff --git a/service/wechatminiprogram/wxa.media_check_async.go b/service/wechatminiprogram/wxa.media_check_async.go index 0b69174d..886ba198 100644 --- a/service/wechatminiprogram/wxa.media_check_async.go +++ b/service/wechatminiprogram/wxa.media_check_async.go @@ -1 +1,57 @@ package wechatminiprogram + +import ( + "context" + "fmt" + "github.com/dtapps/go-library/utils/gojson" + "github.com/dtapps/go-library/utils/gorequest" + "net/http" +) + +type WxaMediaCheckAsyncResponse struct { + Errcode int `json:"errcode"` // 错误码 + Errmsg string `json:"errmsg"` // 错误信息 + TraceId string `json:"trace_id"` // 唯一请求标识,标记单次请求,用于匹配异步推送结果 + Result struct { + Suggest string `json:"suggest"` // 小程序的username + Label int `json:"label"` // 小程序的username + } `json:"result"` // 小程序的username + ToUserName string `json:"ToUserName"` // 小程序的username + FromUserName string `json:"FromUserName"` // 平台推送服务UserName + CreateTime int `json:"CreateTime"` // 发送时间 + MsgType string `json:"MsgType"` // 默认为:event + Event string `json:"Event"` // 默认为:wxa_media_check + Appid string `json:"appid"` // 小程序的appid + Version int `json:"version"` // 小程序的username + Detail []struct { + Strategy string `json:"strategy"` // 小程序的username + Errcode int `json:"errcode"` // 小程序的username + Suggest string `json:"suggest"` // 小程序的username + Label int `json:"label"` // 小程序的username + Prob int `json:"prob"` // 小程序的username + } `json:"detail"` // 小程序的username +} + +type WxaMediaCheckAsyncResult struct { + Result WxaMediaCheckAsyncResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newWxaMediaCheckAsyncResult(result WxaMediaCheckAsyncResponse, body []byte, http gorequest.Response, err error) *WxaMediaCheckAsyncResult { + return &WxaMediaCheckAsyncResult{Result: result, Body: body, Http: http, Err: err} +} + +// WxaMediaCheckAsync 音视频内容安全识别 +// https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/sec-check/mediaCheckAsync.html +func (c *Client) WxaMediaCheckAsync(ctx context.Context, notMustParams ...gorequest.Params) *WxaMediaCheckAsyncResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求 + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/media_check_async?access_token=%s", c.getAccessToken(ctx)), params, http.MethodPost) + // 定义 + var response WxaMediaCheckAsyncResponse + err = gojson.Unmarshal(request.ResponseBody, &response) + return newWxaMediaCheckAsyncResult(response, request.ResponseBody, request, err) +} diff --git a/service/wechatminiprogram/wxa.msg_sec_check.go b/service/wechatminiprogram/wxa.msg_sec_check.go index 0b69174d..bbe488fd 100644 --- a/service/wechatminiprogram/wxa.msg_sec_check.go +++ b/service/wechatminiprogram/wxa.msg_sec_check.go @@ -1 +1,52 @@ package wechatminiprogram + +import ( + "context" + "fmt" + "github.com/dtapps/go-library/utils/gojson" + "github.com/dtapps/go-library/utils/gorequest" + "net/http" +) + +type WxaMsgSecCheckResponse struct { + Errcode int `json:"errcode"` + Errmsg string `json:"errmsg"` + Result struct { + Suggest string `json:"suggest"` + Label int `json:"label"` + } `json:"result"` + Detail []struct { + Strategy string `json:"strategy"` + Errcode int `json:"errcode"` + Suggest string `json:"suggest"` + Label int `json:"label"` + Prob int `json:"prob,omitempty"` + Level int `json:"level,omitempty"` + Keyword string `json:"keyword,omitempty"` + } `json:"detail"` + TraceId string `json:"trace_id"` +} + +type WxaMsgSecCheckResult struct { + Result WxaMsgSecCheckResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newWxaMsgSecCheckResult(result WxaMsgSecCheckResponse, body []byte, http gorequest.Response, err error) *WxaMsgSecCheckResult { + return &WxaMsgSecCheckResult{Result: result, Body: body, Http: http, Err: err} +} + +// WxaMsgSecCheck 文本内容安全识别 +// https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.getUnlimited.html +func (c *Client) WxaMsgSecCheck(ctx context.Context, notMustParams ...gorequest.Params) *WxaMsgSecCheckResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求 + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/msg_sec_check?access_token=%s", c.getAccessToken(ctx)), params, http.MethodPost) + // 定义 + var response WxaMsgSecCheckResponse + err = gojson.Unmarshal(request.ResponseBody, &response) + return newWxaMsgSecCheckResult(response, request.ResponseBody, request, err) +} diff --git a/service/wechatopen/wxa.getuserriskrank.go b/service/wechatopen/wxa.getuserriskrank.go new file mode 100644 index 00000000..8d6b2a5b --- /dev/null +++ b/service/wechatopen/wxa.getuserriskrank.go @@ -0,0 +1,40 @@ +package wechatopen + +import ( + "context" + "fmt" + "github.com/dtapps/go-library/utils/gojson" + "github.com/dtapps/go-library/utils/gorequest" + "net/http" +) + +type WxaGetUserRiskRankResponse struct { + Errcode int `json:"errcode"` // 错误码 + Errmsg string `json:"errmsg"` // 错误信息 + RiskRank int `json:"risk_rank"` // 用户风险等级,合法值为0,1,2,3,4,数字越大风险越高。 + UnoinId int64 `json:"unoin_id"` // 唯一请求标识,标记单次请求 +} + +type WxaGetUserRiskRankResult struct { + Result WxaGetUserRiskRankResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newWxaGetUserRiskRankResult(result WxaGetUserRiskRankResponse, body []byte, http gorequest.Response, err error) *WxaGetUserRiskRankResult { + return &WxaGetUserRiskRankResult{Result: result, Body: body, Http: http, Err: err} +} + +// WxaGetUserRiskRank 获取用户安全等级 +// https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/safety-control-capability/getUserRiskRank.html +func (c *Client) WxaGetUserRiskRank(ctx context.Context, notMustParams ...gorequest.Params) *WxaGetUserRiskRankResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求 + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/getuserriskrank?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) + // 定义 + var response WxaGetUserRiskRankResponse + err = gojson.Unmarshal(request.ResponseBody, &response) + return newWxaGetUserRiskRankResult(response, request.ResponseBody, request, err) +} diff --git a/service/wechatopen/wxa.media_check_async.go b/service/wechatopen/wxa.media_check_async.go new file mode 100644 index 00000000..eb4cf5a9 --- /dev/null +++ b/service/wechatopen/wxa.media_check_async.go @@ -0,0 +1,57 @@ +package wechatopen + +import ( + "context" + "fmt" + "github.com/dtapps/go-library/utils/gojson" + "github.com/dtapps/go-library/utils/gorequest" + "net/http" +) + +type WxaMediaCheckAsyncResponse struct { + Errcode int `json:"errcode"` // 错误码 + Errmsg string `json:"errmsg"` // 错误信息 + TraceId string `json:"trace_id"` // 唯一请求标识,标记单次请求,用于匹配异步推送结果 + Result struct { + Suggest string `json:"suggest"` // 小程序的username + Label int `json:"label"` // 小程序的username + } `json:"result"` // 小程序的username + ToUserName string `json:"ToUserName"` // 小程序的username + FromUserName string `json:"FromUserName"` // 平台推送服务UserName + CreateTime int `json:"CreateTime"` // 发送时间 + MsgType string `json:"MsgType"` // 默认为:event + Event string `json:"Event"` // 默认为:wxa_media_check + Appid string `json:"appid"` // 小程序的appid + Version int `json:"version"` // 小程序的username + Detail []struct { + Strategy string `json:"strategy"` // 小程序的username + Errcode int `json:"errcode"` // 小程序的username + Suggest string `json:"suggest"` // 小程序的username + Label int `json:"label"` // 小程序的username + Prob int `json:"prob"` // 小程序的username + } `json:"detail"` // 小程序的username +} + +type WxaMediaCheckAsyncResult struct { + Result WxaMediaCheckAsyncResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newWxaMediaCheckAsyncResult(result WxaMediaCheckAsyncResponse, body []byte, http gorequest.Response, err error) *WxaMediaCheckAsyncResult { + return &WxaMediaCheckAsyncResult{Result: result, Body: body, Http: http, Err: err} +} + +// WxaMediaCheckAsync 音视频内容安全识别 +// https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/sec-check/mediaCheckAsync.html +func (c *Client) WxaMediaCheckAsync(ctx context.Context, notMustParams ...gorequest.Params) *WxaMediaCheckAsyncResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求 + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/media_check_async?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) + // 定义 + var response WxaMediaCheckAsyncResponse + err = gojson.Unmarshal(request.ResponseBody, &response) + return newWxaMediaCheckAsyncResult(response, request.ResponseBody, request, err) +} diff --git a/service/wechatopen/wxa.msg_sec_check.go b/service/wechatopen/wxa.msg_sec_check.go new file mode 100644 index 00000000..3ae85a7a --- /dev/null +++ b/service/wechatopen/wxa.msg_sec_check.go @@ -0,0 +1,52 @@ +package wechatopen + +import ( + "context" + "fmt" + "github.com/dtapps/go-library/utils/gojson" + "github.com/dtapps/go-library/utils/gorequest" + "net/http" +) + +type WxaMsgSecCheckResponse struct { + Errcode int `json:"errcode"` + Errmsg string `json:"errmsg"` + Result struct { + Suggest string `json:"suggest"` + Label int `json:"label"` + } `json:"result"` + Detail []struct { + Strategy string `json:"strategy"` + Errcode int `json:"errcode"` + Suggest string `json:"suggest"` + Label int `json:"label"` + Prob int `json:"prob,omitempty"` + Level int `json:"level,omitempty"` + Keyword string `json:"keyword,omitempty"` + } `json:"detail"` + TraceId string `json:"trace_id"` +} + +type WxaMsgSecCheckResult struct { + Result WxaMsgSecCheckResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newWxaMsgSecCheckResult(result WxaMsgSecCheckResponse, body []byte, http gorequest.Response, err error) *WxaMsgSecCheckResult { + return &WxaMsgSecCheckResult{Result: result, Body: body, Http: http, Err: err} +} + +// WxaMsgSecCheck 文本内容安全识别 +// https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.getUnlimited.html +func (c *Client) WxaMsgSecCheck(ctx context.Context, notMustParams ...gorequest.Params) *WxaMsgSecCheckResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求 + request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/msg_sec_check?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost) + // 定义 + var response WxaMsgSecCheckResponse + err = gojson.Unmarshal(request.ResponseBody, &response) + return newWxaMsgSecCheckResult(response, request.ResponseBody, request, err) +}