@@ -10,23 +10,23 @@ package me.chanjar.weixin.common; | |||||
*/ | */ | ||||
public enum WxType { | public enum WxType { | ||||
/** | /** | ||||
* 企业微信 | |||||
* 企业微信. | |||||
*/ | */ | ||||
CP, | CP, | ||||
/** | /** | ||||
* 微信公众号 | |||||
* 微信公众号. | |||||
*/ | */ | ||||
MP, | MP, | ||||
/** | /** | ||||
* 微信小程序 | |||||
* 微信小程序. | |||||
*/ | */ | ||||
MiniApp, | MiniApp, | ||||
/** | /** | ||||
* 微信开放平台 | |||||
* 微信开放平台. | |||||
*/ | */ | ||||
Open, | Open, | ||||
/** | /** | ||||
* 微信支付 | |||||
* 微信支付. | |||||
*/ | */ | ||||
Pay; | Pay; | ||||
} | } |
@@ -14,771 +14,771 @@ import lombok.Getter; | |||||
@Getter | @Getter | ||||
public enum WxCpErrorMsgEnum { | public enum WxCpErrorMsgEnum { | ||||
/** | /** | ||||
* 系统繁忙;服务器暂不可用,建议稍候重试。建议重试次数不超过3次。 | |||||
* 系统繁忙;服务器暂不可用,建议稍候重试。建议重试次数不超过3次. | |||||
*/ | */ | ||||
CODE_1(-1, "系统繁忙;服务器暂不可用,建议稍候重试。建议重试次数不超过3次。"), | CODE_1(-1, "系统繁忙;服务器暂不可用,建议稍候重试。建议重试次数不超过3次。"), | ||||
/** | /** | ||||
* 请求成功;接口调用成功 | |||||
* 请求成功;接口调用成功. | |||||
*/ | */ | ||||
CODE_0(0, "请求成功;接口调用成功"), | CODE_0(0, "请求成功;接口调用成功"), | ||||
/** | /** | ||||
* 不合法的secret参数;secret在应用详情/通讯录管理助手可查看 | |||||
* 不合法的secret参数;secret在应用详情/通讯录管理助手可查看. | |||||
*/ | */ | ||||
CODE_40001(40001, "不合法的secret参数;secret在应用详情/通讯录管理助手可查看"), | CODE_40001(40001, "不合法的secret参数;secret在应用详情/通讯录管理助手可查看"), | ||||
/** | /** | ||||
* 无效的UserID | |||||
* 无效的UserID. | |||||
*/ | */ | ||||
CODE_40003(40003, "无效的UserID"), | CODE_40003(40003, "无效的UserID"), | ||||
/** | /** | ||||
* 不合法的媒体文件类型;不满足系统文件要求。参考:上传的媒体文件限制 | |||||
* 不合法的媒体文件类型;不满足系统文件要求。参考:上传的媒体文件限制. | |||||
*/ | */ | ||||
CODE_40004(40004, "不合法的媒体文件类型;不满足系统文件要求。参考:上传的媒体文件限制"), | CODE_40004(40004, "不合法的媒体文件类型;不满足系统文件要求。参考:上传的媒体文件限制"), | ||||
/** | /** | ||||
* 不合法的type参数;合法的type取值,参考:上传临时素材 | |||||
* 不合法的type参数;合法的type取值,参考:上传临时素材. | |||||
*/ | */ | ||||
CODE_40005(40005, "不合法的type参数;合法的type取值,参考:上传临时素材"), | CODE_40005(40005, "不合法的type参数;合法的type取值,参考:上传临时素材"), | ||||
/** | /** | ||||
* 不合法的文件大小;系统文件要求,参考:上传的媒体文件限制 | |||||
* 不合法的文件大小;系统文件要求,参考:上传的媒体文件限制. | |||||
*/ | */ | ||||
CODE_40006(40006, "不合法的文件大小;系统文件要求,参考:上传的媒体文件限制"), | CODE_40006(40006, "不合法的文件大小;系统文件要求,参考:上传的媒体文件限制"), | ||||
/** | /** | ||||
* 不合法的media_id参数 | |||||
* 不合法的media_id参数. | |||||
*/ | */ | ||||
CODE_40007(40007, "不合法的media_id参数"), | CODE_40007(40007, "不合法的media_id参数"), | ||||
/** | /** | ||||
* 不合法的msgtype参数;合法的msgtype取值,参考:消息类型 | |||||
* 不合法的msgtype参数;合法的msgtype取值,参考:消息类型. | |||||
*/ | */ | ||||
CODE_40008(40008, "不合法的msgtype参数;合法的msgtype取值,参考:消息类型"), | CODE_40008(40008, "不合法的msgtype参数;合法的msgtype取值,参考:消息类型"), | ||||
/** | /** | ||||
* 上传图片大小不是有效值;图片大小的系统限制,参考上传的媒体文件限制 | |||||
* 上传图片大小不是有效值;图片大小的系统限制,参考上传的媒体文件限制. | |||||
*/ | */ | ||||
CODE_40009(40009, "上传图片大小不是有效值;图片大小的系统限制,参考上传的媒体文件限制"), | CODE_40009(40009, "上传图片大小不是有效值;图片大小的系统限制,参考上传的媒体文件限制"), | ||||
/** | /** | ||||
* 上传视频大小不是有效值;视频大小的系统限制,参考上传的媒体文件限制 | |||||
* 上传视频大小不是有效值;视频大小的系统限制,参考上传的媒体文件限制. | |||||
*/ | */ | ||||
CODE_40011(40011, "上传视频大小不是有效值;视频大小的系统限制,参考上传的媒体文件限制"), | CODE_40011(40011, "上传视频大小不是有效值;视频大小的系统限制,参考上传的媒体文件限制"), | ||||
/** | /** | ||||
* 不合法的CorpID;需确认CorpID是否填写正确,在 web管理端-设置 可查看 | |||||
* 不合法的CorpID;需确认CorpID是否填写正确,在 web管理端-设置 可查看. | |||||
*/ | */ | ||||
CODE_40013(40013, "不合法的CorpID;需确认CorpID是否填写正确,在 web管理端-设置 可查看"), | CODE_40013(40013, "不合法的CorpID;需确认CorpID是否填写正确,在 web管理端-设置 可查看"), | ||||
/** | /** | ||||
* 不合法的access_token | |||||
* 不合法的access_token. | |||||
*/ | */ | ||||
CODE_40014(40014, "不合法的access_token"), | CODE_40014(40014, "不合法的access_token"), | ||||
/** | /** | ||||
* 不合法的按钮个数;菜单按钮1-3个 | |||||
* 不合法的按钮个数;菜单按钮1-3个. | |||||
*/ | */ | ||||
CODE_40016(40016, "不合法的按钮个数;菜单按钮1-3个"), | CODE_40016(40016, "不合法的按钮个数;菜单按钮1-3个"), | ||||
/** | /** | ||||
* 不合法的按钮类型;支持的类型,参考:按钮类型 | |||||
* 不合法的按钮类型;支持的类型,参考:按钮类型. | |||||
*/ | */ | ||||
CODE_40017(40017, "不合法的按钮类型;支持的类型,参考:按钮类型"), | CODE_40017(40017, "不合法的按钮类型;支持的类型,参考:按钮类型"), | ||||
/** | /** | ||||
* 不合法的按钮名字长度;长度应不超过16个字节 | |||||
* 不合法的按钮名字长度;长度应不超过16个字节. | |||||
*/ | */ | ||||
CODE_40018(40018, "不合法的按钮名字长度;长度应不超过16个字节"), | CODE_40018(40018, "不合法的按钮名字长度;长度应不超过16个字节"), | ||||
/** | /** | ||||
* 不合法的按钮KEY长度;长度应不超过128字节 | |||||
* 不合法的按钮KEY长度;长度应不超过128字节. | |||||
*/ | */ | ||||
CODE_40019(40019, "不合法的按钮KEY长度;长度应不超过128字节"), | CODE_40019(40019, "不合法的按钮KEY长度;长度应不超过128字节"), | ||||
/** | /** | ||||
* 不合法的按钮URL长度;长度应不超过1024字节 | |||||
* 不合法的按钮URL长度;长度应不超过1024字节. | |||||
*/ | */ | ||||
CODE_40020(40020, "不合法的按钮URL长度;长度应不超过1024字节"), | CODE_40020(40020, "不合法的按钮URL长度;长度应不超过1024字节"), | ||||
/** | /** | ||||
* 不合法的子菜单级数;只能包含一级菜单和二级菜单 | |||||
* 不合法的子菜单级数;只能包含一级菜单和二级菜单. | |||||
*/ | */ | ||||
CODE_40022(40022, "不合法的子菜单级数;只能包含一级菜单和二级菜单"), | CODE_40022(40022, "不合法的子菜单级数;只能包含一级菜单和二级菜单"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮个数;子菜单按钮1-5个 | |||||
* 不合法的子菜单按钮个数;子菜单按钮1-5个. | |||||
*/ | */ | ||||
CODE_40023(40023, "不合法的子菜单按钮个数;子菜单按钮1-5个"), | CODE_40023(40023, "不合法的子菜单按钮个数;子菜单按钮1-5个"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮类型;支持的类型,参考:按钮类型 | |||||
* 不合法的子菜单按钮类型;支持的类型,参考:按钮类型. | |||||
*/ | */ | ||||
CODE_40024(40024, "不合法的子菜单按钮类型;支持的类型,参考:按钮类型"), | CODE_40024(40024, "不合法的子菜单按钮类型;支持的类型,参考:按钮类型"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮名字长度;支持的类型,参考:按钮类型 | |||||
* 不合法的子菜单按钮名字长度;支持的类型,参考:按钮类型. | |||||
*/ | */ | ||||
CODE_40025(40025, "不合法的子菜单按钮名字长度;支持的类型,参考:按钮类型"), | CODE_40025(40025, "不合法的子菜单按钮名字长度;支持的类型,参考:按钮类型"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮KEY长度;长度应不超过60个字节 | |||||
* 不合法的子菜单按钮KEY长度;长度应不超过60个字节. | |||||
*/ | */ | ||||
CODE_40026(40026, "不合法的子菜单按钮KEY长度;长度应不超过60个字节"), | CODE_40026(40026, "不合法的子菜单按钮KEY长度;长度应不超过60个字节"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮URL长度;长度应不超过1024字节 | |||||
* 不合法的子菜单按钮URL长度;长度应不超过1024字节. | |||||
*/ | */ | ||||
CODE_40027(40027, "不合法的子菜单按钮URL长度;长度应不超过1024字节"), | CODE_40027(40027, "不合法的子菜单按钮URL长度;长度应不超过1024字节"), | ||||
/** | /** | ||||
* 不合法的oauth_code | |||||
* 不合法的oauth_code. | |||||
*/ | */ | ||||
CODE_40029(40029, "不合法的oauth_code"), | CODE_40029(40029, "不合法的oauth_code"), | ||||
/** | /** | ||||
* 不合法的UserID列表;指定的UserID列表,至少存在一个UserID不在通讯录中 | |||||
* 不合法的UserID列表;指定的UserID列表,至少存在一个UserID不在通讯录中. | |||||
*/ | */ | ||||
CODE_40031(40031, "不合法的UserID列表;指定的UserID列表,至少存在一个UserID不在通讯录中"), | CODE_40031(40031, "不合法的UserID列表;指定的UserID列表,至少存在一个UserID不在通讯录中"), | ||||
/** | /** | ||||
* 不合法的UserID列表长度 | |||||
* 不合法的UserID列表长度. | |||||
*/ | */ | ||||
CODE_40032(40032, "不合法的UserID列表长度"), | CODE_40032(40032, "不合法的UserID列表长度"), | ||||
/** | /** | ||||
* 不合法的请求字符;不能包含\\uxxxx格式的字符 | |||||
* 不合法的请求字符;不能包含\\uxxxx格式的字符. | |||||
*/ | */ | ||||
CODE_40033(40033, "不合法的请求字符;不能包含\\uxxxx格式的字符"), | CODE_40033(40033, "不合法的请求字符;不能包含\\uxxxx格式的字符"), | ||||
/** | /** | ||||
* 不合法的参数 | |||||
* 不合法的参数. | |||||
*/ | */ | ||||
CODE_40035(40035, "不合法的参数"), | CODE_40035(40035, "不合法的参数"), | ||||
/** | /** | ||||
* chatid不存在;会话需要先创建后,才可修改会话详情或者发起聊天 | |||||
* chatid不存在;会话需要先创建后,才可修改会话详情或者发起聊天. | |||||
*/ | */ | ||||
CODE_40050(40050, "chatid不存在;会话需要先创建后,才可修改会话详情或者发起聊天"), | CODE_40050(40050, "chatid不存在;会话需要先创建后,才可修改会话详情或者发起聊天"), | ||||
/** | /** | ||||
* 不合法的子菜单url域名 | |||||
* 不合法的子菜单url域名. | |||||
*/ | */ | ||||
CODE_40054(40054, "不合法的子菜单url域名"), | CODE_40054(40054, "不合法的子菜单url域名"), | ||||
/** | /** | ||||
* 不合法的菜单url域名 | |||||
* 不合法的菜单url域名. | |||||
*/ | */ | ||||
CODE_40055(40055, "不合法的菜单url域名"), | CODE_40055(40055, "不合法的菜单url域名"), | ||||
/** | /** | ||||
* 不合法的agentid | |||||
* 不合法的agentid. | |||||
*/ | */ | ||||
CODE_40056(40056, "不合法的agentid"), | CODE_40056(40056, "不合法的agentid"), | ||||
/** | /** | ||||
* 不合法的callbackurl或者callbackurl验证失败;可自助到开发调试工具重现 | |||||
* 不合法的callbackurl或者callbackurl验证失败;可自助到开发调试工具重现. | |||||
*/ | */ | ||||
CODE_40057(40057, "不合法的callbackurl或者callbackurl验证失败;可自助到开发调试工具重现"), | CODE_40057(40057, "不合法的callbackurl或者callbackurl验证失败;可自助到开发调试工具重现"), | ||||
/** | /** | ||||
* 不合法的参数;传递参数不符合系统要求,需要参照具体API接口说明 | |||||
* 不合法的参数;传递参数不符合系统要求,需要参照具体API接口说明. | |||||
*/ | */ | ||||
CODE_40058(40058, "不合法的参数;传递参数不符合系统要求,需要参照具体API接口说明"), | CODE_40058(40058, "不合法的参数;传递参数不符合系统要求,需要参照具体API接口说明"), | ||||
/** | /** | ||||
* 不合法的上报地理位置标志位;开关标志位只能填 0 或者 1 | |||||
* 不合法的上报地理位置标志位;开关标志位只能填 0 或者 1. | |||||
*/ | */ | ||||
CODE_40059(40059, "不合法的上报地理位置标志位;开关标志位只能填 0 或者 1"), | CODE_40059(40059, "不合法的上报地理位置标志位;开关标志位只能填 0 或者 1"), | ||||
/** | /** | ||||
* 参数为空 | |||||
* 参数为空. | |||||
*/ | */ | ||||
CODE_40063(40063, "参数为空"), | CODE_40063(40063, "参数为空"), | ||||
/** | /** | ||||
* 不合法的部门列表;部门列表为空,或者至少存在一个部门ID不存在于通讯录中 | |||||
* 不合法的部门列表;部门列表为空,或者至少存在一个部门ID不存在于通讯录中. | |||||
*/ | */ | ||||
CODE_40066(40066, "不合法的部门列表;部门列表为空,或者至少存在一个部门ID不存在于通讯录中"), | CODE_40066(40066, "不合法的部门列表;部门列表为空,或者至少存在一个部门ID不存在于通讯录中"), | ||||
/** | /** | ||||
* 不合法的标签ID;标签ID未指定,或者指定的标签ID不存在 | |||||
* 不合法的标签ID;标签ID未指定,或者指定的标签ID不存在. | |||||
*/ | */ | ||||
CODE_40068(40068, "不合法的标签ID;标签ID未指定,或者指定的标签ID不存在"), | CODE_40068(40068, "不合法的标签ID;标签ID未指定,或者指定的标签ID不存在"), | ||||
/** | /** | ||||
* 指定的标签范围结点全部无效 | |||||
* 指定的标签范围结点全部无效. | |||||
*/ | */ | ||||
CODE_40070(40070, "指定的标签范围结点全部无效"), | CODE_40070(40070, "指定的标签范围结点全部无效"), | ||||
/** | /** | ||||
* 不合法的标签名字;标签名字已经存在 | |||||
* 不合法的标签名字;标签名字已经存在. | |||||
*/ | */ | ||||
CODE_40071(40071, "不合法的标签名字;标签名字已经存在"), | CODE_40071(40071, "不合法的标签名字;标签名字已经存在"), | ||||
/** | /** | ||||
* 不合法的标签名字长度;不允许为空,最大长度限制为32个字(汉字或英文字母) | |||||
* 不合法的标签名字长度;不允许为空,最大长度限制为32个字(汉字或英文字母). | |||||
*/ | */ | ||||
CODE_40072(40072, "不合法的标签名字长度;不允许为空,最大长度限制为32个字(汉字或英文字母)"), | CODE_40072(40072, "不合法的标签名字长度;不允许为空,最大长度限制为32个字(汉字或英文字母)"), | ||||
/** | /** | ||||
* 不合法的openid;openid不存在,需确认获取来源 | |||||
* 不合法的openid;openid不存在,需确认获取来源. | |||||
*/ | */ | ||||
CODE_40073(40073, "不合法的openid;openid不存在,需确认获取来源"), | CODE_40073(40073, "不合法的openid;openid不存在,需确认获取来源"), | ||||
/** | /** | ||||
* news消息不支持保密消息类型;图文消息支持保密类型需改用mpnews | |||||
* news消息不支持保密消息类型;图文消息支持保密类型需改用mpnews. | |||||
*/ | */ | ||||
CODE_40074(40074, "news消息不支持保密消息类型;图文消息支持保密类型需改用mpnews"), | CODE_40074(40074, "news消息不支持保密消息类型;图文消息支持保密类型需改用mpnews"), | ||||
/** | /** | ||||
* 不合法的pre_auth_code参数;预授权码不存在,参考:获取预授权码 | |||||
* 不合法的pre_auth_code参数;预授权码不存在,参考:获取预授权码. | |||||
*/ | */ | ||||
CODE_40077(40077, "不合法的pre_auth_code参数;预授权码不存在,参考:获取预授权码"), | CODE_40077(40077, "不合法的pre_auth_code参数;预授权码不存在,参考:获取预授权码"), | ||||
/** | /** | ||||
* 不合法的auth_code参数;需确认获取来源,并且只能消费一次 | |||||
* 不合法的auth_code参数;需确认获取来源,并且只能消费一次. | |||||
*/ | */ | ||||
CODE_40078(40078, "不合法的auth_code参数;需确认获取来源,并且只能消费一次"), | CODE_40078(40078, "不合法的auth_code参数;需确认获取来源,并且只能消费一次"), | ||||
/** | /** | ||||
* 不合法的suite_secret;套件secret可在第三方管理端套件详情查看 | |||||
* 不合法的suite_secret;套件secret可在第三方管理端套件详情查看. | |||||
*/ | */ | ||||
CODE_40080(40080, "不合法的suite_secret;套件secret可在第三方管理端套件详情查看"), | CODE_40080(40080, "不合法的suite_secret;套件secret可在第三方管理端套件详情查看"), | ||||
/** | /** | ||||
* 不合法的suite_token | |||||
* 不合法的suite_token. | |||||
*/ | */ | ||||
CODE_40082(40082, "不合法的suite_token"), | CODE_40082(40082, "不合法的suite_token"), | ||||
/** | /** | ||||
* 不合法的suite_id;suite_id不存在 | |||||
* 不合法的suite_id;suite_id不存在. | |||||
*/ | */ | ||||
CODE_40083(40083, "不合法的suite_id;suite_id不存在"), | CODE_40083(40083, "不合法的suite_id;suite_id不存在"), | ||||
/** | /** | ||||
* 不合法的permanent_code参数 | |||||
* 不合法的permanent_code参数. | |||||
*/ | */ | ||||
CODE_40084(40084, "不合法的permanent_code参数"), | CODE_40084(40084, "不合法的permanent_code参数"), | ||||
/** | /** | ||||
* 不合法的的suite_ticket参数;suite_ticket不存在或者已失效 | |||||
* 不合法的的suite_ticket参数;suite_ticket不存在或者已失效. | |||||
*/ | */ | ||||
CODE_40085(40085, "不合法的的suite_ticket参数;suite_ticket不存在或者已失效"), | CODE_40085(40085, "不合法的的suite_ticket参数;suite_ticket不存在或者已失效"), | ||||
/** | /** | ||||
* 不合法的第三方应用appid;至少有一个不存在应用id | |||||
* 不合法的第三方应用appid;至少有一个不存在应用id. | |||||
*/ | */ | ||||
CODE_40086(40086, "不合法的第三方应用appid;至少有一个不存在应用id"), | CODE_40086(40086, "不合法的第三方应用appid;至少有一个不存在应用id"), | ||||
/** | /** | ||||
* jobid不存在;请检查 jobid 来源 | |||||
* jobid不存在;请检查 jobid 来源. | |||||
*/ | */ | ||||
CODE_40088(40088, "jobid不存在;请检查 jobid 来源"), | CODE_40088(40088, "jobid不存在;请检查 jobid 来源"), | ||||
/** | /** | ||||
* 批量任务的结果已清理;系统仅保存最近5次批量任务的结果。可在通讯录查看实际导入情况 | |||||
* 批量任务的结果已清理;系统仅保存最近5次批量任务的结果。可在通讯录查看实际导入情况. | |||||
*/ | */ | ||||
CODE_40089(40089, "批量任务的结果已清理;系统仅保存最近5次批量任务的结果。可在通讯录查看实际导入情况"), | CODE_40089(40089, "批量任务的结果已清理;系统仅保存最近5次批量任务的结果。可在通讯录查看实际导入情况"), | ||||
/** | /** | ||||
* secret不合法;可能用了别的企业的secret | |||||
* secret不合法;可能用了别的企业的secret. | |||||
*/ | */ | ||||
CODE_40091(40091, "secret不合法;可能用了别的企业的secret"), | CODE_40091(40091, "secret不合法;可能用了别的企业的secret"), | ||||
/** | /** | ||||
* 导入文件存在不合法的内容 | |||||
* 导入文件存在不合法的内容. | |||||
*/ | */ | ||||
CODE_40092(40092, "导入文件存在不合法的内容"), | CODE_40092(40092, "导入文件存在不合法的内容"), | ||||
/** | /** | ||||
* 不合法的jsapi_ticket参数;ticket已失效,或者拼写错误 | |||||
* 不合法的jsapi_ticket参数;ticket已失效,或者拼写错误. | |||||
*/ | */ | ||||
CODE_40093(40093, "不合法的jsapi_ticket参数;ticket已失效,或者拼写错误"), | CODE_40093(40093, "不合法的jsapi_ticket参数;ticket已失效,或者拼写错误"), | ||||
/** | /** | ||||
* 不合法的URL;缺少主页URL参数,或者URL不合法(链接需要带上协议头,以 http:// 或者 https:// 开头) | |||||
* 不合法的URL;缺少主页URL参数,或者URL不合法(链接需要带上协议头,以 http:// 或者 https:// 开头). | |||||
*/ | */ | ||||
CODE_40094(40094, "不合法的URL;缺少主页URL参数,或者URL不合法(链接需要带上协议头,以 http:// 或者 https:// 开头)"), | CODE_40094(40094, "不合法的URL;缺少主页URL参数,或者URL不合法(链接需要带上协议头,以 http:// 或者 https:// 开头)"), | ||||
/** | /** | ||||
* 缺少access_token参数 | |||||
* 缺少access_token参数. | |||||
*/ | */ | ||||
CODE_41001(41001, "缺少access_token参数"), | CODE_41001(41001, "缺少access_token参数"), | ||||
/** | /** | ||||
* 缺少corpid参数 | |||||
* 缺少corpid参数. | |||||
*/ | */ | ||||
CODE_41002(41002, "缺少corpid参数"), | CODE_41002(41002, "缺少corpid参数"), | ||||
/** | /** | ||||
* 缺少secret参数 | |||||
* 缺少secret参数. | |||||
*/ | */ | ||||
CODE_41004(41004, "缺少secret参数"), | CODE_41004(41004, "缺少secret参数"), | ||||
/** | /** | ||||
* 缺少media_id参数;media_id为调用接口必填参数,请确认是否有传递 | |||||
* 缺少media_id参数;media_id为调用接口必填参数,请确认是否有传递. | |||||
*/ | */ | ||||
CODE_41006(41006, "缺少media_id参数;media_id为调用接口必填参数,请确认是否有传递"), | CODE_41006(41006, "缺少media_id参数;media_id为调用接口必填参数,请确认是否有传递"), | ||||
/** | /** | ||||
* 缺少auth code参数 | |||||
* 缺少auth code参数. | |||||
*/ | */ | ||||
CODE_41008(41008, "缺少auth code参数"), | CODE_41008(41008, "缺少auth code参数"), | ||||
/** | /** | ||||
* 缺少userid参数 | |||||
* 缺少userid参数. | |||||
*/ | */ | ||||
CODE_41009(41009, "缺少userid参数"), | CODE_41009(41009, "缺少userid参数"), | ||||
/** | /** | ||||
* 缺少url参数 | |||||
* 缺少url参数. | |||||
*/ | */ | ||||
CODE_41010(41010, "缺少url参数"), | CODE_41010(41010, "缺少url参数"), | ||||
/** | /** | ||||
* 缺少agentid参数 | |||||
* 缺少agentid参数. | |||||
*/ | */ | ||||
CODE_41011(41011, "缺少agentid参数"), | CODE_41011(41011, "缺少agentid参数"), | ||||
/** | /** | ||||
* 缺少 description 参数;发送文本卡片消息接口,description 是必填字段 | |||||
* 缺少 description 参数;发送文本卡片消息接口,description 是必填字段. | |||||
*/ | */ | ||||
CODE_41033(41033, "缺少 description 参数;发送文本卡片消息接口,description 是必填字段"), | CODE_41033(41033, "缺少 description 参数;发送文本卡片消息接口,description 是必填字段"), | ||||
/** | /** | ||||
* 缺少title参数;发送图文消息,标题是必填参数。请确认参数是否有传递。 | |||||
* 缺少title参数;发送图文消息,标题是必填参数。请确认参数是否有传递. | |||||
*/ | */ | ||||
CODE_41016(41016, "缺少title参数;发送图文消息,标题是必填参数。请确认参数是否有传递。"), | CODE_41016(41016, "缺少title参数;发送图文消息,标题是必填参数。请确认参数是否有传递。"), | ||||
/** | /** | ||||
* 缺少 department 参数 | |||||
* 缺少 department 参数. | |||||
*/ | */ | ||||
CODE_41019(41019, "缺少 department 参数"), | CODE_41019(41019, "缺少 department 参数"), | ||||
/** | /** | ||||
* 缺少tagid参数 | |||||
* 缺少tagid参数. | |||||
*/ | */ | ||||
CODE_41017(41017, "缺少tagid参数"), | CODE_41017(41017, "缺少tagid参数"), | ||||
/** | /** | ||||
* 缺少suite_id参数 | |||||
* 缺少suite_id参数. | |||||
*/ | */ | ||||
CODE_41021(41021, "缺少suite_id参数"), | CODE_41021(41021, "缺少suite_id参数"), | ||||
/** | /** | ||||
* 缺少suite_access_token参数 | |||||
* 缺少suite_access_token参数. | |||||
*/ | */ | ||||
CODE_41022(41022, "缺少suite_access_token参数"), | CODE_41022(41022, "缺少suite_access_token参数"), | ||||
/** | /** | ||||
* 缺少suite_ticket参数 | |||||
* 缺少suite_ticket参数. | |||||
*/ | */ | ||||
CODE_41023(41023, "缺少suite_ticket参数"), | CODE_41023(41023, "缺少suite_ticket参数"), | ||||
/** | /** | ||||
* 缺少secret参数 | |||||
* 缺少secret参数. | |||||
*/ | */ | ||||
CODE_41024(41024, "缺少secret参数"), | CODE_41024(41024, "缺少secret参数"), | ||||
/** | /** | ||||
* 缺少permanent_code参数 | |||||
* 缺少permanent_code参数. | |||||
*/ | */ | ||||
CODE_41025(41025, "缺少permanent_code参数"), | CODE_41025(41025, "缺少permanent_code参数"), | ||||
/** | /** | ||||
* access_token已过期;access_token有时效性,需要重新获取一次 | |||||
* access_token已过期;access_token有时效性,需要重新获取一次. | |||||
*/ | */ | ||||
CODE_42001(42001, "access_token已过期;access_token有时效性,需要重新获取一次"), | CODE_42001(42001, "access_token已过期;access_token有时效性,需要重新获取一次"), | ||||
/** | /** | ||||
* pre_auth_code已过期;pre_auth_code有时效性,需要重新获取一次 | |||||
* pre_auth_code已过期;pre_auth_code有时效性,需要重新获取一次. | |||||
*/ | */ | ||||
CODE_42007(42007, "pre_auth_code已过期;pre_auth_code有时效性,需要重新获取一次"), | CODE_42007(42007, "pre_auth_code已过期;pre_auth_code有时效性,需要重新获取一次"), | ||||
/** | /** | ||||
* suite_access_token已过期;suite_access_token有时效性,需要重新获取一次 | |||||
* suite_access_token已过期;suite_access_token有时效性,需要重新获取一次. | |||||
*/ | */ | ||||
CODE_42009(42009, "suite_access_token已过期;suite_access_token有时效性,需要重新获取一次"), | CODE_42009(42009, "suite_access_token已过期;suite_access_token有时效性,需要重新获取一次"), | ||||
/** | /** | ||||
* 指定的userid未绑定微信或未关注微信插件;需要成员使用微信登录企业微信或者关注微信插件才能获取openid | |||||
* 指定的userid未绑定微信或未关注微信插件;需要成员使用微信登录企业微信或者关注微信插件才能获取openid. | |||||
*/ | */ | ||||
CODE_43004(43004, "指定的userid未绑定微信或未关注微信插件;需要成员使用微信登录企业微信或者关注微信插件才能获取openid"), | CODE_43004(43004, "指定的userid未绑定微信或未关注微信插件;需要成员使用微信登录企业微信或者关注微信插件才能获取openid"), | ||||
/** | /** | ||||
* 多媒体文件为空;上传格式参考:上传临时素材,确认header和body的内容正确。 | |||||
* 多媒体文件为空;上传格式参考:上传临时素材,确认header和body的内容正确. | |||||
*/ | */ | ||||
CODE_44001(44001, "多媒体文件为空;上传格式参考:上传临时素材,确认header和body的内容正确。"), | CODE_44001(44001, "多媒体文件为空;上传格式参考:上传临时素材,确认header和body的内容正确。"), | ||||
/** | /** | ||||
* 文本消息content参数为空;发文本消息content为必填参数,且不能为空 | |||||
* 文本消息content参数为空;发文本消息content为必填参数,且不能为空. | |||||
*/ | */ | ||||
CODE_44004(44004, "文本消息content参数为空;发文本消息content为必填参数,且不能为空"), | CODE_44004(44004, "文本消息content参数为空;发文本消息content为必填参数,且不能为空"), | ||||
/** | /** | ||||
* 多媒体文件大小超过限制;图片不可超过5M;音频不可超过5M;文件不可超过20M | |||||
* 多媒体文件大小超过限制;图片不可超过5M;音频不可超过5M;文件不可超过20M. | |||||
*/ | */ | ||||
CODE_45001(45001, "多媒体文件大小超过限制;图片不可超过5M;音频不可超过5M;文件不可超过20M"), | CODE_45001(45001, "多媒体文件大小超过限制;图片不可超过5M;音频不可超过5M;文件不可超过20M"), | ||||
/** | /** | ||||
* 消息内容大小超过限制 | |||||
* 消息内容大小超过限制. | |||||
*/ | */ | ||||
CODE_45002(45002, "消息内容大小超过限制"), | CODE_45002(45002, "消息内容大小超过限制"), | ||||
/** | /** | ||||
* 应用description参数长度不符合系统限制;设置应用若带有description参数,则长度必须为4至120个字符 | |||||
* 应用description参数长度不符合系统限制;设置应用若带有description参数,则长度必须为4至120个字符. | |||||
*/ | */ | ||||
CODE_45004(45004, "应用description参数长度不符合系统限制;设置应用若带有description参数,则长度必须为4至120个字符"), | CODE_45004(45004, "应用description参数长度不符合系统限制;设置应用若带有description参数,则长度必须为4至120个字符"), | ||||
/** | /** | ||||
* 语音播放时间超过限制;语音播放时长不能超过60秒 | |||||
* 语音播放时间超过限制;语音播放时长不能超过60秒. | |||||
*/ | */ | ||||
CODE_45007(45007, "语音播放时间超过限制;语音播放时长不能超过60秒"), | CODE_45007(45007, "语音播放时间超过限制;语音播放时长不能超过60秒"), | ||||
/** | /** | ||||
* 图文消息的文章数量不符合系统限制;图文消息的文章数量不能超过8条 | |||||
* 图文消息的文章数量不符合系统限制;图文消息的文章数量不能超过8条. | |||||
*/ | */ | ||||
CODE_45008(45008, "图文消息的文章数量不符合系统限制;图文消息的文章数量不能超过8条"), | CODE_45008(45008, "图文消息的文章数量不符合系统限制;图文消息的文章数量不能超过8条"), | ||||
/** | /** | ||||
* 接口调用超过限制 | |||||
* 接口调用超过限制. | |||||
*/ | */ | ||||
CODE_45009(45009, "接口调用超过限制"), | CODE_45009(45009, "接口调用超过限制"), | ||||
/** | /** | ||||
* 应用name参数长度不符合系统限制;设置应用若带有name参数,则不允许为空,且不超过32个字符 | |||||
* 应用name参数长度不符合系统限制;设置应用若带有name参数,则不允许为空,且不超过32个字符. | |||||
*/ | */ | ||||
CODE_45022(45022, "应用name参数长度不符合系统限制;设置应用若带有name参数,则不允许为空,且不超过32个字符"), | CODE_45022(45022, "应用name参数长度不符合系统限制;设置应用若带有name参数,则不允许为空,且不超过32个字符"), | ||||
/** | /** | ||||
* 帐号数量超过上限 | |||||
* 帐号数量超过上限. | |||||
*/ | */ | ||||
CODE_45024(45024, "帐号数量超过上限"), | CODE_45024(45024, "帐号数量超过上限"), | ||||
/** | /** | ||||
* 触发删除用户数的保护;限制参考:全量覆盖成员 | |||||
* 触发删除用户数的保护;限制参考:全量覆盖成员. | |||||
*/ | */ | ||||
CODE_45026(45026, "触发删除用户数的保护;限制参考:全量覆盖成员"), | CODE_45026(45026, "触发删除用户数的保护;限制参考:全量覆盖成员"), | ||||
/** | /** | ||||
* 图文消息author参数长度超过限制;最长64个字节 | |||||
* 图文消息author参数长度超过限制;最长64个字节. | |||||
*/ | */ | ||||
CODE_45032(45032, "图文消息author参数长度超过限制;最长64个字节"), | CODE_45032(45032, "图文消息author参数长度超过限制;最长64个字节"), | ||||
/** | /** | ||||
* 接口并发调用超过限制 | |||||
* 接口并发调用超过限制. | |||||
*/ | */ | ||||
CODE_45033(45033, "接口并发调用超过限制"), | CODE_45033(45033, "接口并发调用超过限制"), | ||||
/** | /** | ||||
* 菜单未设置;菜单需发布后才能获取到数据 | |||||
* 菜单未设置;菜单需发布后才能获取到数据. | |||||
*/ | */ | ||||
CODE_46003(46003, "菜单未设置;菜单需发布后才能获取到数据"), | CODE_46003(46003, "菜单未设置;菜单需发布后才能获取到数据"), | ||||
/** | /** | ||||
* 指定的用户不存在;需要确认指定的用户存在于通讯录中 | |||||
* 指定的用户不存在;需要确认指定的用户存在于通讯录中. | |||||
*/ | */ | ||||
CODE_46004(46004, "指定的用户不存在;需要确认指定的用户存在于通讯录中"), | CODE_46004(46004, "指定的用户不存在;需要确认指定的用户存在于通讯录中"), | ||||
/** | /** | ||||
* API接口无权限调用 | |||||
* API接口无权限调用. | |||||
*/ | */ | ||||
CODE_48002(48002, "API接口无权限调用"), | CODE_48002(48002, "API接口无权限调用"), | ||||
/** | /** | ||||
* 不合法的suite_id;确认suite_access_token由指定的suite_id生成 | |||||
* 不合法的suite_id;确认suite_access_token由指定的suite_id生成. | |||||
*/ | */ | ||||
CODE_48003(48003, "不合法的suite_id;确认suite_access_token由指定的suite_id生成"), | CODE_48003(48003, "不合法的suite_id;确认suite_access_token由指定的suite_id生成"), | ||||
/** | /** | ||||
* 授权关系无效;可能是无授权或授权已被取消 | |||||
* 授权关系无效;可能是无授权或授权已被取消. | |||||
*/ | */ | ||||
CODE_48004(48004, "授权关系无效;可能是无授权或授权已被取消"), | CODE_48004(48004, "授权关系无效;可能是无授权或授权已被取消"), | ||||
/** | /** | ||||
* API接口已废弃;接口已不再支持,建议改用新接口或者新方案 | |||||
* API接口已废弃;接口已不再支持,建议改用新接口或者新方案. | |||||
*/ | */ | ||||
CODE_48005(48005, "API接口已废弃;接口已不再支持,建议改用新接口或者新方案"), | CODE_48005(48005, "API接口已废弃;接口已不再支持,建议改用新接口或者新方案"), | ||||
/** | /** | ||||
* redirect_url未登记可信域名 | |||||
* redirect_url未登记可信域名. | |||||
*/ | */ | ||||
CODE_50001(50001, "redirect_url未登记可信域名"), | CODE_50001(50001, "redirect_url未登记可信域名"), | ||||
/** | /** | ||||
* 成员不在权限范围;请检查应用或管理组的权限范围 | |||||
* 成员不在权限范围;请检查应用或管理组的权限范围. | |||||
*/ | */ | ||||
CODE_50002(50002, "成员不在权限范围;请检查应用或管理组的权限范围"), | CODE_50002(50002, "成员不在权限范围;请检查应用或管理组的权限范围"), | ||||
/** | /** | ||||
* 应用已禁用;禁用的应用无法使用API接口。可在”管理端-企业应用”启用应用 | |||||
* 应用已禁用;禁用的应用无法使用API接口。可在”管理端-企业应用”启用应用. | |||||
*/ | */ | ||||
CODE_50003(50003, "应用已禁用;禁用的应用无法使用API接口。可在”管理端-企业应用”启用应用"), | CODE_50003(50003, "应用已禁用;禁用的应用无法使用API接口。可在”管理端-企业应用”启用应用"), | ||||
/** | /** | ||||
* 部门长度不符合限制;部门名称不能为空且长度不能超过32个字 | |||||
* 部门长度不符合限制;部门名称不能为空且长度不能超过32个字. | |||||
*/ | */ | ||||
CODE_60001(60001, "部门长度不符合限制;部门名称不能为空且长度不能超过32个字"), | CODE_60001(60001, "部门长度不符合限制;部门名称不能为空且长度不能超过32个字"), | ||||
/** | /** | ||||
* 部门ID不存在;需要确认部门ID是否有带,并且存在通讯录中 | |||||
* 部门ID不存在;需要确认部门ID是否有带,并且存在通讯录中. | |||||
*/ | */ | ||||
CODE_60003(60003, "部门ID不存在;需要确认部门ID是否有带,并且存在通讯录中"), | CODE_60003(60003, "部门ID不存在;需要确认部门ID是否有带,并且存在通讯录中"), | ||||
/** | /** | ||||
* 父部门不存在;需要确认父亲部门ID是否有带,并且存在通讯录中 | |||||
* 父部门不存在;需要确认父亲部门ID是否有带,并且存在通讯录中. | |||||
*/ | */ | ||||
CODE_60004(60004, "父部门不存在;需要确认父亲部门ID是否有带,并且存在通讯录中"), | CODE_60004(60004, "父部门不存在;需要确认父亲部门ID是否有带,并且存在通讯录中"), | ||||
/** | /** | ||||
* 部门下存在成员;不允许删除有成员的部门 | |||||
* 部门下存在成员;不允许删除有成员的部门. | |||||
*/ | */ | ||||
CODE_60005(60005, "部门下存在成员;不允许删除有成员的部门"), | CODE_60005(60005, "部门下存在成员;不允许删除有成员的部门"), | ||||
/** | /** | ||||
* 部门下存在子部门;不允许删除有子部门的部门 | |||||
* 部门下存在子部门;不允许删除有子部门的部门. | |||||
*/ | */ | ||||
CODE_60006(60006, "部门下存在子部门;不允许删除有子部门的部门"), | CODE_60006(60006, "部门下存在子部门;不允许删除有子部门的部门"), | ||||
/** | /** | ||||
* 不允许删除根部门 | |||||
* 不允许删除根部门. | |||||
*/ | */ | ||||
CODE_60007(60007, "不允许删除根部门"), | CODE_60007(60007, "不允许删除根部门"), | ||||
/** | /** | ||||
* 部门已存在;部门ID或者部门名称已存在 | |||||
* 部门已存在;部门ID或者部门名称已存在. | |||||
*/ | */ | ||||
CODE_60008(60008, "部门已存在;部门ID或者部门名称已存在"), | CODE_60008(60008, "部门已存在;部门ID或者部门名称已存在"), | ||||
/** | /** | ||||
* 部门名称含有非法字符;不能含有 \\:?*“< >| 等字符 | |||||
* 部门名称含有非法字符;不能含有 \\:?*“< >| 等字符. | |||||
*/ | */ | ||||
CODE_60009(60009, "部门名称含有非法字符;不能含有 \\ :?*“< >| 等字符"), | CODE_60009(60009, "部门名称含有非法字符;不能含有 \\ :?*“< >| 等字符"), | ||||
/** | /** | ||||
* 部门存在循环关系 | |||||
* 部门存在循环关系. | |||||
*/ | */ | ||||
CODE_60010(60010, "部门存在循环关系"), | CODE_60010(60010, "部门存在循环关系"), | ||||
/** | /** | ||||
* 指定的成员/部门/标签参数无权限 | |||||
* 指定的成员/部门/标签参数无权限. | |||||
*/ | */ | ||||
CODE_60011(60011, "指定的成员/部门/标签参数无权限"), | CODE_60011(60011, "指定的成员/部门/标签参数无权限"), | ||||
/** | /** | ||||
* 不允许删除默认应用;默认应用的id为0 | |||||
* 不允许删除默认应用;默认应用的id为0. | |||||
*/ | */ | ||||
CODE_60012(60012, "不允许删除默认应用;默认应用的id为0"), | CODE_60012(60012, "不允许删除默认应用;默认应用的id为0"), | ||||
/** | /** | ||||
* 访问ip不在白名单之中;请确认访问ip是否在服务商白名单IP列表 | |||||
* 访问ip不在白名单之中;请确认访问ip是否在服务商白名单IP列表. | |||||
*/ | */ | ||||
CODE_60020(60020, "访问ip不在白名单之中;请确认访问ip是否在服务商白名单IP列表"), | CODE_60020(60020, "访问ip不在白名单之中;请确认访问ip是否在服务商白名单IP列表"), | ||||
/** | /** | ||||
* 不允许修改第三方应用的主页 URL;第三方应用类型,不允许通过接口修改该应用的主页 URL | |||||
* 不允许修改第三方应用的主页 URL;第三方应用类型,不允许通过接口修改该应用的主页 URL. | |||||
*/ | */ | ||||
CODE_60028(60028, "不允许修改第三方应用的主页 URL;第三方应用类型,不允许通过接口修改该应用的主页 URL"), | CODE_60028(60028, "不允许修改第三方应用的主页 URL;第三方应用类型,不允许通过接口修改该应用的主页 URL"), | ||||
/** | /** | ||||
* UserID已存在 | |||||
* UserID已存在. | |||||
*/ | */ | ||||
CODE_60102(60102, "UserID已存在"), | CODE_60102(60102, "UserID已存在"), | ||||
/** | /** | ||||
* 手机号码不合法;长度不超过32位,字符仅支持数字,加号和减号 | |||||
* 手机号码不合法;长度不超过32位,字符仅支持数字,加号和减号. | |||||
*/ | */ | ||||
CODE_60103(60103, "手机号码不合法;长度不超过32位,字符仅支持数字,加号和减号"), | CODE_60103(60103, "手机号码不合法;长度不超过32位,字符仅支持数字,加号和减号"), | ||||
/** | /** | ||||
* 手机号码已存在;同一个企业内,成员的手机号不能重复。建议更换手机号,或者更新已有的手机记录。 | |||||
* 手机号码已存在;同一个企业内,成员的手机号不能重复。建议更换手机号,或者更新已有的手机记录. | |||||
*/ | */ | ||||
CODE_60104(60104, "手机号码已存在;同一个企业内,成员的手机号不能重复。建议更换手机号,或者更新已有的手机记录。"), | CODE_60104(60104, "手机号码已存在;同一个企业内,成员的手机号不能重复。建议更换手机号,或者更新已有的手机记录。"), | ||||
/** | /** | ||||
* 邮箱不合法;长度不超过64位,且为有效的email格式 | |||||
* 邮箱不合法;长度不超过64位,且为有效的email格式. | |||||
*/ | */ | ||||
CODE_60105(60105, "邮箱不合法;长度不超过64位,且为有效的email格式"), | CODE_60105(60105, "邮箱不合法;长度不超过64位,且为有效的email格式"), | ||||
/** | /** | ||||
* 邮箱已存在;同一个企业内,成员的邮箱不能重复。建议更换邮箱,或者更新已有的邮箱记录。 | |||||
* 邮箱已存在;同一个企业内,成员的邮箱不能重复。建议更换邮箱,或者更新已有的邮箱记录. | |||||
*/ | */ | ||||
CODE_60106(60106, "邮箱已存在;同一个企业内,成员的邮箱不能重复。建议更换邮箱,或者更新已有的邮箱记录。"), | CODE_60106(60106, "邮箱已存在;同一个企业内,成员的邮箱不能重复。建议更换邮箱,或者更新已有的邮箱记录。"), | ||||
/** | /** | ||||
* 微信号不合法;微信号格式由字母、数字、”-“、”_“组成,长度为 3-20 字节,首字符必须是字母或”-“或”_“ | |||||
* 微信号不合法;微信号格式由字母、数字、”-“、”_“组成,长度为 3-20 字节,首字符必须是字母或”-“或”_“. | |||||
*/ | */ | ||||
CODE_60107(60107, "微信号不合法;微信号格式由字母、数字、”-“、”_“组成,长度为 3-20 字节,首字符必须是字母或”-“或”_“"), | CODE_60107(60107, "微信号不合法;微信号格式由字母、数字、”-“、”_“组成,长度为 3-20 字节,首字符必须是字母或”-“或”_“"), | ||||
/** | /** | ||||
* 用户所属部门数量超过限制;用户同时归属部门不超过20个 | |||||
* 用户所属部门数量超过限制;用户同时归属部门不超过20个. | |||||
*/ | */ | ||||
CODE_60110(60110, "用户所属部门数量超过限制;用户同时归属部门不超过20个"), | CODE_60110(60110, "用户所属部门数量超过限制;用户同时归属部门不超过20个"), | ||||
/** | /** | ||||
* UserID不存在;UserID参数为空,或者不存在通讯录中 | |||||
* UserID不存在;UserID参数为空,或者不存在通讯录中. | |||||
*/ | */ | ||||
CODE_60111(60111, "UserID不存在;UserID参数为空,或者不存在通讯录中"), | CODE_60111(60111, "UserID不存在;UserID参数为空,或者不存在通讯录中"), | ||||
/** | /** | ||||
* 成员name参数不合法;不能为空,且不能超过64字符 | |||||
* 成员name参数不合法;不能为空,且不能超过64字符. | |||||
*/ | */ | ||||
CODE_60112(60112, "成员name参数不合法;不能为空,且不能超过64字符"), | CODE_60112(60112, "成员name参数不合法;不能为空,且不能超过64字符"), | ||||
/** | /** | ||||
* 无效的部门id;部门不存在通讯录中 | |||||
* 无效的部门id;部门不存在通讯录中. | |||||
*/ | */ | ||||
CODE_60123(60123, "无效的部门id;部门不存在通讯录中"), | CODE_60123(60123, "无效的部门id;部门不存在通讯录中"), | ||||
/** | /** | ||||
* 无效的父部门id;父部门不存在通讯录中 | |||||
* 无效的父部门id;父部门不存在通讯录中. | |||||
*/ | */ | ||||
CODE_60124(60124, "无效的父部门id;父部门不存在通讯录中"), | CODE_60124(60124, "无效的父部门id;父部门不存在通讯录中"), | ||||
/** | /** | ||||
* 非法部门名字;不能为空,且不能超过64字节,且不能含有\\:*?”< >|等字符 | |||||
* 非法部门名字;不能为空,且不能超过64字节,且不能含有\\:*?”< >|等字符. | |||||
*/ | */ | ||||
CODE_60125(60125, "非法部门名字;不能为空,且不能超过64字节,且不能含有\\:*?”< >|等字符"), | CODE_60125(60125, "非法部门名字;不能为空,且不能超过64字节,且不能含有\\:*?”< >|等字符"), | ||||
/** | /** | ||||
* 缺少department参数 | |||||
* 缺少department参数. | |||||
*/ | */ | ||||
CODE_60127(60127, "缺少department参数"), | CODE_60127(60127, "缺少department参数"), | ||||
/** | /** | ||||
* 成员手机和邮箱都为空;成员手机和邮箱至少有个非空 | |||||
* 成员手机和邮箱都为空;成员手机和邮箱至少有个非空. | |||||
*/ | */ | ||||
CODE_60129(60129, "成员手机和邮箱都为空;成员手机和邮箱至少有个非空"), | CODE_60129(60129, "成员手机和邮箱都为空;成员手机和邮箱至少有个非空"), | ||||
/** | /** | ||||
* 发票已被其他公众号锁定 | |||||
* 发票已被其他公众号锁定. | |||||
*/ | */ | ||||
CODE_72023(72023, "发票已被其他公众号锁定"), | CODE_72023(72023, "发票已被其他公众号锁定"), | ||||
/** | /** | ||||
* 发票状态错误;reimburse_status状态错误,参考:更新发票状态 | |||||
* 发票状态错误;reimburse_status状态错误,参考:更新发票状态. | |||||
*/ | */ | ||||
CODE_72024(72024, "发票状态错误;reimburse_status状态错误,参考:更新发票状态"), | CODE_72024(72024, "发票状态错误;reimburse_status状态错误,参考:更新发票状态"), | ||||
/** | /** | ||||
* 存在发票不属于该用户;只能批量更新该openid的发票,参考:批量更新发票状态 | |||||
* 存在发票不属于该用户;只能批量更新该openid的发票,参考:批量更新发票状态. | |||||
*/ | */ | ||||
CODE_72037(72037, "存在发票不属于该用户;只能批量更新该openid的发票,参考:批量更新发票状态"), | CODE_72037(72037, "存在发票不属于该用户;只能批量更新该openid的发票,参考:批量更新发票状态"), | ||||
/** | /** | ||||
* 可信域名不正确,或者无ICP备案 | |||||
* 可信域名不正确,或者无ICP备案. | |||||
*/ | */ | ||||
CODE_80001(80001, "可信域名不正确,或者无ICP备案"), | CODE_80001(80001, "可信域名不正确,或者无ICP备案"), | ||||
/** | /** | ||||
* 部门下的结点数超过限制(3W) | |||||
* 部门下的结点数超过限制(3W). | |||||
*/ | */ | ||||
CODE_81001(81001, "部门下的结点数超过限制(3W)"), | CODE_81001(81001, "部门下的结点数超过限制(3W)"), | ||||
/** | /** | ||||
* 部门最多15层 | |||||
* 部门最多15层. | |||||
*/ | */ | ||||
CODE_81002(81002, "部门最多15层"), | CODE_81002(81002, "部门最多15层"), | ||||
/** | /** | ||||
* 无权限操作标签 | |||||
* 无权限操作标签. | |||||
*/ | */ | ||||
CODE_81011(81011, "无权限操作标签"), | CODE_81011(81011, "无权限操作标签"), | ||||
/** | /** | ||||
* UserID、部门ID、标签ID全部非法或无权限 | |||||
* UserID、部门ID、标签ID全部非法或无权限. | |||||
*/ | */ | ||||
CODE_81013(81013, "UserID、部门ID、标签ID全部非法或无权限"), | CODE_81013(81013, "UserID、部门ID、标签ID全部非法或无权限"), | ||||
/** | /** | ||||
* 标签添加成员,单次添加user或party过多 | |||||
* 标签添加成员,单次添加user或party过多. | |||||
*/ | */ | ||||
CODE_81014(81014, "标签添加成员,单次添加user或party过多"), | CODE_81014(81014, "标签添加成员,单次添加user或party过多"), | ||||
/** | /** | ||||
* 指定的成员/部门/标签全部无效 | |||||
* 指定的成员/部门/标签全部无效. | |||||
*/ | */ | ||||
CODE_82001(82001, "指定的成员/部门/标签全部无效"), | CODE_82001(82001, "指定的成员/部门/标签全部无效"), | ||||
/** | /** | ||||
* 不合法的PartyID列表长度;发消息,单次不能超过100个部门 | |||||
* 不合法的PartyID列表长度;发消息,单次不能超过100个部门. | |||||
*/ | */ | ||||
CODE_82002(82002, "不合法的PartyID列表长度;发消息,单次不能超过100个部门"), | CODE_82002(82002, "不合法的PartyID列表长度;发消息,单次不能超过100个部门"), | ||||
/** | /** | ||||
* 不合法的TagID列表长度;发消息,单次不能超过100个标签 | |||||
* 不合法的TagID列表长度;发消息,单次不能超过100个标签. | |||||
*/ | */ | ||||
CODE_82003(82003, "不合法的TagID列表长度;发消息,单次不能超过100个标签"), | CODE_82003(82003, "不合法的TagID列表长度;发消息,单次不能超过100个标签"), | ||||
/** | /** | ||||
* 成员票据过期 | |||||
* 成员票据过期. | |||||
*/ | */ | ||||
CODE_84014(84014, "成员票据过期"), | CODE_84014(84014, "成员票据过期"), | ||||
/** | /** | ||||
* 成员票据无效;确认user_ticket参数来源是否正确。参考接口:根据code获取成员信息 | |||||
* 成员票据无效;确认user_ticket参数来源是否正确。参考接口:根据code获取成员信息. | |||||
*/ | */ | ||||
CODE_84015(84015, "成员票据无效;确认user_ticket参数来源是否正确。参考接口:根据code获取成员信息"), | CODE_84015(84015, "成员票据无效;确认user_ticket参数来源是否正确。参考接口:根据code获取成员信息"), | ||||
/** | /** | ||||
* 缺少templateid参数 | |||||
* 缺少templateid参数. | |||||
*/ | */ | ||||
CODE_84019(84019, "缺少templateid参数"), | CODE_84019(84019, "缺少templateid参数"), | ||||
/** | /** | ||||
* templateid不存在;确认参数是否有带,并且已创建 | |||||
* templateid不存在;确认参数是否有带,并且已创建. | |||||
*/ | */ | ||||
CODE_84020(84020, "templateid不存在;确认参数是否有带,并且已创建"), | CODE_84020(84020, "templateid不存在;确认参数是否有带,并且已创建"), | ||||
/** | /** | ||||
* 缺少register_code参数 | |||||
* 缺少register_code参数. | |||||
*/ | */ | ||||
CODE_84021(84021, "缺少register_code参数"), | CODE_84021(84021, "缺少register_code参数"), | ||||
/** | /** | ||||
* 无效的register_code参数 | |||||
* 无效的register_code参数. | |||||
*/ | */ | ||||
CODE_84022(84022, "无效的register_code参数"), | CODE_84022(84022, "无效的register_code参数"), | ||||
/** | /** | ||||
* 不允许调用设置通讯录同步完成接口 | |||||
* 不允许调用设置通讯录同步完成接口. | |||||
*/ | */ | ||||
CODE_84023(84023, "不允许调用设置通讯录同步完成接口"), | CODE_84023(84023, "不允许调用设置通讯录同步完成接口"), | ||||
/** | /** | ||||
* 无注册信息 | |||||
* 无注册信息. | |||||
*/ | */ | ||||
CODE_84024(84024, "无注册信息"), | CODE_84024(84024, "无注册信息"), | ||||
/** | /** | ||||
* 不符合的state参数;必须是[a-zA-Z0-9]的参数值,长度不可超过128个字节 | |||||
* 不符合的state参数;必须是[a-zA-Z0-9]的参数值,长度不可超过128个字节. | |||||
*/ | */ | ||||
CODE_84025(84025, "不符合的state参数;必须是[a-zA-Z0-9]的参数值,长度不可超过128个字节"), | CODE_84025(84025, "不符合的state参数;必须是[a-zA-Z0-9]的参数值,长度不可超过128个字节"), | ||||
/** | /** | ||||
* 包含不合法的词语 | |||||
* 包含不合法的词语. | |||||
*/ | */ | ||||
CODE_85002(85002, "包含不合法的词语"), | CODE_85002(85002, "包含不合法的词语"), | ||||
/** | /** | ||||
* 每企业每个月设置的可信域名不可超过20个 | |||||
* 每企业每个月设置的可信域名不可超过20个. | |||||
*/ | */ | ||||
CODE_85004(85004, "每企业每个月设置的可信域名不可超过20个"), | CODE_85004(85004, "每企业每个月设置的可信域名不可超过20个"), | ||||
/** | /** | ||||
* 可信域名未通过所有权校验 | |||||
* 可信域名未通过所有权校验. | |||||
*/ | */ | ||||
CODE_85005(85005, "可信域名未通过所有权校验"), | CODE_85005(85005, "可信域名未通过所有权校验"), | ||||
/** | /** | ||||
* 参数 chatid 不合法 | |||||
* 参数 chatid 不合法. | |||||
*/ | */ | ||||
CODE_86001(86001, "参数 chatid 不合法"), | CODE_86001(86001, "参数 chatid 不合法"), | ||||
/** | /** | ||||
* 参数 chatid 不存在 | |||||
* 参数 chatid 不存在. | |||||
*/ | */ | ||||
CODE_86003(86003, "参数 chatid 不存在"), | CODE_86003(86003, "参数 chatid 不存在"), | ||||
/** | /** | ||||
* 参数 群名不合法 | |||||
* 参数 群名不合法. | |||||
*/ | */ | ||||
CODE_86004(86004, "参数 群名不合法"), | CODE_86004(86004, "参数 群名不合法"), | ||||
/** | /** | ||||
* 参数 群主不合法 | |||||
* 参数 群主不合法. | |||||
*/ | */ | ||||
CODE_86005(86005, "参数 群主不合法"), | CODE_86005(86005, "参数 群主不合法"), | ||||
/** | /** | ||||
* 群成员数过多或过少 | |||||
* 群成员数过多或过少. | |||||
*/ | */ | ||||
CODE_86006(86006, "群成员数过多或过少"), | CODE_86006(86006, "群成员数过多或过少"), | ||||
/** | /** | ||||
* 不合法的群成员 | |||||
* 不合法的群成员. | |||||
*/ | */ | ||||
CODE_86007(86007, "不合法的群成员"), | CODE_86007(86007, "不合法的群成员"), | ||||
/** | /** | ||||
* 非法操作非自己创建的群 | |||||
* 非法操作非自己创建的群. | |||||
*/ | */ | ||||
CODE_86008(86008, "非法操作非自己创建的群"), | CODE_86008(86008, "非法操作非自己创建的群"), | ||||
/** | /** | ||||
* 存在非法会话成员ID | |||||
* 存在非法会话成员ID. | |||||
*/ | */ | ||||
CODE_86216(86216, "存在非法会话成员ID"), | CODE_86216(86216, "存在非法会话成员ID"), | ||||
/** | /** | ||||
* 会话发送者不在会话成员列表中;会话的发送者,必须是会话的成员列表之一 | |||||
* 会话发送者不在会话成员列表中;会话的发送者,必须是会话的成员列表之一. | |||||
*/ | */ | ||||
CODE_86217(86217, "会话发送者不在会话成员列表中;会话的发送者,必须是会话的成员列表之一"), | CODE_86217(86217, "会话发送者不在会话成员列表中;会话的发送者,必须是会话的成员列表之一"), | ||||
/** | /** | ||||
* 指定的会话参数不合法 | |||||
* 指定的会话参数不合法. | |||||
*/ | */ | ||||
CODE_86220(86220, "指定的会话参数不合法"), | CODE_86220(86220, "指定的会话参数不合法"), | ||||
/** | /** | ||||
* 未认证摇一摇周边 | |||||
* 未认证摇一摇周边. | |||||
*/ | */ | ||||
CODE_90001(90001, "未认证摇一摇周边"), | CODE_90001(90001, "未认证摇一摇周边"), | ||||
/** | /** | ||||
* 缺少摇一摇周边ticket参数 | |||||
* 缺少摇一摇周边ticket参数. | |||||
*/ | */ | ||||
CODE_90002(90002, "缺少摇一摇周边ticket参数"), | CODE_90002(90002, "缺少摇一摇周边ticket参数"), | ||||
/** | /** | ||||
* 摇一摇周边ticket参数不合法 | |||||
* 摇一摇周边ticket参数不合法. | |||||
*/ | */ | ||||
CODE_90003(90003, "摇一摇周边ticket参数不合法"), | CODE_90003(90003, "摇一摇周边ticket参数不合法"), | ||||
/** | /** | ||||
* 非法的对外属性类型 | |||||
* 非法的对外属性类型. | |||||
*/ | */ | ||||
CODE_90100(90100, "非法的对外属性类型"), | CODE_90100(90100, "非法的对外属性类型"), | ||||
/** | /** | ||||
* 对外属性:文本类型长度不合法;文本长度不可超过12个UTF8字符 | |||||
* 对外属性:文本类型长度不合法;文本长度不可超过12个UTF8字符. | |||||
*/ | */ | ||||
CODE_90101(90101, "对外属性:文本类型长度不合法;文本长度不可超过12个UTF8字符"), | CODE_90101(90101, "对外属性:文本类型长度不合法;文本长度不可超过12个UTF8字符"), | ||||
/** | /** | ||||
* 对外属性:网页类型标题长度不合法;标题长度不可超过12个UTF8字符 | |||||
* 对外属性:网页类型标题长度不合法;标题长度不可超过12个UTF8字符. | |||||
*/ | */ | ||||
CODE_90102(90102, "对外属性:网页类型标题长度不合法;标题长度不可超过12个UTF8字符"), | CODE_90102(90102, "对外属性:网页类型标题长度不合法;标题长度不可超过12个UTF8字符"), | ||||
/** | /** | ||||
* 对外属性:网页url不合法 | |||||
* 对外属性:网页url不合法. | |||||
*/ | */ | ||||
CODE_90103(90103, "对外属性:网页url不合法"), | CODE_90103(90103, "对外属性:网页url不合法"), | ||||
/** | /** | ||||
* 对外属性:小程序类型标题长度不合法;标题长度不可超过12个UTF8字符 | |||||
* 对外属性:小程序类型标题长度不合法;标题长度不可超过12个UTF8字符. | |||||
*/ | */ | ||||
CODE_90104(90104, "对外属性:小程序类型标题长度不合法;标题长度不可超过12个UTF8字符"), | CODE_90104(90104, "对外属性:小程序类型标题长度不合法;标题长度不可超过12个UTF8字符"), | ||||
/** | /** | ||||
* 对外属性:小程序类型pagepath不合法 | |||||
* 对外属性:小程序类型pagepath不合法. | |||||
*/ | */ | ||||
CODE_90105(90105, "对外属性:小程序类型pagepath不合法"), | CODE_90105(90105, "对外属性:小程序类型pagepath不合法"), | ||||
/** | /** | ||||
* 对外属性:请求参数不合法 | |||||
* 对外属性:请求参数不合法. | |||||
*/ | */ | ||||
CODE_90106(90106, "对外属性:请求参数不合法"), | CODE_90106(90106, "对外属性:请求参数不合法"), | ||||
/** | /** | ||||
* 获取ticket的类型无效 | |||||
* 获取ticket的类型无效. | |||||
*/ | */ | ||||
CODE_91040(91040, "获取ticket的类型无效"), | CODE_91040(91040, "获取ticket的类型无效"), | ||||
/** | /** | ||||
* 无权限操作指定的应用 | |||||
* 无权限操作指定的应用. | |||||
*/ | */ | ||||
CODE_301002(301002, "无权限操作指定的应用"), | CODE_301002(301002, "无权限操作指定的应用"), | ||||
/** | /** | ||||
* 不允许删除创建者;创建者不允许从通讯录中删除。如果需要删除该成员,需要先在WEB管理端转移创建者身份。 | |||||
* 不允许删除创建者;创建者不允许从通讯录中删除。如果需要删除该成员,需要先在WEB管理端转移创建者身份. | |||||
*/ | */ | ||||
CODE_301005(301005, "不允许删除创建者;创建者不允许从通讯录中删除。如果需要删除该成员,需要先在WEB管理端转移创建者身份。"), | CODE_301005(301005, "不允许删除创建者;创建者不允许从通讯录中删除。如果需要删除该成员,需要先在WEB管理端转移创建者身份。"), | ||||
/** | /** | ||||
* 参数 position 不合法;长度不允许超过128个字符 | |||||
* 参数 position 不合法;长度不允许超过128个字符. | |||||
*/ | */ | ||||
CODE_301012(301012, "参数 position 不合法;长度不允许超过128个字符"), | CODE_301012(301012, "参数 position 不合法;长度不允许超过128个字符"), | ||||
/** | /** | ||||
* 参数 telephone 不合法;telephone必须由1-32位的纯数字或’-‘号组成。 | |||||
* 参数 telephone 不合法;telephone必须由1-32位的纯数字或’-‘号组成. | |||||
*/ | */ | ||||
CODE_301013(301013, "参数 telephone 不合法;telephone必须由1-32位的纯数字或’-‘号组成。"), | CODE_301013(301013, "参数 telephone 不合法;telephone必须由1-32位的纯数字或’-‘号组成。"), | ||||
/** | /** | ||||
* 参数 english_name 不合法;参数如果有传递,不允许为空字符串,同时不能超过64字节,只能是由字母、数字、点(.)、减号(-)、空格或下划线(_)组成 | |||||
* 参数 english_name 不合法;参数如果有传递,不允许为空字符串,同时不能超过64字节,只能是由字母、数字、点(.)、减号(-)、空格或下划线(_)组成. | |||||
*/ | */ | ||||
CODE_301014(301014, "参数 english_name 不合法;参数如果有传递,不允许为空字符串,同时不能超过64字节,只能是由字母、数字、点(.)、减号(-)、空格或下划线(_)组成"), | CODE_301014(301014, "参数 english_name 不合法;参数如果有传递,不允许为空字符串,同时不能超过64字节,只能是由字母、数字、点(.)、减号(-)、空格或下划线(_)组成"), | ||||
/** | /** | ||||
* 参数 mediaid 不合法;请检查 mediaid 来源,应该通过上传临时素材的图片类型获得mediaid | |||||
* 参数 mediaid 不合法;请检查 mediaid 来源,应该通过上传临时素材的图片类型获得mediaid. | |||||
*/ | */ | ||||
CODE_301015(301015, "参数 mediaid 不合法;请检查 mediaid 来源,应该通过上传临时素材的图片类型获得mediaid"), | CODE_301015(301015, "参数 mediaid 不合法;请检查 mediaid 来源,应该通过上传临时素材的图片类型获得mediaid"), | ||||
/** | /** | ||||
* 上传语音文件不符合系统要求;语音文件的系统限制,参考上传的媒体文件限制 | |||||
* 上传语音文件不符合系统要求;语音文件的系统限制,参考上传的媒体文件限制. | |||||
*/ | */ | ||||
CODE_301016(301016, "上传语音文件不符合系统要求;语音文件的系统限制,参考上传的媒体文件限制"), | CODE_301016(301016, "上传语音文件不符合系统要求;语音文件的系统限制,参考上传的媒体文件限制"), | ||||
/** | /** | ||||
* 上传语音文件仅支持AMR格式;语音文件的系统限制,参考上传的媒体文件限制 | |||||
* 上传语音文件仅支持AMR格式;语音文件的系统限制,参考上传的媒体文件限制. | |||||
*/ | */ | ||||
CODE_301017(301017, "上传语音文件仅支持AMR格式;语音文件的系统限制,参考上传的媒体文件限制"), | CODE_301017(301017, "上传语音文件仅支持AMR格式;语音文件的系统限制,参考上传的媒体文件限制"), | ||||
/** | /** | ||||
* 参数 userid 无效;至少有一个userid不存在于通讯录中 | |||||
* 参数 userid 无效;至少有一个userid不存在于通讯录中. | |||||
*/ | */ | ||||
CODE_301021(301021, "参数 userid 无效;至少有一个userid不存在于通讯录中"), | CODE_301021(301021, "参数 userid 无效;至少有一个userid不存在于通讯录中"), | ||||
/** | /** | ||||
* 获取打卡数据失败;系统失败,可重试处理 | |||||
* 获取打卡数据失败;系统失败,可重试处理. | |||||
*/ | */ | ||||
CODE_301022(301022, "获取打卡数据失败;系统失败,可重试处理"), | CODE_301022(301022, "获取打卡数据失败;系统失败,可重试处理"), | ||||
/** | /** | ||||
* useridlist非法或超过限额;列表数量不能为0且不超过100 | |||||
* useridlist非法或超过限额;列表数量不能为0且不超过100. | |||||
*/ | */ | ||||
CODE_301023(301023, "useridlist非法或超过限额;列表数量不能为0且不超过100"), | CODE_301023(301023, "useridlist非法或超过限额;列表数量不能为0且不超过100"), | ||||
/** | /** | ||||
* 获取打卡记录时间间隔超限;保证开始时间大于0 且结束时间大于 0 且结束时间大于开始时间,且间隔少于93天 | |||||
* 获取打卡记录时间间隔超限;保证开始时间大于0 且结束时间大于 0 且结束时间大于开始时间,且间隔少于93天. | |||||
*/ | */ | ||||
CODE_301024(301024, "获取打卡记录时间间隔超限;保证开始时间大于0 且结束时间大于 0 且结束时间大于开始时间,且间隔少于93天"), | CODE_301024(301024, "获取打卡记录时间间隔超限;保证开始时间大于0 且结束时间大于 0 且结束时间大于开始时间,且间隔少于93天"), | ||||
/** | /** | ||||
* 不允许更新该用户的userid | |||||
* 不允许更新该用户的userid. | |||||
*/ | */ | ||||
CODE_301036(301036, "不允许更新该用户的userid"), | CODE_301036(301036, "不允许更新该用户的userid"), | ||||
/** | /** | ||||
* 批量导入任务的文件中userid有重复 | |||||
* 批量导入任务的文件中userid有重复. | |||||
*/ | */ | ||||
CODE_302003(302003, "批量导入任务的文件中userid有重复"), | CODE_302003(302003, "批量导入任务的文件中userid有重复"), | ||||
/** | /** | ||||
* 组织架构不合法(1不是一棵树,2 多个一样的partyid,3 partyid空,4 partyid name 空,5 同一个父节点下有两个子节点 部门名字一样 可能是以上情况,请一一排查) | |||||
* 组织架构不合法(1不是一棵树,2 多个一样的partyid,3 partyid空,4 partyid name 空,5 同一个父节点下有两个子节点 部门名字一样 可能是以上情况,请一一排查). | |||||
*/ | */ | ||||
CODE_302004(302004, "组织架构不合法(1不是一棵树,2 多个一样的partyid,3 partyid空,4 partyid name 空,5 同一个父节点下有两个子节点 部门名字一样 可能是以上情况,请一一排查)"), | CODE_302004(302004, "组织架构不合法(1不是一棵树,2 多个一样的partyid,3 partyid空,4 partyid name 空,5 同一个父节点下有两个子节点 部门名字一样 可能是以上情况,请一一排查)"), | ||||
/** | /** | ||||
* 批量导入系统失败,请重新尝试导入 | |||||
* 批量导入系统失败,请重新尝试导入. | |||||
*/ | */ | ||||
CODE_302005(302005, "批量导入系统失败,请重新尝试导入"), | CODE_302005(302005, "批量导入系统失败,请重新尝试导入"), | ||||
/** | /** | ||||
* 批量导入任务的文件中partyid有重复 | |||||
* 批量导入任务的文件中partyid有重复. | |||||
*/ | */ | ||||
CODE_302006(302006, "批量导入任务的文件中partyid有重复"), | CODE_302006(302006, "批量导入任务的文件中partyid有重复"), | ||||
/** | /** | ||||
* 批量导入任务的文件中,同一个部门下有两个子部门名字一样 | |||||
* 批量导入任务的文件中,同一个部门下有两个子部门名字一样. | |||||
*/ | */ | ||||
CODE_302007(302007, "批量导入任务的文件中,同一个部门下有两个子部门名字一样"), | CODE_302007(302007, "批量导入任务的文件中,同一个部门下有两个子部门名字一样"), | ||||
/** | /** | ||||
* CorpId参数无效;指定的CorpId不存在 | |||||
* CorpId参数无效;指定的CorpId不存在. | |||||
*/ | */ | ||||
CODE_2000002(2000002, "CorpId参数无效;指定的CorpId不存在"); | CODE_2000002(2000002, "CorpId参数无效;指定的CorpId不存在"); | ||||
@@ -791,7 +791,7 @@ public enum WxCpErrorMsgEnum { | |||||
} | } | ||||
/** | /** | ||||
* 通过错误代码查找其中文含义. | |||||
* 通过错误代码查找其中文含义.. | |||||
*/ | */ | ||||
public static String findMsgByCode(int code) { | public static String findMsgByCode(int code) { | ||||
for (WxCpErrorMsgEnum value : WxCpErrorMsgEnum.values()) { | for (WxCpErrorMsgEnum value : WxCpErrorMsgEnum.values()) { | ||||
@@ -1,13 +1,12 @@ | |||||
package me.chanjar.weixin.common.error; | package me.chanjar.weixin.common.error; | ||||
import java.io.Serializable; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import lombok.Builder; | import lombok.Builder; | ||||
import lombok.Data; | import lombok.Data; | ||||
import me.chanjar.weixin.common.WxType; | import me.chanjar.weixin.common.WxType; | ||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | import me.chanjar.weixin.common.util.json.WxGsonBuilder; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.io.Serializable; | |||||
/** | /** | ||||
* 微信错误码. | * 微信错误码. | ||||
@@ -46,29 +45,38 @@ public class WxError implements Serializable { | |||||
public static WxError fromJson(String json, WxType type) { | public static WxError fromJson(String json, WxType type) { | ||||
final WxError wxError = WxGsonBuilder.create().fromJson(json, WxError.class); | final WxError wxError = WxGsonBuilder.create().fromJson(json, WxError.class); | ||||
if (StringUtils.isNotEmpty(wxError.getErrorMsg())) { | |||||
wxError.setErrorMsgEn(wxError.getErrorMsg()); | |||||
if (wxError.getErrorCode() == 0 || type == null) { | |||||
return wxError; | |||||
} | } | ||||
if (type == null) { | |||||
return wxError; | |||||
if (StringUtils.isNotEmpty(wxError.getErrorMsg())) { | |||||
wxError.setErrorMsgEn(wxError.getErrorMsg()); | |||||
} | } | ||||
if (type == WxType.MP) { | |||||
final String msg = WxMpErrorMsgEnum.findMsgByCode(wxError.getErrorCode()); | |||||
if (msg != null) { | |||||
wxError.setErrorMsg(msg); | |||||
switch (type) { | |||||
case MP: { | |||||
final String msg = WxMpErrorMsgEnum.findMsgByCode(wxError.getErrorCode()); | |||||
if (msg != null) { | |||||
wxError.setErrorMsg(msg); | |||||
} | |||||
break; | |||||
} | } | ||||
} else if (type == WxType.CP) { | |||||
final String msg = WxCpErrorMsgEnum.findMsgByCode(wxError.getErrorCode()); | |||||
if (msg != null) { | |||||
wxError.setErrorMsg(msg); | |||||
case CP: { | |||||
final String msg = WxCpErrorMsgEnum.findMsgByCode(wxError.getErrorCode()); | |||||
if (msg != null) { | |||||
wxError.setErrorMsg(msg); | |||||
} | |||||
break; | |||||
} | } | ||||
} else if (type == WxType.MiniApp) { | |||||
case MiniApp: { | |||||
final String msg = WxMaErrorMsgEnum.findMsgByCode(wxError.getErrorCode()); | final String msg = WxMaErrorMsgEnum.findMsgByCode(wxError.getErrorCode()); | ||||
if (msg != null) { | if (msg != null) { | ||||
wxError.setErrorMsg(msg); | wxError.setErrorMsg(msg); | ||||
} | } | ||||
break; | |||||
} | |||||
default: | |||||
return wxError; | |||||
} | } | ||||
return wxError; | return wxError; | ||||
@@ -76,10 +84,11 @@ public class WxError implements Serializable { | |||||
@Override | @Override | ||||
public String toString() { | public String toString() { | ||||
if (this.json != null) { | |||||
return this.json; | |||||
if (this.json == null) { | |||||
return "错误代码:" + this.errorCode + ", 错误信息:" + this.errorMsg; | |||||
} | } | ||||
return "错误: Code=" + this.errorCode + ", Msg=" + this.errorMsg; | |||||
return "错误代码:" + this.errorCode + ", 错误信息:" + this.errorMsg + ",微信原始报文:" + this.json; | |||||
} | } | ||||
} | } |
@@ -14,619 +14,623 @@ import lombok.Getter; | |||||
@Getter | @Getter | ||||
public enum WxMpErrorMsgEnum { | public enum WxMpErrorMsgEnum { | ||||
/** | /** | ||||
* 系统繁忙,此时请开发者稍候再试 | |||||
* 系统繁忙,此时请开发者稍候再试. | |||||
*/ | */ | ||||
CODE_1(-1, "系统繁忙,此时请开发者稍候再试"), | CODE_1(-1, "系统繁忙,此时请开发者稍候再试"), | ||||
/** | /** | ||||
* 请求成功 | |||||
* 请求成功. | |||||
*/ | */ | ||||
CODE_0(0, "请求成功"), | CODE_0(0, "请求成功"), | ||||
/** | /** | ||||
* 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口 | |||||
* 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口. | |||||
*/ | */ | ||||
CODE_40001(40001, "获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口"), | CODE_40001(40001, "获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口"), | ||||
/** | /** | ||||
* 不合法的凭证类型 | |||||
* 不合法的凭证类型. | |||||
*/ | */ | ||||
CODE_40002(40002, "不合法的凭证类型"), | CODE_40002(40002, "不合法的凭证类型"), | ||||
/** | /** | ||||
* 不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID | |||||
* 不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID. | |||||
*/ | */ | ||||
CODE_40003(40003, "不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID"), | CODE_40003(40003, "不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID"), | ||||
/** | /** | ||||
* 不合法的媒体文件类型 | |||||
* 不合法的媒体文件类型. | |||||
*/ | */ | ||||
CODE_40004(40004, "不合法的媒体文件类型"), | CODE_40004(40004, "不合法的媒体文件类型"), | ||||
/** | /** | ||||
* 不合法的文件类型 | |||||
* 不合法的文件类型. | |||||
*/ | */ | ||||
CODE_40005(40005, "不合法的文件类型"), | CODE_40005(40005, "不合法的文件类型"), | ||||
/** | /** | ||||
* 不合法的文件大小 | |||||
* 不合法的文件大小. | |||||
*/ | */ | ||||
CODE_40006(40006, "不合法的文件大小"), | CODE_40006(40006, "不合法的文件大小"), | ||||
/** | /** | ||||
* 不合法的媒体文件 id | |||||
* 不合法的媒体文件 id. | |||||
*/ | */ | ||||
CODE_40007(40007, "不合法的媒体文件 id"), | CODE_40007(40007, "不合法的媒体文件 id"), | ||||
/** | /** | ||||
* 不合法的消息类型 | |||||
* 不合法的消息类型. | |||||
*/ | */ | ||||
CODE_40008(40008, "不合法的消息类型"), | CODE_40008(40008, "不合法的消息类型"), | ||||
/** | /** | ||||
* 不合法的图片文件大小 | |||||
* 不合法的图片文件大小. | |||||
*/ | */ | ||||
CODE_40009(40009, "不合法的图片文件大小"), | CODE_40009(40009, "不合法的图片文件大小"), | ||||
/** | /** | ||||
* 不合法的语音文件大小 | |||||
* 不合法的语音文件大小. | |||||
*/ | */ | ||||
CODE_40010(40010, "不合法的语音文件大小"), | CODE_40010(40010, "不合法的语音文件大小"), | ||||
/** | /** | ||||
* 不合法的视频文件大小 | |||||
* 不合法的视频文件大小. | |||||
*/ | */ | ||||
CODE_40011(40011, "不合法的视频文件大小"), | CODE_40011(40011, "不合法的视频文件大小"), | ||||
/** | /** | ||||
* 不合法的缩略图文件大小 | |||||
* 不合法的缩略图文件大小. | |||||
*/ | */ | ||||
CODE_40012(40012, "不合法的缩略图文件大小"), | CODE_40012(40012, "不合法的缩略图文件大小"), | ||||
/** | /** | ||||
* 不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写 | |||||
* 不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写. | |||||
*/ | */ | ||||
CODE_40013(40013, "不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写"), | CODE_40013(40013, "不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写"), | ||||
/** | /** | ||||
* 不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口 | |||||
* 不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口. | |||||
*/ | */ | ||||
CODE_40014(40014, "不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口"), | CODE_40014(40014, "不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口"), | ||||
/** | /** | ||||
* 不合法的菜单类型 | |||||
* 不合法的菜单类型. | |||||
*/ | */ | ||||
CODE_40015(40015, "不合法的菜单类型"), | CODE_40015(40015, "不合法的菜单类型"), | ||||
/** | /** | ||||
* 不合法的按钮个数 | |||||
* 不合法的按钮个数. | |||||
*/ | */ | ||||
CODE_40016(40016, "不合法的按钮个数"), | CODE_40016(40016, "不合法的按钮个数"), | ||||
/** | /** | ||||
* 不合法的按钮个数 | |||||
* 不合法的按钮个数. | |||||
*/ | */ | ||||
CODE_40017(40017, "不合法的按钮个数"), | CODE_40017(40017, "不合法的按钮个数"), | ||||
/** | /** | ||||
* 不合法的按钮名字长度 | |||||
* 不合法的按钮名字长度. | |||||
*/ | */ | ||||
CODE_40018(40018, "不合法的按钮名字长度"), | CODE_40018(40018, "不合法的按钮名字长度"), | ||||
/** | /** | ||||
* 不合法的按钮 KEY 长度 | |||||
* 不合法的按钮 KEY 长度. | |||||
*/ | */ | ||||
CODE_40019(40019, "不合法的按钮 KEY 长度"), | CODE_40019(40019, "不合法的按钮 KEY 长度"), | ||||
/** | /** | ||||
* 不合法的按钮 URL 长度 | |||||
* 不合法的按钮 URL 长度. | |||||
*/ | */ | ||||
CODE_40020(40020, "不合法的按钮 URL 长度"), | CODE_40020(40020, "不合法的按钮 URL 长度"), | ||||
/** | /** | ||||
* 不合法的菜单版本号 | |||||
* 不合法的菜单版本号. | |||||
*/ | */ | ||||
CODE_40021(40021, "不合法的菜单版本号"), | CODE_40021(40021, "不合法的菜单版本号"), | ||||
/** | /** | ||||
* 不合法的子菜单级数 | |||||
* 不合法的子菜单级数. | |||||
*/ | */ | ||||
CODE_40022(40022, "不合法的子菜单级数"), | CODE_40022(40022, "不合法的子菜单级数"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮个数 | |||||
* 不合法的子菜单按钮个数. | |||||
*/ | */ | ||||
CODE_40023(40023, "不合法的子菜单按钮个数"), | CODE_40023(40023, "不合法的子菜单按钮个数"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮类型 | |||||
* 不合法的子菜单按钮类型. | |||||
*/ | */ | ||||
CODE_40024(40024, "不合法的子菜单按钮类型"), | CODE_40024(40024, "不合法的子菜单按钮类型"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮名字长度 | |||||
* 不合法的子菜单按钮名字长度. | |||||
*/ | */ | ||||
CODE_40025(40025, "不合法的子菜单按钮名字长度"), | CODE_40025(40025, "不合法的子菜单按钮名字长度"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮 KEY 长度 | |||||
* 不合法的子菜单按钮 KEY 长度. | |||||
*/ | */ | ||||
CODE_40026(40026, "不合法的子菜单按钮 KEY 长度"), | CODE_40026(40026, "不合法的子菜单按钮 KEY 长度"), | ||||
/** | /** | ||||
* 不合法的子菜单按钮 URL 长度 | |||||
* 不合法的子菜单按钮 URL 长度. | |||||
*/ | */ | ||||
CODE_40027(40027, "不合法的子菜单按钮 URL 长度"), | CODE_40027(40027, "不合法的子菜单按钮 URL 长度"), | ||||
/** | /** | ||||
* 不合法的自定义菜单使用用户 | |||||
* 不合法的自定义菜单使用用户. | |||||
*/ | */ | ||||
CODE_40028(40028, "不合法的自定义菜单使用用户"), | CODE_40028(40028, "不合法的自定义菜单使用用户"), | ||||
/** | /** | ||||
* 不合法的 oauth_code | |||||
* 不合法的 oauth_code. | |||||
*/ | */ | ||||
CODE_40029(40029, "不合法的 oauth_code"), | CODE_40029(40029, "不合法的 oauth_code"), | ||||
/** | /** | ||||
* 不合法的 refresh_token | |||||
* 不合法的 refresh_token. | |||||
*/ | */ | ||||
CODE_40030(40030, "不合法的 refresh_token"), | CODE_40030(40030, "不合法的 refresh_token"), | ||||
/** | /** | ||||
* 不合法的 openid 列表 | |||||
* 不合法的 openid 列表. | |||||
*/ | */ | ||||
CODE_40031(40031, "不合法的 openid 列表"), | CODE_40031(40031, "不合法的 openid 列表"), | ||||
/** | /** | ||||
* 不合法的 openid 列表长度 | |||||
* 不合法的 openid 列表长度. | |||||
*/ | */ | ||||
CODE_40032(40032, "不合法的 openid 列表长度"), | CODE_40032(40032, "不合法的 openid 列表长度"), | ||||
/** | /** | ||||
* 不合法的请求字符,不能包含\\uxxxx 格式的字符 | |||||
* 不合法的请求字符,不能包含\\uxxxx 格式的字符. | |||||
*/ | */ | ||||
CODE_40033(40033, "不合法的请求字符,不能包含\\uxxxx 格式的字符"), | CODE_40033(40033, "不合法的请求字符,不能包含\\uxxxx 格式的字符"), | ||||
/** | /** | ||||
* 不合法的参数 | |||||
* 不合法的参数. | |||||
*/ | */ | ||||
CODE_40035(40035, "不合法的参数"), | CODE_40035(40035, "不合法的参数"), | ||||
/** | /** | ||||
* 不合法的请求格式 | |||||
* 不合法的请求格式. | |||||
*/ | */ | ||||
CODE_40038(40038, "不合法的请求格式"), | CODE_40038(40038, "不合法的请求格式"), | ||||
/** | /** | ||||
* 不合法的 URL 长度 | |||||
* 不合法的 URL 长度. | |||||
*/ | */ | ||||
CODE_40039(40039, "不合法的 URL 长度"), | CODE_40039(40039, "不合法的 URL 长度"), | ||||
/** | /** | ||||
* 不合法的分组 id | |||||
* 不合法的分组 id. | |||||
*/ | */ | ||||
CODE_40050(40050, "不合法的分组 id"), | CODE_40050(40050, "不合法的分组 id"), | ||||
/** | /** | ||||
* 分组名字不合法 | |||||
* 分组名字不合法. | |||||
*/ | */ | ||||
CODE_40051(40051, "分组名字不合法"), | CODE_40051(40051, "分组名字不合法"), | ||||
/** | /** | ||||
* 删除单篇图文时,指定的 article_idx 不合法 | |||||
* 删除单篇图文时,指定的 article_idx 不合法. | |||||
*/ | */ | ||||
CODE_40060(40060, "删除单篇图文时,指定的 article_idx 不合法"), | CODE_40060(40060, "删除单篇图文时,指定的 article_idx 不合法"), | ||||
/** | /** | ||||
* 分组名字不合法 | |||||
* 分组名字不合法. | |||||
*/ | */ | ||||
CODE_40117(40117, "分组名字不合法"), | CODE_40117(40117, "分组名字不合法"), | ||||
/** | /** | ||||
* media_id 大小不合法 | |||||
* media_id 大小不合法. | |||||
*/ | */ | ||||
CODE_40118(40118, "media_id 大小不合法"), | CODE_40118(40118, "media_id 大小不合法"), | ||||
/** | /** | ||||
* button 类型错误 | |||||
* button 类型错误. | |||||
*/ | */ | ||||
CODE_40119(40119, "button 类型错误"), | CODE_40119(40119, "button 类型错误"), | ||||
/** | /** | ||||
* button 类型错误 | |||||
* button 类型错误. | |||||
*/ | */ | ||||
CODE_40120(40120, "button 类型错误"), | CODE_40120(40120, "button 类型错误"), | ||||
/** | /** | ||||
* 不合法的 media_id 类型 | |||||
* 不合法的 media_id 类型. | |||||
*/ | */ | ||||
CODE_40121(40121, "不合法的 media_id 类型"), | CODE_40121(40121, "不合法的 media_id 类型"), | ||||
/** | /** | ||||
* 微信号不合法 | |||||
* 微信号不合法. | |||||
*/ | */ | ||||
CODE_40132(40132, "微信号不合法"), | CODE_40132(40132, "微信号不合法"), | ||||
/** | /** | ||||
* 不支持的图片格式 | |||||
* 不支持的图片格式. | |||||
*/ | */ | ||||
CODE_40137(40137, "不支持的图片格式"), | CODE_40137(40137, "不支持的图片格式"), | ||||
/** | /** | ||||
* 请勿添加其他公众号的主页链接 | |||||
* 请勿添加其他公众号的主页链接. | |||||
*/ | */ | ||||
CODE_40155(40155, "请勿添加其他公众号的主页链接"), | CODE_40155(40155, "请勿添加其他公众号的主页链接"), | ||||
/** | /** | ||||
* 缺少 access_token 参数 | |||||
* 缺少 access_token 参数. | |||||
*/ | */ | ||||
CODE_41001(41001, "缺少 access_token 参数"), | CODE_41001(41001, "缺少 access_token 参数"), | ||||
/** | /** | ||||
* 缺少 appid 参数 | |||||
* 缺少 appid 参数. | |||||
*/ | */ | ||||
CODE_41002(41002, "缺少 appid 参数"), | CODE_41002(41002, "缺少 appid 参数"), | ||||
/** | /** | ||||
* 缺少 refresh_token 参数 | |||||
* 缺少 refresh_token 参数. | |||||
*/ | */ | ||||
CODE_41003(41003, "缺少 refresh_token 参数"), | CODE_41003(41003, "缺少 refresh_token 参数"), | ||||
/** | /** | ||||
* 缺少 secret 参数 | |||||
* 缺少 secret 参数. | |||||
*/ | */ | ||||
CODE_41004(41004, "缺少 secret 参数"), | CODE_41004(41004, "缺少 secret 参数"), | ||||
/** | /** | ||||
* 缺少多媒体文件数据 | |||||
* 缺少多媒体文件数据. | |||||
*/ | */ | ||||
CODE_41005(41005, "缺少多媒体文件数据"), | CODE_41005(41005, "缺少多媒体文件数据"), | ||||
/** | /** | ||||
* 缺少 media_id 参数 | |||||
* 缺少 media_id 参数. | |||||
*/ | */ | ||||
CODE_41006(41006, "缺少 media_id 参数"), | CODE_41006(41006, "缺少 media_id 参数"), | ||||
/** | /** | ||||
* 缺少子菜单数据 | |||||
* 缺少子菜单数据. | |||||
*/ | */ | ||||
CODE_41007(41007, "缺少子菜单数据"), | CODE_41007(41007, "缺少子菜单数据"), | ||||
/** | /** | ||||
* 缺少 oauth code | |||||
* 缺少 oauth code. | |||||
*/ | */ | ||||
CODE_41008(41008, "缺少 oauth code"), | CODE_41008(41008, "缺少 oauth code"), | ||||
/** | /** | ||||
* 缺少 openid | |||||
* 缺少 openid. | |||||
*/ | */ | ||||
CODE_41009(41009, "缺少 openid"), | CODE_41009(41009, "缺少 openid"), | ||||
/** | /** | ||||
* access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明 | |||||
* access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明. | |||||
*/ | */ | ||||
CODE_42001(42001, "access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明"), | CODE_42001(42001, "access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明"), | ||||
/** | /** | ||||
* refresh_token 超时 | |||||
* refresh_token 超时. | |||||
*/ | */ | ||||
CODE_42002(42002, "refresh_token 超时"), | CODE_42002(42002, "refresh_token 超时"), | ||||
/** | /** | ||||
* oauth_code 超时 | |||||
* oauth_code 超时. | |||||
*/ | */ | ||||
CODE_42003(42003, "oauth_code 超时"), | CODE_42003(42003, "oauth_code 超时"), | ||||
/** | /** | ||||
* 用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权 | |||||
* 用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权. | |||||
*/ | */ | ||||
CODE_42007(42007, "用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权"), | CODE_42007(42007, "用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权"), | ||||
/** | /** | ||||
* 需要 GET 请求 | |||||
* 需要 GET 请求. | |||||
*/ | */ | ||||
CODE_43001(43001, "需要 GET 请求"), | CODE_43001(43001, "需要 GET 请求"), | ||||
/** | /** | ||||
* 需要 POST 请求 | |||||
* 需要 POST 请求. | |||||
*/ | */ | ||||
CODE_43002(43002, "需要 POST 请求"), | CODE_43002(43002, "需要 POST 请求"), | ||||
/** | /** | ||||
* 需要 HTTPS 请求 | |||||
* 需要 HTTPS 请求. | |||||
*/ | */ | ||||
CODE_43003(43003, "需要 HTTPS 请求"), | CODE_43003(43003, "需要 HTTPS 请求"), | ||||
/** | /** | ||||
* 需要接收者关注 | |||||
* 需要接收者关注. | |||||
*/ | */ | ||||
CODE_43004(43004, "需要接收者关注"), | CODE_43004(43004, "需要接收者关注"), | ||||
/** | /** | ||||
* 需要好友关系 | |||||
* 需要好友关系. | |||||
*/ | */ | ||||
CODE_43005(43005, "需要好友关系"), | CODE_43005(43005, "需要好友关系"), | ||||
/** | /** | ||||
* 需要将接收者从黑名单中移除 | |||||
* 需要将接收者从黑名单中移除. | |||||
*/ | */ | ||||
CODE_43019(43019, "需要将接收者从黑名单中移除"), | CODE_43019(43019, "需要将接收者从黑名单中移除"), | ||||
/** | /** | ||||
* 多媒体文件为空 | |||||
* 多媒体文件为空. | |||||
*/ | */ | ||||
CODE_44001(44001, "多媒体文件为空"), | CODE_44001(44001, "多媒体文件为空"), | ||||
/** | /** | ||||
* POST 的数据包为空 | |||||
* POST 的数据包为空. | |||||
*/ | */ | ||||
CODE_44002(44002, "POST 的数据包为空"), | CODE_44002(44002, "POST 的数据包为空"), | ||||
/** | /** | ||||
* 图文消息内容为空 | |||||
* 图文消息内容为空. | |||||
*/ | */ | ||||
CODE_44003(44003, "图文消息内容为空"), | CODE_44003(44003, "图文消息内容为空"), | ||||
/** | /** | ||||
* 文本消息内容为空 | |||||
* 文本消息内容为空. | |||||
*/ | */ | ||||
CODE_44004(44004, "文本消息内容为空"), | CODE_44004(44004, "文本消息内容为空"), | ||||
/** | /** | ||||
* 多媒体文件大小超过限制 | |||||
* 多媒体文件大小超过限制. | |||||
*/ | */ | ||||
CODE_45001(45001, "多媒体文件大小超过限制"), | CODE_45001(45001, "多媒体文件大小超过限制"), | ||||
/** | /** | ||||
* 消息内容超过限制 | |||||
* 消息内容超过限制. | |||||
*/ | */ | ||||
CODE_45002(45002, "消息内容超过限制"), | CODE_45002(45002, "消息内容超过限制"), | ||||
/** | /** | ||||
* 标题字段超过限制 | |||||
* 标题字段超过限制. | |||||
*/ | */ | ||||
CODE_45003(45003, "标题字段超过限制"), | CODE_45003(45003, "标题字段超过限制"), | ||||
/** | /** | ||||
* 描述字段超过限制 | |||||
* 描述字段超过限制. | |||||
*/ | */ | ||||
CODE_45004(45004, "描述字段超过限制"), | CODE_45004(45004, "描述字段超过限制"), | ||||
/** | /** | ||||
* 链接字段超过限制 | |||||
* 链接字段超过限制. | |||||
*/ | */ | ||||
CODE_45005(45005, "链接字段超过限制"), | CODE_45005(45005, "链接字段超过限制"), | ||||
/** | /** | ||||
* 图片链接字段超过限制 | |||||
* 图片链接字段超过限制. | |||||
*/ | */ | ||||
CODE_45006(45006, "图片链接字段超过限制"), | CODE_45006(45006, "图片链接字段超过限制"), | ||||
/** | /** | ||||
* 语音播放时间超过限制 | |||||
* 语音播放时间超过限制. | |||||
*/ | */ | ||||
CODE_45007(45007, "语音播放时间超过限制"), | CODE_45007(45007, "语音播放时间超过限制"), | ||||
/** | /** | ||||
* 图文消息超过限制 | |||||
* 图文消息超过限制. | |||||
*/ | */ | ||||
CODE_45008(45008, "图文消息超过限制"), | CODE_45008(45008, "图文消息超过限制"), | ||||
/** | /** | ||||
* 接口调用超过限制 | |||||
* 接口调用超过限制. | |||||
*/ | */ | ||||
CODE_45009(45009, "接口调用超过限制"), | CODE_45009(45009, "接口调用超过限制"), | ||||
/** | /** | ||||
* 创建菜单个数超过限制 | |||||
* 创建菜单个数超过限制. | |||||
*/ | */ | ||||
CODE_45010(45010, "创建菜单个数超过限制"), | CODE_45010(45010, "创建菜单个数超过限制"), | ||||
/** | /** | ||||
* API 调用太频繁,请稍候再试 | |||||
* API 调用太频繁,请稍候再试. | |||||
*/ | */ | ||||
CODE_45011(45011, "API 调用太频繁,请稍候再试"), | CODE_45011(45011, "API 调用太频繁,请稍候再试"), | ||||
/** | /** | ||||
* 回复时间超过限制 | |||||
* 回复时间超过限制. | |||||
*/ | */ | ||||
CODE_45015(45015, "回复时间超过限制"), | CODE_45015(45015, "回复时间超过限制"), | ||||
/** | /** | ||||
* 系统分组,不允许修改 | |||||
* 系统分组,不允许修改. | |||||
*/ | */ | ||||
CODE_45016(45016, "系统分组,不允许修改"), | CODE_45016(45016, "系统分组,不允许修改"), | ||||
/** | /** | ||||
* 分组名字过长 | |||||
* 分组名字过长. | |||||
*/ | */ | ||||
CODE_45017(45017, "分组名字过长"), | CODE_45017(45017, "分组名字过长"), | ||||
/** | /** | ||||
* 分组数量超过上限 | |||||
* 分组数量超过上限. | |||||
*/ | */ | ||||
CODE_45018(45018, "分组数量超过上限"), | CODE_45018(45018, "分组数量超过上限"), | ||||
/** | /** | ||||
* 客服接口下行条数超过上限 | |||||
* 客服接口下行条数超过上限. | |||||
*/ | */ | ||||
CODE_45047(45047, "客服接口下行条数超过上限"), | CODE_45047(45047, "客服接口下行条数超过上限"), | ||||
/** | /** | ||||
* 不存在媒体数据 | |||||
* 非法的tag_id. | |||||
*/ | |||||
CODE_45159(45159, "非法的tag_id"), | |||||
/** | |||||
* 不存在媒体数据. | |||||
*/ | */ | ||||
CODE_46001(46001, "不存在媒体数据"), | CODE_46001(46001, "不存在媒体数据"), | ||||
/** | /** | ||||
* 不存在的菜单版本 | |||||
* 不存在的菜单版本. | |||||
*/ | */ | ||||
CODE_46002(46002, "不存在的菜单版本"), | CODE_46002(46002, "不存在的菜单版本"), | ||||
/** | /** | ||||
* 不存在的菜单数据 | |||||
* 不存在的菜单数据. | |||||
*/ | */ | ||||
CODE_46003(46003, "不存在的菜单数据"), | CODE_46003(46003, "不存在的菜单数据"), | ||||
/** | /** | ||||
* 不存在的用户 | |||||
* 不存在的用户. | |||||
*/ | */ | ||||
CODE_46004(46004, "不存在的用户"), | CODE_46004(46004, "不存在的用户"), | ||||
/** | /** | ||||
* 解析 JSON/XML 内容错误 | |||||
* 解析 JSON/XML 内容错误. | |||||
*/ | */ | ||||
CODE_47001(47001, "解析 JSON/XML 内容错误"), | CODE_47001(47001, "解析 JSON/XML 内容错误"), | ||||
/** | /** | ||||
* api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限 | |||||
* api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限. | |||||
*/ | */ | ||||
CODE_48001(48001, "api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限"), | CODE_48001(48001, "api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限"), | ||||
/** | /** | ||||
* 粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” ) | |||||
* 粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” ). | |||||
*/ | */ | ||||
CODE_48002(48002, "粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” )"), | CODE_48002(48002, "粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” )"), | ||||
/** | /** | ||||
* api 接口被封禁,请登录 mp.weixin.qq.com 查看详情 | |||||
* api 接口被封禁,请登录 mp.weixin.qq.com 查看详情. | |||||
*/ | */ | ||||
CODE_48004(48004, "api 接口被封禁,请登录 mp.weixin.qq.com 查看详情"), | CODE_48004(48004, "api 接口被封禁,请登录 mp.weixin.qq.com 查看详情"), | ||||
/** | /** | ||||
* api 禁止删除被自动回复和自定义菜单引用的素材 | |||||
* api 禁止删除被自动回复和自定义菜单引用的素材. | |||||
*/ | */ | ||||
CODE_48005(48005, "api 禁止删除被自动回复和自定义菜单引用的素材"), | CODE_48005(48005, "api 禁止删除被自动回复和自定义菜单引用的素材"), | ||||
/** | /** | ||||
* api 禁止清零调用次数,因为清零次数达到上限 | |||||
* api 禁止清零调用次数,因为清零次数达到上限. | |||||
*/ | */ | ||||
CODE_48006(48006, "api 禁止清零调用次数,因为清零次数达到上限"), | CODE_48006(48006, "api 禁止清零调用次数,因为清零次数达到上限"), | ||||
/** | /** | ||||
* 没有该类型消息的发送权限 | |||||
* 没有该类型消息的发送权限. | |||||
*/ | */ | ||||
CODE_48008(48008, "没有该类型消息的发送权限"), | CODE_48008(48008, "没有该类型消息的发送权限"), | ||||
/** | /** | ||||
* 用户未授权该 api | |||||
* 用户未授权该 api. | |||||
*/ | */ | ||||
CODE_50001(50001, "用户未授权该 api"), | CODE_50001(50001, "用户未授权该 api"), | ||||
/** | /** | ||||
* 用户受限,可能是违规后接口被封禁 | |||||
* 用户受限,可能是违规后接口被封禁. | |||||
*/ | */ | ||||
CODE_50002(50002, "用户受限,可能是违规后接口被封禁"), | CODE_50002(50002, "用户受限,可能是违规后接口被封禁"), | ||||
/** | /** | ||||
* 用户未关注公众号 | |||||
* 用户未关注公众号. | |||||
*/ | */ | ||||
CODE_50005(50005, "用户未关注公众号"), | CODE_50005(50005, "用户未关注公众号"), | ||||
/** | /** | ||||
* 参数错误 (invalid parameter) | |||||
* 参数错误 (invalid parameter). | |||||
*/ | */ | ||||
CODE_61451(61451, "参数错误 (invalid parameter)"), | CODE_61451(61451, "参数错误 (invalid parameter)"), | ||||
/** | /** | ||||
* 无效客服账号 (invalid kf_account) | |||||
* 无效客服账号 (invalid kf_account). | |||||
*/ | */ | ||||
CODE_61452(61452, "无效客服账号 (invalid kf_account)"), | CODE_61452(61452, "无效客服账号 (invalid kf_account)"), | ||||
/** | /** | ||||
* 客服帐号已存在 (kf_account exsited) | |||||
* 客服帐号已存在 (kf_account exsited). | |||||
*/ | */ | ||||
CODE_61453(61453, "客服帐号已存在 (kf_account exsited)"), | CODE_61453(61453, "客服帐号已存在 (kf_account exsited)"), | ||||
/** | /** | ||||
* 客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length) | |||||
* 客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length). | |||||
*/ | */ | ||||
CODE_61454(61454, "客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length)"), | CODE_61454(61454, "客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length)"), | ||||
/** | /** | ||||
* 客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account) | |||||
* 客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account). | |||||
*/ | */ | ||||
CODE_61455(61455, "客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account)"), | CODE_61455(61455, "客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account)"), | ||||
/** | /** | ||||
* 客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded) | |||||
* 客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded). | |||||
*/ | */ | ||||
CODE_61456(61456, "客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded)"), | CODE_61456(61456, "客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded)"), | ||||
/** | /** | ||||
* 无效头像文件类型 (invalid file type) | |||||
* 无效头像文件类型 (invalid file type). | |||||
*/ | */ | ||||
CODE_61457(61457, "无效头像文件类型 (invalid file type)"), | CODE_61457(61457, "无效头像文件类型 (invalid file type)"), | ||||
/** | /** | ||||
* 系统错误 (system error) | |||||
* 系统错误 (system error). | |||||
*/ | */ | ||||
CODE_61450(61450, "系统错误 (system error)"), | CODE_61450(61450, "系统错误 (system error)"), | ||||
/** | /** | ||||
* 日期格式错误 | |||||
* 日期格式错误. | |||||
*/ | */ | ||||
CODE_61500(61500, "日期格式错误"), | CODE_61500(61500, "日期格式错误"), | ||||
/** | /** | ||||
* 不存在此 menuid 对应的个性化菜单 | |||||
* 不存在此 menuid 对应的个性化菜单. | |||||
*/ | */ | ||||
CODE_65301(65301, "不存在此 menuid 对应的个性化菜单"), | CODE_65301(65301, "不存在此 menuid 对应的个性化菜单"), | ||||
/** | /** | ||||
* 没有相应的用户 | |||||
* 没有相应的用户. | |||||
*/ | */ | ||||
CODE_65302(65302, "没有相应的用户"), | CODE_65302(65302, "没有相应的用户"), | ||||
/** | /** | ||||
* 没有默认菜单,不能创建个性化菜单 | |||||
* 没有默认菜单,不能创建个性化菜单. | |||||
*/ | */ | ||||
CODE_65303(65303, "没有默认菜单,不能创建个性化菜单"), | CODE_65303(65303, "没有默认菜单,不能创建个性化菜单"), | ||||
/** | /** | ||||
* MatchRule 信息为空 | |||||
* MatchRule 信息为空. | |||||
*/ | */ | ||||
CODE_65304(65304, "MatchRule 信息为空"), | CODE_65304(65304, "MatchRule 信息为空"), | ||||
/** | /** | ||||
* 个性化菜单数量受限 | |||||
* 个性化菜单数量受限. | |||||
*/ | */ | ||||
CODE_65305(65305, "个性化菜单数量受限"), | CODE_65305(65305, "个性化菜单数量受限"), | ||||
/** | /** | ||||
* 不支持个性化菜单的帐号 | |||||
* 不支持个性化菜单的帐号. | |||||
*/ | */ | ||||
CODE_65306(65306, "不支持个性化菜单的帐号"), | CODE_65306(65306, "不支持个性化菜单的帐号"), | ||||
/** | /** | ||||
* 个性化菜单信息为空 | |||||
* 个性化菜单信息为空. | |||||
*/ | */ | ||||
CODE_65307(65307, "个性化菜单信息为空"), | CODE_65307(65307, "个性化菜单信息为空"), | ||||
/** | /** | ||||
* 包含没有响应类型的 button | |||||
* 包含没有响应类型的 button. | |||||
*/ | */ | ||||
CODE_65308(65308, "包含没有响应类型的 button"), | CODE_65308(65308, "包含没有响应类型的 button"), | ||||
/** | /** | ||||
* 个性化菜单开关处于关闭状态 | |||||
* 个性化菜单开关处于关闭状态. | |||||
*/ | */ | ||||
CODE_65309(65309, "个性化菜单开关处于关闭状态"), | CODE_65309(65309, "个性化菜单开关处于关闭状态"), | ||||
/** | /** | ||||
* 填写了省份或城市信息,国家信息不能为空 | |||||
* 填写了省份或城市信息,国家信息不能为空. | |||||
*/ | */ | ||||
CODE_65310(65310, "填写了省份或城市信息,国家信息不能为空"), | CODE_65310(65310, "填写了省份或城市信息,国家信息不能为空"), | ||||
/** | /** | ||||
* 填写了城市信息,省份信息不能为空 | |||||
* 填写了城市信息,省份信息不能为空. | |||||
*/ | */ | ||||
CODE_65311(65311, "填写了城市信息,省份信息不能为空"), | CODE_65311(65311, "填写了城市信息,省份信息不能为空"), | ||||
/** | /** | ||||
* 不合法的国家信息 | |||||
* 不合法的国家信息. | |||||
*/ | */ | ||||
CODE_65312(65312, "不合法的国家信息"), | CODE_65312(65312, "不合法的国家信息"), | ||||
/** | /** | ||||
* 不合法的省份信息 | |||||
* 不合法的省份信息. | |||||
*/ | */ | ||||
CODE_65313(65313, "不合法的省份信息"), | CODE_65313(65313, "不合法的省份信息"), | ||||
/** | /** | ||||
* 不合法的城市信息 | |||||
* 不合法的城市信息. | |||||
*/ | */ | ||||
CODE_65314(65314, "不合法的城市信息"), | CODE_65314(65314, "不合法的城市信息"), | ||||
/** | /** | ||||
* 该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接) | |||||
* 该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接). | |||||
*/ | */ | ||||
CODE_65316(65316, "该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接)"), | CODE_65316(65316, "该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接)"), | ||||
/** | /** | ||||
* 不合法的 URL | |||||
* 不合法的 URL. | |||||
*/ | */ | ||||
CODE_65317(65317, "不合法的 URL"), | CODE_65317(65317, "不合法的 URL"), | ||||
/** | /** | ||||
* POST 数据参数不合法 | |||||
* POST 数据参数不合法. | |||||
*/ | */ | ||||
CODE_9001001(9001001, "POST 数据参数不合法"), | CODE_9001001(9001001, "POST 数据参数不合法"), | ||||
/** | /** | ||||
* 远端服务不可用 | |||||
* 远端服务不可用. | |||||
*/ | */ | ||||
CODE_9001002(9001002, "远端服务不可用"), | CODE_9001002(9001002, "远端服务不可用"), | ||||
/** | /** | ||||
* Ticket 不合法 | |||||
* Ticket 不合法. | |||||
*/ | */ | ||||
CODE_9001003(9001003, "Ticket 不合法"), | CODE_9001003(9001003, "Ticket 不合法"), | ||||
/** | /** | ||||
* 获取摇周边用户信息失败 | |||||
* 获取摇周边用户信息失败. | |||||
*/ | */ | ||||
CODE_9001004(9001004, "获取摇周边用户信息失败"), | CODE_9001004(9001004, "获取摇周边用户信息失败"), | ||||
/** | /** | ||||
* 获取商户信息失败 | |||||
* 获取商户信息失败. | |||||
*/ | */ | ||||
CODE_9001005(9001005, "获取商户信息失败"), | CODE_9001005(9001005, "获取商户信息失败"), | ||||
/** | /** | ||||
* 获取 OpenID 失败 | |||||
* 获取 OpenID 失败. | |||||
*/ | */ | ||||
CODE_9001006(9001006, "获取 OpenID 失败"), | CODE_9001006(9001006, "获取 OpenID 失败"), | ||||
/** | /** | ||||
* 上传文件缺失 | |||||
* 上传文件缺失. | |||||
*/ | */ | ||||
CODE_9001007(9001007, "上传文件缺失"), | CODE_9001007(9001007, "上传文件缺失"), | ||||
/** | /** | ||||
* 上传素材的文件类型不合法 | |||||
* 上传素材的文件类型不合法. | |||||
*/ | */ | ||||
CODE_9001008(9001008, "上传素材的文件类型不合法"), | CODE_9001008(9001008, "上传素材的文件类型不合法"), | ||||
/** | /** | ||||
* 上传素材的文件尺寸不合法 | |||||
* 上传素材的文件尺寸不合法. | |||||
*/ | */ | ||||
CODE_9001009(9001009, "上传素材的文件尺寸不合法"), | CODE_9001009(9001009, "上传素材的文件尺寸不合法"), | ||||
/** | /** | ||||
* 上传失败 | |||||
* 上传失败. | |||||
*/ | */ | ||||
CODE_9001010(9001010, "上传失败"), | CODE_9001010(9001010, "上传失败"), | ||||
/** | /** | ||||
* 帐号不合法 | |||||
* 帐号不合法. | |||||
*/ | */ | ||||
CODE_9001020(9001020, "帐号不合法"), | CODE_9001020(9001020, "帐号不合法"), | ||||
/** | /** | ||||
* 已有设备激活率低于 50% ,不能新增设备 | |||||
* 已有设备激活率低于 50% ,不能新增设备. | |||||
*/ | */ | ||||
CODE_9001021(9001021, "已有设备激活率低于 50% ,不能新增设备"), | CODE_9001021(9001021, "已有设备激活率低于 50% ,不能新增设备"), | ||||
/** | /** | ||||
* 设备申请数不合法,必须为大于 0 的数字 | |||||
* 设备申请数不合法,必须为大于 0 的数字. | |||||
*/ | */ | ||||
CODE_9001022(9001022, "设备申请数不合法,必须为大于 0 的数字"), | CODE_9001022(9001022, "设备申请数不合法,必须为大于 0 的数字"), | ||||
/** | /** | ||||
* 已存在审核中的设备 ID 申请 | |||||
* 已存在审核中的设备 ID 申请. | |||||
*/ | */ | ||||
CODE_9001023(9001023, "已存在审核中的设备 ID 申请"), | CODE_9001023(9001023, "已存在审核中的设备 ID 申请"), | ||||
/** | /** | ||||
* 一次查询设备 ID 数量不能超过 50 | |||||
* 一次查询设备 ID 数量不能超过 50. | |||||
*/ | */ | ||||
CODE_9001024(9001024, "一次查询设备 ID 数量不能超过 50"), | CODE_9001024(9001024, "一次查询设备 ID 数量不能超过 50"), | ||||
/** | /** | ||||
* 设备 ID 不合法 | |||||
* 设备 ID 不合法. | |||||
*/ | */ | ||||
CODE_9001025(9001025, "设备 ID 不合法"), | CODE_9001025(9001025, "设备 ID 不合法"), | ||||
/** | /** | ||||
* 页面 ID 不合法 | |||||
* 页面 ID 不合法. | |||||
*/ | */ | ||||
CODE_9001026(9001026, "页面 ID 不合法"), | CODE_9001026(9001026, "页面 ID 不合法"), | ||||
/** | /** | ||||
* 页面参数不合法 | |||||
* 页面参数不合法. | |||||
*/ | */ | ||||
CODE_9001027(9001027, "页面参数不合法"), | CODE_9001027(9001027, "页面参数不合法"), | ||||
/** | /** | ||||
* 一次删除页面 ID 数量不能超过 10 | |||||
* 一次删除页面 ID 数量不能超过 10. | |||||
*/ | */ | ||||
CODE_9001028(9001028, "一次删除页面 ID 数量不能超过 10"), | CODE_9001028(9001028, "一次删除页面 ID 数量不能超过 10"), | ||||
/** | /** | ||||
* 页面已应用在设备中,请先解除应用关系再删除 | |||||
* 页面已应用在设备中,请先解除应用关系再删除. | |||||
*/ | */ | ||||
CODE_9001029(9001029, "页面已应用在设备中,请先解除应用关系再删除"), | CODE_9001029(9001029, "页面已应用在设备中,请先解除应用关系再删除"), | ||||
/** | /** | ||||
* 一次查询页面 ID 数量不能超过 50 | |||||
* 一次查询页面 ID 数量不能超过 50. | |||||
*/ | */ | ||||
CODE_9001030(9001030, "一次查询页面 ID 数量不能超过 50"), | CODE_9001030(9001030, "一次查询页面 ID 数量不能超过 50"), | ||||
/** | /** | ||||
* 时间区间不合法 | |||||
* 时间区间不合法. | |||||
*/ | */ | ||||
CODE_9001031(9001031, "时间区间不合法"), | CODE_9001031(9001031, "时间区间不合法"), | ||||
/** | /** | ||||
* 保存设备与页面的绑定关系参数错误 | |||||
* 保存设备与页面的绑定关系参数错误. | |||||
*/ | */ | ||||
CODE_9001032(9001032, "保存设备与页面的绑定关系参数错误"), | CODE_9001032(9001032, "保存设备与页面的绑定关系参数错误"), | ||||
/** | /** | ||||
* 门店 ID 不合法 | |||||
* 门店 ID 不合法. | |||||
*/ | */ | ||||
CODE_9001033(9001033, "门店 ID 不合法"), | CODE_9001033(9001033, "门店 ID 不合法"), | ||||
/** | /** | ||||
* 设备备注信息过长 | |||||
* 设备备注信息过长. | |||||
*/ | */ | ||||
CODE_9001034(9001034, "设备备注信息过长"), | CODE_9001034(9001034, "设备备注信息过长"), | ||||
/** | /** | ||||
* 设备申请参数不合法 | |||||
* 设备申请参数不合法. | |||||
*/ | */ | ||||
CODE_9001035(9001035, "设备申请参数不合法"), | CODE_9001035(9001035, "设备申请参数不合法"), | ||||
/** | /** | ||||
* 查询起始值 begin 不合法 | |||||
* 查询起始值 begin 不合法. | |||||
*/ | */ | ||||
CODE_9001036(9001036, "查询起始值 begin 不合法"); | CODE_9001036(9001036, "查询起始值 begin 不合法"); | ||||
@@ -639,7 +643,7 @@ public enum WxMpErrorMsgEnum { | |||||
} | } | ||||
/** | /** | ||||
* 通过错误代码查找其中文含义. | |||||
* 通过错误代码查找其中文含义.. | |||||
*/ | */ | ||||
public static String findMsgByCode(int code) { | public static String findMsgByCode(int code) { | ||||
for (WxMpErrorMsgEnum value : WxMpErrorMsgEnum.values()) { | for (WxMpErrorMsgEnum value : WxMpErrorMsgEnum.values()) { | ||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.common.util.http; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheMediaDownloadRequestExecutor; | import me.chanjar.weixin.common.util.http.apache.ApacheMediaDownloadRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaDownloadRequestExecutor; | import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaDownloadRequestExecutor; | ||||
@@ -25,8 +26,8 @@ public abstract class BaseMediaDownloadRequestExecutor<H, P> implements RequestE | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, String data, ResponseHandler<File> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, String data, ResponseHandler<File> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<File, String> create(RequestHttp requestHttp, File tmpDirFile) { | public static RequestExecutor<File, String> create(RequestHttp requestHttp, File tmpDirFile) { | ||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.common.util.http; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheMediaUploadRequestExecutor; | import me.chanjar.weixin.common.util.http.apache.ApacheMediaUploadRequestExecutor; | ||||
@@ -23,8 +24,8 @@ public abstract class MediaUploadRequestExecutor<H, P> implements RequestExecuto | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, File data, ResponseHandler<WxMediaUploadResult> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, File data, ResponseHandler<WxMediaUploadResult> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<WxMediaUploadResult, File> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMediaUploadResult, File> create(RequestHttp requestHttp) { | ||||
@@ -1,9 +1,10 @@ | |||||
package me.chanjar.weixin.common.util.http; | package me.chanjar.weixin.common.util.http; | ||||
import java.io.IOException; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import java.io.IOException; | |||||
/** | /** | ||||
* http请求执行器. | * http请求执行器. | ||||
* | * | ||||
@@ -16,23 +17,24 @@ public interface RequestExecutor<T, E> { | |||||
/** | /** | ||||
* 执行http请求. | * 执行http请求. | ||||
* | * | ||||
* @param uri uri | |||||
* @param data 数据 | |||||
* @param uri uri | |||||
* @param data 数据 | |||||
* @param wxType 微信模块类型 | |||||
* @return 响应结果 | * @return 响应结果 | ||||
* @throws WxErrorException 自定义异常 | * @throws WxErrorException 自定义异常 | ||||
* @throws IOException io异常 | * @throws IOException io异常 | ||||
*/ | */ | ||||
T execute(String uri, E data) throws WxErrorException, IOException; | |||||
T execute(String uri, E data, WxType wxType) throws WxErrorException, IOException; | |||||
/** | /** | ||||
* 执行http请求. | * 执行http请求. | ||||
* | * | ||||
* @param uri uri | |||||
* @param data 数据 | |||||
* @param uri uri | |||||
* @param data 数据 | |||||
* @param handler http响应处理器 | * @param handler http响应处理器 | ||||
* @param wxType 微信模块类型 | |||||
* @throws WxErrorException 自定义异常 | * @throws WxErrorException 自定义异常 | ||||
* @throws IOException io异常 | * @throws IOException io异常 | ||||
*/ | */ | ||||
void execute(String uri, E data, ResponseHandler<T> handler) throws WxErrorException, IOException; | |||||
void execute(String uri, E data, ResponseHandler<T> handler, WxType wxType) throws WxErrorException, IOException; | |||||
} | } |
@@ -2,6 +2,7 @@ package me.chanjar.weixin.common.util.http; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientSimpleGetRequestExecutor; | import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientSimpleGetRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimpleGetRequestExecutor; | import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimpleGetRequestExecutor; | ||||
@@ -21,8 +22,8 @@ public abstract class SimpleGetRequestExecutor<H, P> implements RequestExecutor< | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, String data, ResponseHandler<String> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, String data, ResponseHandler<String> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<String, String> create(RequestHttp requestHttp) { | public static RequestExecutor<String, String> create(RequestHttp requestHttp) { | ||||
@@ -2,6 +2,7 @@ package me.chanjar.weixin.common.util.http; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor; | import me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimplePostRequestExecutor; | import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimplePostRequestExecutor; | ||||
@@ -21,8 +22,9 @@ public abstract class SimplePostRequestExecutor<H, P> implements RequestExecutor | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, String data, ResponseHandler<String> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, String data, ResponseHandler<String> handler, WxType wxType) | |||||
throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<String, String> create(RequestHttp requestHttp) { | public static RequestExecutor<String, String> create(RequestHttp requestHttp) { | ||||
@@ -1,29 +1,31 @@ | |||||
package me.chanjar.weixin.common.util.http.apache; | package me.chanjar.weixin.common.util.http.apache; | ||||
import java.io.IOException; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | |||||
import me.chanjar.weixin.common.util.http.RequestHttp; | |||||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | |||||
import org.apache.http.HttpHost; | import org.apache.http.HttpHost; | ||||
import org.apache.http.client.config.RequestConfig; | import org.apache.http.client.config.RequestConfig; | ||||
import org.apache.http.client.methods.CloseableHttpResponse; | import org.apache.http.client.methods.CloseableHttpResponse; | ||||
import org.apache.http.client.methods.HttpGet; | import org.apache.http.client.methods.HttpGet; | ||||
import org.apache.http.impl.client.CloseableHttpClient; | import org.apache.http.impl.client.CloseableHttpClient; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | |||||
import me.chanjar.weixin.common.util.http.RequestHttp; | |||||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | |||||
import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/4 | |||||
*/ | */ | ||||
public class ApacheHttpClientSimpleGetRequestExecutor extends SimpleGetRequestExecutor<CloseableHttpClient, HttpHost> { | public class ApacheHttpClientSimpleGetRequestExecutor extends SimpleGetRequestExecutor<CloseableHttpClient, HttpHost> { | ||||
public ApacheHttpClientSimpleGetRequestExecutor(RequestHttp requestHttp) { | public ApacheHttpClientSimpleGetRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public String execute(String uri, String queryParam) throws WxErrorException, IOException { | |||||
public String execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -38,7 +40,7 @@ public class ApacheHttpClientSimpleGetRequestExecutor extends SimpleGetRequestEx | |||||
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet)) { | try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet)) { | ||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -1,9 +1,12 @@ | |||||
package me.chanjar.weixin.common.util.http.apache; | package me.chanjar.weixin.common.util.http.apache; | ||||
import java.io.File; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | |||||
import me.chanjar.weixin.common.util.fs.FileUtils; | |||||
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.HttpResponseProxy; | |||||
import me.chanjar.weixin.common.util.http.RequestHttp; | |||||
import org.apache.commons.io.FilenameUtils; | import org.apache.commons.io.FilenameUtils; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.apache.http.Header; | import org.apache.http.Header; | ||||
@@ -14,15 +17,15 @@ import org.apache.http.client.methods.HttpGet; | |||||
import org.apache.http.entity.ContentType; | import org.apache.http.entity.ContentType; | ||||
import org.apache.http.impl.client.CloseableHttpClient; | import org.apache.http.impl.client.CloseableHttpClient; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | |||||
import me.chanjar.weixin.common.util.fs.FileUtils; | |||||
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.HttpResponseProxy; | |||||
import me.chanjar.weixin.common.util.http.RequestHttp; | |||||
import java.io.File; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/5 | |||||
*/ | */ | ||||
public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<CloseableHttpClient, HttpHost> { | public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<CloseableHttpClient, HttpHost> { | ||||
public ApacheMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | public ApacheMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | ||||
@@ -30,7 +33,7 @@ public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequest | |||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, String queryParam) throws WxErrorException, IOException { | |||||
public File execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -51,7 +54,7 @@ public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequest | |||||
if (contentTypeHeader[0].getValue().startsWith(ContentType.APPLICATION_JSON.getMimeType())) { | if (contentTypeHeader[0].getValue().startsWith(ContentType.APPLICATION_JSON.getMimeType())) { | ||||
// application/json; encoding=utf-8 下载媒体文件出错 | // application/json; encoding=utf-8 下载媒体文件出错 | ||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | ||||
throw new WxErrorException(WxError.fromJson(responseContent)); | |||||
throw new WxErrorException(WxError.fromJson(responseContent, wxType)); | |||||
} | } | ||||
} | } | ||||
@@ -1,7 +1,8 @@ | |||||
package me.chanjar.weixin.common.util.http.apache; | package me.chanjar.weixin.common.util.http.apache; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -26,7 +27,7 @@ public class ApacheMediaUploadRequestExecutor extends MediaUploadRequestExecutor | |||||
} | } | ||||
@Override | @Override | ||||
public WxMediaUploadResult execute(String uri, File file) throws WxErrorException, IOException { | |||||
public WxMediaUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | ||||
@@ -42,7 +43,7 @@ public class ApacheMediaUploadRequestExecutor extends MediaUploadRequestExecutor | |||||
} | } | ||||
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { | try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { | ||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -1,5 +1,6 @@ | |||||
package me.chanjar.weixin.common.util.http.apache; | package me.chanjar.weixin.common.util.http.apache; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -15,16 +16,18 @@ import org.apache.http.impl.client.CloseableHttpClient; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/4 | |||||
*/ | */ | ||||
public class ApacheSimplePostRequestExecutor extends SimplePostRequestExecutor<CloseableHttpClient, HttpHost> { | public class ApacheSimplePostRequestExecutor extends SimplePostRequestExecutor<CloseableHttpClient, HttpHost> { | ||||
public ApacheSimplePostRequestExecutor(RequestHttp requestHttp) { | public ApacheSimplePostRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public String execute(String uri, String postEntity) throws WxErrorException, IOException { | |||||
public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | ||||
@@ -47,7 +50,7 @@ public class ApacheSimplePostRequestExecutor extends SimplePostRequestExecutor<C | |||||
return responseContent; | return responseContent; | ||||
} | } | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -1,36 +1,38 @@ | |||||
package me.chanjar.weixin.common.util.http.jodd; | package me.chanjar.weixin.common.util.http.jodd; | ||||
import java.io.ByteArrayInputStream; | |||||
import java.io.File; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
import org.apache.commons.io.FilenameUtils; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import jodd.http.HttpConnectionProvider; | import jodd.http.HttpConnectionProvider; | ||||
import jodd.http.HttpRequest; | import jodd.http.HttpRequest; | ||||
import jodd.http.HttpResponse; | import jodd.http.HttpResponse; | ||||
import jodd.http.ProxyInfo; | import jodd.http.ProxyInfo; | ||||
import jodd.util.StringPool; | import jodd.util.StringPool; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.fs.FileUtils; | import me.chanjar.weixin.common.util.fs.FileUtils; | ||||
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.HttpResponseProxy; | import me.chanjar.weixin.common.util.http.HttpResponseProxy; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import org.apache.commons.io.FilenameUtils; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.io.ByteArrayInputStream; | |||||
import java.io.File; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/5 | |||||
*/ | */ | ||||
public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<HttpConnectionProvider, ProxyInfo> { | public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<HttpConnectionProvider, ProxyInfo> { | ||||
public JoddHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | public JoddHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | ||||
super(requestHttp, tmpDirFile); | super(requestHttp, tmpDirFile); | ||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, String queryParam) throws WxErrorException, IOException { | |||||
public File execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -50,7 +52,7 @@ public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadReque | |||||
String contentType = response.header("Content-Type"); | String contentType = response.header("Content-Type"); | ||||
if (contentType != null && contentType.startsWith("application/json")) { | if (contentType != null && contentType.startsWith("application/json")) { | ||||
// application/json; encoding=utf-8 下载媒体文件出错 | // application/json; encoding=utf-8 下载媒体文件出错 | ||||
throw new WxErrorException(WxError.fromJson(response.bodyText())); | |||||
throw new WxErrorException(WxError.fromJson(response.bodyText(), wxType)); | |||||
} | } | ||||
String fileName = new HttpResponseProxy(response).getFileName(); | String fileName = new HttpResponseProxy(response).getFileName(); | ||||
@@ -5,9 +5,9 @@ import jodd.http.HttpRequest; | |||||
import jodd.http.HttpResponse; | import jodd.http.HttpResponse; | ||||
import jodd.http.ProxyInfo; | import jodd.http.ProxyInfo; | ||||
import jodd.util.StringPool; | import jodd.util.StringPool; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -16,7 +16,10 @@ import java.io.File; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/5 | |||||
*/ | */ | ||||
public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> { | public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> { | ||||
public JoddHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { | public JoddHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { | ||||
@@ -24,7 +27,7 @@ public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecut | |||||
} | } | ||||
@Override | @Override | ||||
public WxMediaUploadResult execute(String uri, File file) throws WxErrorException, IOException { | |||||
public WxMediaUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { | |||||
HttpRequest request = HttpRequest.post(uri); | HttpRequest request = HttpRequest.post(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | ||||
@@ -35,7 +38,7 @@ public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecut | |||||
response.charset(StringPool.UTF_8); | response.charset(StringPool.UTF_8); | ||||
String responseContent = response.bodyText(); | String responseContent = response.bodyText(); | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -1,8 +1,11 @@ | |||||
package me.chanjar.weixin.common.util.http.jodd; | package me.chanjar.weixin.common.util.http.jodd; | ||||
import jodd.http.*; | |||||
import jodd.http.HttpConnectionProvider; | |||||
import jodd.http.HttpRequest; | |||||
import jodd.http.HttpResponse; | |||||
import jodd.http.ProxyInfo; | |||||
import jodd.util.StringPool; | import jodd.util.StringPool; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -11,16 +14,18 @@ import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/4 | |||||
*/ | */ | ||||
public class JoddHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<HttpConnectionProvider, ProxyInfo> { | public class JoddHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<HttpConnectionProvider, ProxyInfo> { | ||||
public JoddHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { | public JoddHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public String execute(String uri, String queryParam) throws WxErrorException, IOException { | |||||
public String execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -38,7 +43,7 @@ public class JoddHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<H | |||||
String responseContent = response.bodyText(); | String responseContent = response.bodyText(); | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -5,6 +5,7 @@ import jodd.http.HttpRequest; | |||||
import jodd.http.HttpResponse; | import jodd.http.HttpResponse; | ||||
import jodd.http.ProxyInfo; | import jodd.http.ProxyInfo; | ||||
import jodd.util.StringPool; | import jodd.util.StringPool; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -13,16 +14,18 @@ import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/4 | |||||
*/ | */ | ||||
public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor<HttpConnectionProvider, ProxyInfo> { | public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor<HttpConnectionProvider, ProxyInfo> { | ||||
public JoddHttpSimplePostRequestExecutor(RequestHttp requestHttp) { | public JoddHttpSimplePostRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public String execute(String uri, String postEntity) throws WxErrorException, IOException { | |||||
public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException { | |||||
HttpConnectionProvider provider = requestHttp.getRequestHttpClient(); | HttpConnectionProvider provider = requestHttp.getRequestHttpClient(); | ||||
ProxyInfo proxyInfo = requestHttp.getRequestHttpProxy(); | ProxyInfo proxyInfo = requestHttp.getRequestHttpProxy(); | ||||
@@ -39,8 +42,7 @@ public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor | |||||
String responseContent = response.bodyText(); | String responseContent = response.bodyText(); | ||||
if (responseContent.isEmpty()) { | if (responseContent.isEmpty()) { | ||||
throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容") | |||||
.build()); | |||||
throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容").build()); | |||||
} | } | ||||
if (responseContent.startsWith("<xml>")) { | if (responseContent.startsWith("<xml>")) { | ||||
@@ -48,7 +50,7 @@ public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor | |||||
return responseContent; | return responseContent; | ||||
} | } | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -1,5 +1,7 @@ | |||||
package me.chanjar.weixin.common.util.http.okhttp; | package me.chanjar.weixin.common.util.http.okhttp; | ||||
import lombok.extern.slf4j.Slf4j; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | ||||
@@ -19,18 +21,18 @@ import java.io.File; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | |||||
*. | |||||
* @author ecoolper | |||||
* @date 2017/5/5 | |||||
*/ | */ | ||||
@Slf4j | |||||
public class OkHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | public class OkHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | ||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
public OkHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | public OkHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | ||||
super(requestHttp, tmpDirFile); | super(requestHttp, tmpDirFile); | ||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, String queryParam) throws WxErrorException, IOException { | |||||
logger.debug("OkHttpMediaDownloadRequestExecutor is running"); | |||||
public File execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -48,7 +50,7 @@ public class OkHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequest | |||||
String contentType = response.header("Content-Type"); | String contentType = response.header("Content-Type"); | ||||
if (contentType != null && contentType.startsWith("application/json")) { | if (contentType != null && contentType.startsWith("application/json")) { | ||||
// application/json; encoding=utf-8 下载媒体文件出错 | // application/json; encoding=utf-8 下载媒体文件出错 | ||||
throw new WxErrorException(WxError.fromJson(response.body().string())); | |||||
throw new WxErrorException(WxError.fromJson(response.body().string(), wxType)); | |||||
} | } | ||||
String fileName = new HttpResponseProxy(response).getFileName(); | String fileName = new HttpResponseProxy(response).getFileName(); | ||||
@@ -1,32 +1,29 @@ | |||||
package me.chanjar.weixin.common.util.http.okhttp; | package me.chanjar.weixin.common.util.http.okhttp; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import okhttp3.*; | import okhttp3.*; | ||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/5 | |||||
*/ | */ | ||||
public class OkHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | public class OkHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | ||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
public OkHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { | public OkHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public WxMediaUploadResult execute(String uri, File file) throws WxErrorException, IOException { | |||||
logger.debug("OkHttpMediaUploadRequestExecutor is running"); | |||||
//得到httpClient | |||||
OkHttpClient client = requestHttp.getRequestHttpClient(); | |||||
public WxMediaUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { | |||||
RequestBody body = new MultipartBody.Builder() | RequestBody body = new MultipartBody.Builder() | ||||
.setType(MediaType.parse("multipart/form-data")) | .setType(MediaType.parse("multipart/form-data")) | ||||
@@ -36,9 +33,9 @@ public class OkHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor | |||||
.build(); | .build(); | ||||
Request request = new Request.Builder().url(uri).post(body).build(); | Request request = new Request.Builder().url(uri).post(body).build(); | ||||
Response response = client.newCall(request).execute(); | |||||
Response response = requestHttp.getRequestHttpClient().newCall(request).execute(); | |||||
String responseContent = response.body().string(); | String responseContent = response.body().string(); | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -1,28 +1,29 @@ | |||||
package me.chanjar.weixin.common.util.http.okhttp; | package me.chanjar.weixin.common.util.http.okhttp; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | ||||
import okhttp3.*; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import okhttp3.OkHttpClient; | |||||
import okhttp3.Request; | |||||
import okhttp3.Response; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/4 | |||||
*/ | */ | ||||
public class OkHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | public class OkHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | ||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
public OkHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { | public OkHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public String execute(String uri, String queryParam) throws WxErrorException, IOException { | |||||
logger.debug("OkHttpSimpleGetRequestExecutor is running"); | |||||
public String execute(String uri, String queryParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -35,7 +36,7 @@ public class OkHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<OkH | |||||
Request request = new Request.Builder().url(uri).build(); | Request request = new Request.Builder().url(uri).build(); | ||||
Response response = client.newCall(request).execute(); | Response response = client.newCall(request).execute(); | ||||
String responseContent = response.body().string(); | String responseContent = response.body().string(); | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -1,42 +1,38 @@ | |||||
package me.chanjar.weixin.common.util.http.okhttp; | package me.chanjar.weixin.common.util.http.okhttp; | ||||
import lombok.extern.slf4j.Slf4j; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; | import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; | ||||
import okhttp3.*; | import okhttp3.*; | ||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/4 | |||||
*/ | */ | ||||
@Slf4j | |||||
public class OkHttpSimplePostRequestExecutor extends SimplePostRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | public class OkHttpSimplePostRequestExecutor extends SimplePostRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | ||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
public OkHttpSimplePostRequestExecutor(RequestHttp requestHttp) { | public OkHttpSimplePostRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public String execute(String uri, String postEntity) throws WxErrorException, IOException { | |||||
logger.debug("OkHttpSimplePostRequestExecutor running"); | |||||
//得到httpClient | |||||
OkHttpClient client = requestHttp.getRequestHttpClient(); | |||||
MediaType mediaType = MediaType.parse("text/plain; charset=utf-8"); | |||||
RequestBody body = RequestBody.create(mediaType, postEntity); | |||||
public String execute(String uri, String postEntity, WxType wxType) throws WxErrorException, IOException { | |||||
RequestBody body = RequestBody.create(MediaType.parse("text/plain; charset=utf-8"), postEntity); | |||||
Request request = new Request.Builder().url(uri).post(body).build(); | Request request = new Request.Builder().url(uri).post(body).build(); | ||||
Response response = client.newCall(request).execute(); | |||||
Response response = requestHttp.getRequestHttpClient().newCall(request).execute(); | |||||
String responseContent = response.body().string(); | String responseContent = response.body().string(); | ||||
WxError error = WxError.fromJson(responseContent); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
return responseContent; | return responseContent; | ||||
} | } | ||||
@@ -1,34 +1,34 @@ | |||||
package me.chanjar.weixin.common.error; | package me.chanjar.weixin.common.error; | ||||
import org.testng.Assert; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import org.testng.annotations.Test; | import org.testng.annotations.Test; | ||||
import static org.testng.Assert.*; | |||||
import static org.testng.Assert.assertEquals; | |||||
import static org.testng.Assert.assertNull; | |||||
@Test | @Test | ||||
public class WxErrorTest { | public class WxErrorTest { | ||||
public void testFromJson() { | public void testFromJson() { | ||||
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }"; | String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }"; | ||||
WxError wxError = WxError.fromJson(json); | |||||
WxError wxError = WxError.fromJson(json, WxType.MP); | |||||
assertEquals(40003, wxError.getErrorCode()); | assertEquals(40003, wxError.getErrorCode()); | ||||
assertEquals(wxError.getErrorMsg(), "invalid openid"); | |||||
assertEquals(wxError.getErrorMsgEn(), "invalid openid"); | |||||
} | } | ||||
public void testFromBadJson1() { | public void testFromBadJson1() { | ||||
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\", \"media_id\": \"12323423dsfafsf232f\" }"; | String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\", \"media_id\": \"12323423dsfafsf232f\" }"; | ||||
WxError wxError = WxError.fromJson(json); | |||||
WxError wxError = WxError.fromJson(json, WxType.MP); | |||||
assertEquals(40003, wxError.getErrorCode()); | assertEquals(40003, wxError.getErrorCode()); | ||||
assertEquals(wxError.getErrorMsg(), "invalid openid"); | |||||
assertEquals(wxError.getErrorMsgEn(), "invalid openid"); | |||||
} | } | ||||
public void testFromBadJson2() { | public void testFromBadJson2() { | ||||
String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}"; | String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}"; | ||||
WxError wxError = WxError.fromJson(json); | |||||
WxError wxError = WxError.fromJson(json, WxType.MP); | |||||
assertEquals(0, wxError.getErrorCode()); | assertEquals(0, wxError.getErrorCode()); | ||||
assertEquals(wxError.getErrorMsg(), null); | |||||
assertNull(wxError.getErrorMsg()); | |||||
} | } | ||||
@@ -6,6 +6,7 @@ import com.google.gson.JsonElement; | |||||
import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
import com.google.gson.JsonParser; | import com.google.gson.JsonParser; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.bean.WxJsapiSignature; | import me.chanjar.weixin.common.bean.WxJsapiSignature; | ||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
@@ -24,9 +25,6 @@ import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; | |||||
import me.chanjar.weixin.cp.bean.WxCpMessage; | import me.chanjar.weixin.cp.bean.WxCpMessage; | ||||
import me.chanjar.weixin.cp.bean.WxCpMessageSendResult; | import me.chanjar.weixin.cp.bean.WxCpMessageSendResult; | ||||
import me.chanjar.weixin.cp.config.WxCpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpConfigStorage; | ||||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
@@ -260,7 +258,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||||
String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken; | String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken; | ||||
try { | try { | ||||
T result = executor.execute(uriWithAccessToken, data); | |||||
T result = executor.execute(uriWithAccessToken, data, WxType.CP); | |||||
log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | ||||
return result; | return result; | ||||
} catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
@@ -18,7 +18,6 @@ import me.chanjar.weixin.cp.api.WxCpTpService; | |||||
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; | import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; | ||||
import me.chanjar.weixin.cp.bean.WxCpTpCorp; | import me.chanjar.weixin.cp.bean.WxCpTpCorp; | ||||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | ||||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
@@ -183,7 +182,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||||
String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "suite_access_token=" + suiteAccessToken; | String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "suite_access_token=" + suiteAccessToken; | ||||
try { | try { | ||||
T result = executor.execute(uriWithAccessToken, data); | |||||
T result = executor.execute(uriWithAccessToken, data, WxType.CP); | |||||
log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | ||||
return result; | return result; | ||||
} catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
@@ -4,6 +4,7 @@ import com.google.gson.JsonObject; | |||||
import com.google.gson.JsonParser; | import com.google.gson.JsonParser; | ||||
import com.google.gson.reflect.TypeToken; | import com.google.gson.reflect.TypeToken; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.cp.api.WxCpAgentService; | import me.chanjar.weixin.cp.api.WxCpAgentService; | ||||
@@ -46,7 +47,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService { | |||||
String responseContent = this.mainService.post(url, agentInfo.toJson()); | String responseContent = this.mainService.post(url, agentInfo.toJson()); | ||||
JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | ||||
if (jsonObject.get("errcode").getAsInt() != 0) { | if (jsonObject.get("errcode").getAsInt() != 0) { | ||||
throw new WxErrorException(WxError.fromJson(responseContent)); | |||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP)); | |||||
} | } | ||||
} | } | ||||
@@ -56,7 +57,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService { | |||||
String responseContent = this.mainService.get(url, null); | String responseContent = this.mainService.get(url, null); | ||||
JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | ||||
if (jsonObject.get("errcode").getAsInt() != 0) { | if (jsonObject.get("errcode").getAsInt() != 0) { | ||||
throw new WxErrorException(WxError.fromJson(responseContent)); | |||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP)); | |||||
} | } | ||||
return WxCpGsonBuilder.create().fromJson(jsonObject.get("agentlist").toString(), new TypeToken<List<WxCpAgent>>() { | return WxCpGsonBuilder.create().fromJson(jsonObject.get("agentlist").toString(), new TypeToken<List<WxCpAgent>>() { | ||||
@@ -9,20 +9,29 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||||
import java.util.List; | import java.util.List; | ||||
public interface WxMaTemplateService { | public interface WxMaTemplateService { | ||||
//获取小程序模板库标题列表 | |||||
/** | |||||
* 获取小程序模板库标题列表 | |||||
*/ | |||||
String TEMPLATE_LIBRARY_LIST_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list"; | String TEMPLATE_LIBRARY_LIST_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list"; | ||||
//获取模板库某个模板标题下关键词库 | |||||
/** | |||||
* 获取模板库某个模板标题下关键词库 | |||||
*/ | |||||
String TEMPLATE_LIBRARY_KEYWORD_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get"; | String TEMPLATE_LIBRARY_KEYWORD_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get"; | ||||
//组合模板并添加至帐号下的个人模板库 | |||||
/** | |||||
* 组合模板并添加至帐号下的个人模板库 | |||||
*/ | |||||
String TEMPLATE_ADD_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/add"; | String TEMPLATE_ADD_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/add"; | ||||
//获取帐号下已存在的模板列表 | |||||
/** | |||||
* 获取帐号下已存在的模板列表 | |||||
*/ | |||||
String TEMPLATE_LIST_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/list"; | String TEMPLATE_LIST_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/list"; | ||||
//删除帐号下的某个模板 | |||||
/** | |||||
* 删除帐号下的某个模板 | |||||
*/ | |||||
String TEMPLATE_DEL_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/del"; | String TEMPLATE_DEL_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/del"; | ||||
/** | /** | ||||
@@ -32,6 +41,7 @@ public interface WxMaTemplateService { | |||||
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | * 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | ||||
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list?access_token=ACCESS_TOKEN | * 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list?access_token=ACCESS_TOKEN | ||||
* </pre> | * </pre> | ||||
* | |||||
* @param offset | * @param offset | ||||
* @param count | * @param count | ||||
* @return | * @return | ||||
@@ -45,6 +55,7 @@ public interface WxMaTemplateService { | |||||
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | * 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | ||||
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token=ACCESS_TOKEN | * 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token=ACCESS_TOKEN | ||||
* </pre> | * </pre> | ||||
* | |||||
* @param id | * @param id | ||||
* @return | * @return | ||||
*/ | */ | ||||
@@ -57,6 +68,7 @@ public interface WxMaTemplateService { | |||||
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | * 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | ||||
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/add?access_token=ACCESS_TOKEN | * 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/add?access_token=ACCESS_TOKEN | ||||
* </pre> | * </pre> | ||||
* | |||||
* @param id | * @param id | ||||
* @param keywordIdList | * @param keywordIdList | ||||
* @return | * @return | ||||
@@ -70,6 +82,7 @@ public interface WxMaTemplateService { | |||||
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | * 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | ||||
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/list?access_token=ACCESS_TOKEN | * 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/list?access_token=ACCESS_TOKEN | ||||
* </pre> | * </pre> | ||||
* | |||||
* @param offset | * @param offset | ||||
* @param count | * @param count | ||||
* @return | * @return | ||||
@@ -83,6 +96,7 @@ public interface WxMaTemplateService { | |||||
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | * 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a> | ||||
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/list?access_token=ACCESS_TOKEN | * 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/list?access_token=ACCESS_TOKEN | ||||
* </pre> | * </pre> | ||||
* | |||||
* @param templateId | * @param templateId | ||||
*/ | */ | ||||
boolean delTemplate(String templateId) throws WxErrorException; | boolean delTemplate(String templateId) throws WxErrorException; | ||||
@@ -12,6 +12,7 @@ import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; | |||||
import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
import com.google.gson.JsonParser; | import com.google.gson.JsonParser; | ||||
import com.google.gson.reflect.TypeToken; | import com.google.gson.reflect.TypeToken; | ||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import org.apache.commons.lang3.time.DateFormatUtils; | import org.apache.commons.lang3.time.DateFormatUtils; | ||||
@@ -23,14 +24,11 @@ import java.util.List; | |||||
* @author <a href="https://github.com/charmingoh">Charming</a> | * @author <a href="https://github.com/charmingoh">Charming</a> | ||||
* @since 2018-04-28 | * @since 2018-04-28 | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaAnalysisServiceImpl implements WxMaAnalysisService { | public class WxMaAnalysisServiceImpl implements WxMaAnalysisService { | ||||
private static final JsonParser JSON_PARSER = new JsonParser(); | private static final JsonParser JSON_PARSER = new JsonParser(); | ||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaAnalysisServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | @Override | ||||
public List<WxMaSummaryTrend> getDailySummaryTrend(Date beginDate, Date endDate) throws WxErrorException { | public List<WxMaSummaryTrend> getDailySummaryTrend(Date beginDate, Date endDate) throws WxErrorException { | ||||
return getAnalysisResultAsList(GET_DAILY_SUMMARY_TREND_URL, beginDate, endDate, | return getAnalysisResultAsList(GET_DAILY_SUMMARY_TREND_URL, beginDate, endDate, | ||||
@@ -8,6 +8,7 @@ import java.nio.file.Files; | |||||
import java.nio.file.Path; | import java.nio.file.Path; | ||||
import java.util.List; | import java.util.List; | ||||
import lombok.AllArgsConstructor; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import cn.binarywang.wx.miniapp.api.WxMaCodeService; | import cn.binarywang.wx.miniapp.api.WxMaCodeService; | ||||
@@ -31,14 +32,11 @@ import me.chanjar.weixin.common.util.json.GsonHelper; | |||||
* @author <a href="https://github.com/charmingoh">Charming</a> | * @author <a href="https://github.com/charmingoh">Charming</a> | ||||
* @since 2018-04-26 20:00 | * @since 2018-04-26 20:00 | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaCodeServiceImpl implements WxMaCodeService { | public class WxMaCodeServiceImpl implements WxMaCodeService { | ||||
private static final JsonParser JSON_PARSER = new JsonParser(); | private static final JsonParser JSON_PARSER = new JsonParser(); | ||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaCodeServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | @Override | ||||
public void commit(WxMaCodeCommitRequest commitRequest) throws WxErrorException { | public void commit(WxMaCodeCommitRequest commitRequest) throws WxErrorException { | ||||
this.wxMaService.post(COMMIT_URL, commitRequest.toJson()); | this.wxMaService.post(COMMIT_URL, commitRequest.toJson()); | ||||
@@ -50,7 +48,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService { | |||||
Path qrCodeFilePath = null; | Path qrCodeFilePath = null; | ||||
try { | try { | ||||
RequestExecutor<File, String> executor = BaseMediaDownloadRequestExecutor | RequestExecutor<File, String> executor = BaseMediaDownloadRequestExecutor | ||||
.create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("weixin-java-tools-ma-" + appId).toFile()); | |||||
.create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("wxjava-ma-" + appId).toFile()); | |||||
final StringBuilder url = new StringBuilder(GET_QRCODE_URL); | final StringBuilder url = new StringBuilder(GET_QRCODE_URL); | ||||
if (StringUtils.isNotBlank(path)) { | if (StringUtils.isNotBlank(path)) { | ||||
@@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
import com.google.gson.JsonElement; | import com.google.gson.JsonElement; | ||||
import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
import com.google.gson.JsonParser; | import com.google.gson.JsonParser; | ||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.bean.WxJsapiSignature; | import me.chanjar.weixin.common.bean.WxJsapiSignature; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.RandomUtils; | import me.chanjar.weixin.common.util.RandomUtils; | ||||
@@ -19,19 +20,18 @@ import java.util.concurrent.locks.Lock; | |||||
* | * | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaJsapiServiceImpl implements WxMaJsapiService { | public class WxMaJsapiServiceImpl implements WxMaJsapiService { | ||||
private static final JsonParser JSON_PARSER = new JsonParser(); | private static final JsonParser JSON_PARSER = new JsonParser(); | ||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaJsapiServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | |||||
public String getCardApiTicket() throws WxErrorException { | public String getCardApiTicket() throws WxErrorException { | ||||
return getCardApiTicket(false); | return getCardApiTicket(false); | ||||
} | } | ||||
@Override | |||||
public String getCardApiTicket(boolean forceRefresh) throws WxErrorException { | public String getCardApiTicket(boolean forceRefresh) throws WxErrorException { | ||||
Lock lock = this.wxMaService.getWxMaConfig().getCardApiTicketLock(); | Lock lock = this.wxMaService.getWxMaConfig().getCardApiTicketLock(); | ||||
try { | try { | ||||
@@ -2,8 +2,9 @@ package cn.binarywang.wx.miniapp.api.impl; | |||||
import cn.binarywang.wx.miniapp.api.WxMaMediaService; | import cn.binarywang.wx.miniapp.api.WxMaMediaService; | ||||
import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.fs.FileUtils; | import me.chanjar.weixin.common.util.fs.FileUtils; | ||||
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | ||||
@@ -19,13 +20,10 @@ import java.util.UUID; | |||||
/** | /** | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaMediaServiceImpl implements WxMaMediaService { | public class WxMaMediaServiceImpl implements WxMaMediaService { | ||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaMediaServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | @Override | ||||
public WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputStream inputStream) throws WxErrorException { | public WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputStream inputStream) throws WxErrorException { | ||||
try { | try { | ||||
@@ -8,20 +8,19 @@ import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage; | |||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants; | import cn.binarywang.wx.miniapp.constant.WxMaConstants; | ||||
import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
import com.google.gson.JsonParser; | import com.google.gson.JsonParser; | ||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
/** | /** | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaMsgServiceImpl implements WxMaMsgService { | public class WxMaMsgServiceImpl implements WxMaMsgService { | ||||
private static final JsonParser JSON_PARSER = new JsonParser(); | private static final JsonParser JSON_PARSER = new JsonParser(); | ||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaMsgServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | @Override | ||||
public boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException { | public boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException { | ||||
String responseContent = this.wxMaService.post(KEFU_MESSAGE_SEND_URL, message.toJson()); | String responseContent = this.wxMaService.post(KEFU_MESSAGE_SEND_URL, message.toJson()); | ||||
@@ -33,7 +32,7 @@ public class WxMaMsgServiceImpl implements WxMaMsgService { | |||||
String responseContent = this.wxMaService.post(TEMPLATE_MSG_SEND_URL, templateMessage.toJson()); | String responseContent = this.wxMaService.post(TEMPLATE_MSG_SEND_URL, templateMessage.toJson()); | ||||
JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | ||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { | if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { | ||||
throw new WxErrorException(WxError.fromJson(responseContent)); | |||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | |||||
} | } | ||||
} | } | ||||
@@ -42,7 +41,7 @@ public class WxMaMsgServiceImpl implements WxMaMsgService { | |||||
String responseContent = this.wxMaService.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson()); | String responseContent = this.wxMaService.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson()); | ||||
JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | ||||
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { | if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { | ||||
throw new WxErrorException(WxError.fromJson(responseContent)); | |||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | |||||
} | } | ||||
} | } | ||||
@@ -4,33 +4,28 @@ import cn.binarywang.wx.miniapp.api.WxMaPluginService; | |||||
import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
import cn.binarywang.wx.miniapp.bean.WxMaPluginListResult; | import cn.binarywang.wx.miniapp.bean.WxMaPluginListResult; | ||||
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; | import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; | ||||
import com.google.common.collect.ImmutableMap; | |||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import java.util.HashMap; | |||||
import java.util.Map; | import java.util.Map; | ||||
@AllArgsConstructor | |||||
public class WxMaPluginServiceImpl implements WxMaPluginService { | public class WxMaPluginServiceImpl implements WxMaPluginService { | ||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaPluginServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | @Override | ||||
public void applyPlugin(String pluginAppId, String reason) throws WxErrorException { | public void applyPlugin(String pluginAppId, String reason) throws WxErrorException { | ||||
Map<String, String> params = new HashMap<>(); | |||||
params.put("action", "apply"); | |||||
params.put("plugin_appid", pluginAppId); | |||||
params.put("reason", reason); | |||||
Map<String, String> params = ImmutableMap.of("action", "apply", | |||||
"plugin_appid", pluginAppId, | |||||
"reason", reason); | |||||
this.wxMaService.post(PLUGIN_URL, WxMaGsonBuilder.create().toJson(params)); | this.wxMaService.post(PLUGIN_URL, WxMaGsonBuilder.create().toJson(params)); | ||||
} | } | ||||
@Override | @Override | ||||
public WxMaPluginListResult getPluginList() throws WxErrorException { | public WxMaPluginListResult getPluginList() throws WxErrorException { | ||||
Map<String, String> params = new HashMap<>(); | |||||
params.put("action", "list"); | |||||
Map<String, String> params = ImmutableMap.of("action", "list"); | |||||
String responseContent = this.wxMaService.post(PLUGIN_URL, WxMaGsonBuilder.create().toJson(params)); | String responseContent = this.wxMaService.post(PLUGIN_URL, WxMaGsonBuilder.create().toJson(params)); | ||||
return WxMaPluginListResult.fromJson(responseContent); | return WxMaPluginListResult.fromJson(responseContent); | ||||
@@ -38,19 +33,15 @@ public class WxMaPluginServiceImpl implements WxMaPluginService { | |||||
@Override | @Override | ||||
public void unbindPlugin(String pluginAppId) throws WxErrorException { | public void unbindPlugin(String pluginAppId) throws WxErrorException { | ||||
Map<String, String> params = new HashMap<>(); | |||||
params.put("action", "unbind"); | |||||
params.put("plugin_appid", pluginAppId); | |||||
Map<String, String> params = ImmutableMap.of("action", "unbind", "plugin_appid", pluginAppId); | |||||
this.wxMaService.post(PLUGIN_URL, WxMaGsonBuilder.create().toJson(params)); | this.wxMaService.post(PLUGIN_URL, WxMaGsonBuilder.create().toJson(params)); | ||||
} | } | ||||
@Override | @Override | ||||
public void updatePlugin(String pluginAppId, String userVersion) throws WxErrorException { | public void updatePlugin(String pluginAppId, String userVersion) throws WxErrorException { | ||||
Map<String, String> params = new HashMap<>(); | |||||
params.put("action", "update"); | |||||
params.put("plugin_appid", pluginAppId); | |||||
params.put("user_version", userVersion); | |||||
Map<String, String> params = ImmutableMap.of("action", "update", | |||||
"plugin_appid", pluginAppId, | |||||
"user_version", userVersion); | |||||
this.wxMaService.post(PLUGIN_URL, WxMaGsonBuilder.create().toJson(params)); | this.wxMaService.post(PLUGIN_URL, WxMaGsonBuilder.create().toJson(params)); | ||||
} | } | ||||
@@ -1,7 +1,5 @@ | |||||
package cn.binarywang.wx.miniapp.api.impl; | package cn.binarywang.wx.miniapp.api.impl; | ||||
import java.io.File; | |||||
import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; | import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; | ||||
import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; | import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; | ||||
@@ -10,18 +8,18 @@ import cn.binarywang.wx.miniapp.bean.WxaCode; | |||||
import cn.binarywang.wx.miniapp.bean.WxaCodeUnlimit; | import cn.binarywang.wx.miniapp.bean.WxaCodeUnlimit; | ||||
import cn.binarywang.wx.miniapp.util.QrcodeBytesRequestExecutor; | import cn.binarywang.wx.miniapp.util.QrcodeBytesRequestExecutor; | ||||
import cn.binarywang.wx.miniapp.util.QrcodeRequestExecutor; | import cn.binarywang.wx.miniapp.util.QrcodeRequestExecutor; | ||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import java.io.File; | |||||
/** | /** | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaQrcodeServiceImpl implements WxMaQrcodeService { | public class WxMaQrcodeServiceImpl implements WxMaQrcodeService { | ||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaQrcodeServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | @Override | ||||
public byte[] createQrcodeBytes(String path, int width) throws WxErrorException { | public byte[] createQrcodeBytes(String path, int width) throws WxErrorException { | ||||
final QrcodeBytesRequestExecutor executor = new QrcodeBytesRequestExecutor(this.wxMaService.getRequestHttp()); | final QrcodeBytesRequestExecutor executor = new QrcodeBytesRequestExecutor(this.wxMaService.getRequestHttp()); | ||||
@@ -6,6 +6,7 @@ import cn.binarywang.wx.miniapp.api.WxMaRunService; | |||||
import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
import cn.binarywang.wx.miniapp.bean.WxMaRunStepInfo; | import cn.binarywang.wx.miniapp.bean.WxMaRunStepInfo; | ||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | ||||
import lombok.AllArgsConstructor; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -15,13 +16,10 @@ import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | |||||
* | * | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaRunServiceImpl implements WxMaRunService { | public class WxMaRunServiceImpl implements WxMaRunService { | ||||
private WxMaService service; | private WxMaService service; | ||||
public WxMaRunServiceImpl(WxMaService service) { | |||||
this.service = service; | |||||
} | |||||
@Override | @Override | ||||
public List<WxMaRunStepInfo> getRunStepInfo(String sessionKey, String encryptedData, String ivStr) { | public List<WxMaRunStepInfo> getRunStepInfo(String sessionKey, String encryptedData, String ivStr) { | ||||
return WxMaRunStepInfo.fromJson(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr)); | return WxMaRunStepInfo.fromJson(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr)); | ||||
@@ -1,14 +1,15 @@ | |||||
package cn.binarywang.wx.miniapp.api.impl; | package cn.binarywang.wx.miniapp.api.impl; | ||||
import java.io.File; | |||||
import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; | import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; | ||||
import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | ||||
import java.io.File; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* | * | ||||
@@ -17,13 +18,10 @@ import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | |||||
* | * | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaSecCheckServiceImpl implements WxMaSecCheckService { | public class WxMaSecCheckServiceImpl implements WxMaSecCheckService { | ||||
private WxMaService service; | private WxMaService service; | ||||
public WxMaSecCheckServiceImpl(WxMaService service) { | |||||
this.service = service; | |||||
} | |||||
@Override | @Override | ||||
public boolean checkImage(File file) throws WxErrorException { | public boolean checkImage(File file) throws WxErrorException { | ||||
//这里只是借用MediaUploadRequestExecutor,并不使用其返回值WxMediaUploadResult | //这里只是借用MediaUploadRequestExecutor,并不使用其返回值WxMediaUploadResult | ||||
@@ -119,7 +119,7 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl | |||||
} | } | ||||
try (CloseableHttpResponse response = getRequestHttpClient().execute(httpGet)) { | try (CloseableHttpResponse response = getRequestHttpClient().execute(httpGet)) { | ||||
String resultContent = new BasicResponseHandler().handleResponse(response); | String resultContent = new BasicResponseHandler().handleResponse(response); | ||||
WxError error = WxError.fromJson(resultContent); | |||||
WxError error = WxError.fromJson(resultContent, WxType.MiniApp); | |||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
throw new WxErrorException(error); | throw new WxErrorException(error); | ||||
} | } | ||||
@@ -251,7 +251,7 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl | |||||
String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken; | String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken; | ||||
try { | try { | ||||
T result = executor.execute(uriWithAccessToken, data); | |||||
T result = executor.execute(uriWithAccessToken, data, WxType.MiniApp); | |||||
log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | ||||
return result; | return result; | ||||
} catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
import cn.binarywang.wx.miniapp.api.WxMaSettingService; | import cn.binarywang.wx.miniapp.api.WxMaSettingService; | ||||
import cn.binarywang.wx.miniapp.bean.WxMaDomainAction; | import cn.binarywang.wx.miniapp.bean.WxMaDomainAction; | ||||
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; | import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; | ||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
@@ -13,13 +14,10 @@ import java.util.Map; | |||||
* @author <a href="https://github.com/charmingoh">Charming</a> | * @author <a href="https://github.com/charmingoh">Charming</a> | ||||
* @since 2018-04-27 15:46 | * @since 2018-04-27 15:46 | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaSettingServiceImpl implements WxMaSettingService { | public class WxMaSettingServiceImpl implements WxMaSettingService { | ||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaSettingServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | @Override | ||||
public WxMaDomainAction modifyDomain(WxMaDomainAction domainAction) throws WxErrorException { | public WxMaDomainAction modifyDomain(WxMaDomainAction domainAction) throws WxErrorException { | ||||
String responseContent = this.wxMaService.post(MODIFY_DOMAIN_URL, domainAction.toJson()); | String responseContent = this.wxMaService.post(MODIFY_DOMAIN_URL, domainAction.toJson()); | ||||
@@ -4,17 +4,15 @@ import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
import cn.binarywang.wx.miniapp.api.WxMaShareService; | import cn.binarywang.wx.miniapp.api.WxMaShareService; | ||||
import cn.binarywang.wx.miniapp.bean.WxMaShareInfo; | import cn.binarywang.wx.miniapp.bean.WxMaShareInfo; | ||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | ||||
import lombok.AllArgsConstructor; | |||||
/** | /** | ||||
* @author zhfish | * @author zhfish | ||||
*/ | */ | ||||
@AllArgsConstructor | |||||
public class WxMaShareServiceImpl implements WxMaShareService { | public class WxMaShareServiceImpl implements WxMaShareService { | ||||
private WxMaService service; | private WxMaService service; | ||||
public WxMaShareServiceImpl(WxMaService service) { | |||||
this.service = service; | |||||
} | |||||
@Override | @Override | ||||
public WxMaShareInfo getShareInfo(String sessionKey, String encryptedData, String ivStr) { | public WxMaShareInfo getShareInfo(String sessionKey, String encryptedData, String ivStr) { | ||||
return WxMaShareInfo.fromJson(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr)); | return WxMaShareInfo.fromJson(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr)); | ||||
@@ -1,101 +1,58 @@ | |||||
package cn.binarywang.wx.miniapp.api.impl; | package cn.binarywang.wx.miniapp.api.impl; | ||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
import cn.binarywang.wx.miniapp.api.WxMaTemplateService; | import cn.binarywang.wx.miniapp.api.WxMaTemplateService; | ||||
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateAddResult; | import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateAddResult; | ||||
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryGetResult; | import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryGetResult; | ||||
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult; | import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult; | ||||
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult; | import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import com.google.common.collect.ImmutableMap; | |||||
import lombok.AllArgsConstructor; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | import me.chanjar.weixin.common.util.json.WxGsonBuilder; | ||||
public class WxMaTemplateServiceImpl implements WxMaTemplateService { | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | |||||
* @author Binary | |||||
*/ | |||||
@AllArgsConstructor | |||||
public class WxMaTemplateServiceImpl implements WxMaTemplateService { | |||||
private WxMaService wxMaService; | private WxMaService wxMaService; | ||||
public WxMaTemplateServiceImpl(WxMaService wxMaService) { | |||||
this.wxMaService = wxMaService; | |||||
} | |||||
@Override | @Override | ||||
public WxMaTemplateLibraryListResult findTemplateLibraryList(int offset, int count) throws WxErrorException { | public WxMaTemplateLibraryListResult findTemplateLibraryList(int offset, int count) throws WxErrorException { | ||||
Map<String, Integer> params = new HashMap<>(); | |||||
params.put("offset", offset); | |||||
params.put("count", count); | |||||
Map<String, Integer> params = ImmutableMap.of("offset", offset, "count", count); | |||||
String responseText = this.wxMaService.post(TEMPLATE_LIBRARY_LIST_URL, WxGsonBuilder.create().toJson(params)); | String responseText = this.wxMaService.post(TEMPLATE_LIBRARY_LIST_URL, WxGsonBuilder.create().toJson(params)); | ||||
WxError wxError = WxError.fromJson(responseText); | |||||
if (wxError.getErrorCode() == 0) { | |||||
return WxMaTemplateLibraryListResult.fromJson(responseText); | |||||
} else { | |||||
throw new WxErrorException(wxError); | |||||
} | |||||
return WxMaTemplateLibraryListResult.fromJson(responseText); | |||||
} | } | ||||
@Override | @Override | ||||
public WxMaTemplateLibraryGetResult findTemplateLibraryKeywordList(String id) throws WxErrorException { | public WxMaTemplateLibraryGetResult findTemplateLibraryKeywordList(String id) throws WxErrorException { | ||||
Map<String, String> params = new HashMap<>(); | |||||
params.put("id", id); | |||||
String responseText = this.wxMaService.post(TEMPLATE_LIBRARY_KEYWORD_URL, WxGsonBuilder.create().toJson(params)); | |||||
WxError wxError = WxError.fromJson(responseText); | |||||
if (wxError.getErrorCode() == 0) { | |||||
return WxMaTemplateLibraryGetResult.fromJson(responseText); | |||||
} else { | |||||
throw new WxErrorException(wxError); | |||||
} | |||||
String responseText = this.wxMaService.post(TEMPLATE_LIBRARY_KEYWORD_URL, | |||||
WxGsonBuilder.create().toJson(ImmutableMap.of("id", id))); | |||||
return WxMaTemplateLibraryGetResult.fromJson(responseText); | |||||
} | } | ||||
@Override | @Override | ||||
public WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException { | public WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException { | ||||
Map<String, Object> params = new HashMap<>(); | |||||
params.put("id", id); | |||||
params.put("keyword_id_list", keywordIdList.toArray()); | |||||
String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, WxGsonBuilder.create().toJson(params)); | |||||
WxError wxError = WxError.fromJson(responseText); | |||||
if (wxError.getErrorCode() == 0) { | |||||
return WxMaTemplateAddResult.fromJson(responseText); | |||||
} else { | |||||
throw new WxErrorException(wxError); | |||||
} | |||||
String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, | |||||
WxGsonBuilder.create().toJson(ImmutableMap.of("id", id, "keyword_id_list", keywordIdList.toArray()))); | |||||
return WxMaTemplateAddResult.fromJson(responseText); | |||||
} | } | ||||
@Override | @Override | ||||
public WxMaTemplateListResult findTemplateList(int offset, int count) throws WxErrorException { | public WxMaTemplateListResult findTemplateList(int offset, int count) throws WxErrorException { | ||||
Map<String, Integer> params = new HashMap<>(); | |||||
params.put("offset", offset); | |||||
params.put("count", count); | |||||
Map<String, Integer> params = ImmutableMap.of("offset", offset, "count", count); | |||||
String responseText = this.wxMaService.post(TEMPLATE_LIST_URL, WxGsonBuilder.create().toJson(params)); | String responseText = this.wxMaService.post(TEMPLATE_LIST_URL, WxGsonBuilder.create().toJson(params)); | ||||
WxError wxError = WxError.fromJson(responseText); | |||||
if (wxError.getErrorCode() == 0) { | |||||
return WxMaTemplateListResult.fromJson(responseText); | |||||
} else { | |||||
throw new WxErrorException(wxError); | |||||
} | |||||
return WxMaTemplateListResult.fromJson(responseText); | |||||
} | } | ||||
@Override | @Override | ||||
public boolean delTemplate(String templateId) throws WxErrorException { | public boolean delTemplate(String templateId) throws WxErrorException { | ||||
Map<String, String> params = new HashMap<>(); | |||||
params.put("template_id", templateId); | |||||
String responseText = this.wxMaService.post(TEMPLATE_DEL_URL, WxGsonBuilder.create().toJson(params)); | |||||
WxError wxError = WxError.fromJson(responseText); | |||||
if (wxError.getErrorCode() == 0) { | |||||
return true; | |||||
} else { | |||||
throw new WxErrorException(wxError); | |||||
} | |||||
Map<String, String> params = ImmutableMap.of("template_id", templateId); | |||||
this.wxMaService.post(TEMPLATE_DEL_URL, WxGsonBuilder.create().toJson(params)); | |||||
return true; | |||||
} | } | ||||
} | } |
@@ -10,7 +10,6 @@ import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | |||||
import com.google.gson.JsonArray; | import com.google.gson.JsonArray; | ||||
import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.SignUtils; | import me.chanjar.weixin.common.util.SignUtils; | ||||
import org.apache.commons.codec.digest.DigestUtils; | import org.apache.commons.codec.digest.DigestUtils; | ||||
@@ -49,11 +48,7 @@ public class WxMaUserServiceImpl implements WxMaUserService { | |||||
String params = param.toString(); | String params = param.toString(); | ||||
String signature = SignUtils.createHmacSha256Sign(params, sessionKey); | String signature = SignUtils.createHmacSha256Sign(params, sessionKey); | ||||
String url = String.format(SET_USER_STORAGE, config.getAppid(), signature, openid, "hmac_sha256"); | String url = String.format(SET_USER_STORAGE, config.getAppid(), signature, openid, "hmac_sha256"); | ||||
String result = this.service.post(url, params); | |||||
WxError error = WxError.fromJson(result); | |||||
if (error.getErrorCode() != 0) { | |||||
throw new WxErrorException(error); | |||||
} | |||||
this.service.post(url, params); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -1,8 +1,14 @@ | |||||
package cn.binarywang.wx.miniapp.util; | package cn.binarywang.wx.miniapp.util; | ||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
import cn.binarywang.wx.miniapp.bean.AbstractWxMaQrcodeWrapper; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | |||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.RequestHttp; | |||||
import me.chanjar.weixin.common.util.http.ResponseHandler; | |||||
import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler; | |||||
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; | |||||
import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||
import org.apache.http.Header; | import org.apache.http.Header; | ||||
import org.apache.http.HttpHost; | import org.apache.http.HttpHost; | ||||
@@ -13,14 +19,8 @@ import org.apache.http.entity.ContentType; | |||||
import org.apache.http.entity.StringEntity; | import org.apache.http.entity.StringEntity; | ||||
import org.apache.http.impl.client.CloseableHttpClient; | import org.apache.http.impl.client.CloseableHttpClient; | ||||
import cn.binarywang.wx.miniapp.bean.AbstractWxMaQrcodeWrapper; | |||||
import me.chanjar.weixin.common.error.WxError; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | |||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.RequestHttp; | |||||
import me.chanjar.weixin.common.util.http.ResponseHandler; | |||||
import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler; | |||||
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
/** | /** | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
@@ -33,12 +33,12 @@ public class QrcodeBytesRequestExecutor implements RequestExecutor<byte[], Abstr | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, AbstractWxMaQrcodeWrapper data, ResponseHandler<byte[]> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, AbstractWxMaQrcodeWrapper data, ResponseHandler<byte[]> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
@Override | @Override | ||||
public byte[] execute(String uri, AbstractWxMaQrcodeWrapper qrcodeWrapper) throws WxErrorException, IOException { | |||||
public byte[] execute(String uri, AbstractWxMaQrcodeWrapper qrcodeWrapper, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
httpPost.setConfig( | httpPost.setConfig( | ||||
@@ -55,7 +55,7 @@ public class QrcodeBytesRequestExecutor implements RequestExecutor<byte[], Abstr | |||||
&& ContentType.APPLICATION_JSON.getMimeType() | && ContentType.APPLICATION_JSON.getMimeType() | ||||
.equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) { | .equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) { | ||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | ||||
throw new WxErrorException(WxError.fromJson(responseContent)); | |||||
throw new WxErrorException(WxError.fromJson(responseContent, wxType)); | |||||
} | } | ||||
return IOUtils.toByteArray(inputStream); | return IOUtils.toByteArray(inputStream); | ||||
@@ -1,20 +1,7 @@ | |||||
package cn.binarywang.wx.miniapp.util; | package cn.binarywang.wx.miniapp.util; | ||||
import java.io.File; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
import java.util.UUID; | |||||
import org.apache.http.Header; | |||||
import org.apache.http.HttpHost; | |||||
import org.apache.http.client.config.RequestConfig; | |||||
import org.apache.http.client.methods.CloseableHttpResponse; | |||||
import org.apache.http.client.methods.HttpPost; | |||||
import org.apache.http.entity.ContentType; | |||||
import org.apache.http.entity.StringEntity; | |||||
import org.apache.http.impl.client.CloseableHttpClient; | |||||
import cn.binarywang.wx.miniapp.bean.AbstractWxMaQrcodeWrapper; | import cn.binarywang.wx.miniapp.bean.AbstractWxMaQrcodeWrapper; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.fs.FileUtils; | import me.chanjar.weixin.common.util.fs.FileUtils; | ||||
@@ -23,6 +10,19 @@ import me.chanjar.weixin.common.util.http.RequestHttp; | |||||
import me.chanjar.weixin.common.util.http.ResponseHandler; | import me.chanjar.weixin.common.util.http.ResponseHandler; | ||||
import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler; | import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler; | ||||
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; | import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler; | ||||
import org.apache.http.Header; | |||||
import org.apache.http.HttpHost; | |||||
import org.apache.http.client.config.RequestConfig; | |||||
import org.apache.http.client.methods.CloseableHttpResponse; | |||||
import org.apache.http.client.methods.HttpPost; | |||||
import org.apache.http.entity.ContentType; | |||||
import org.apache.http.entity.StringEntity; | |||||
import org.apache.http.impl.client.CloseableHttpClient; | |||||
import java.io.File; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
import java.util.UUID; | |||||
/** | /** | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
@@ -35,12 +35,12 @@ public class QrcodeRequestExecutor implements RequestExecutor<File, AbstractWxMa | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, AbstractWxMaQrcodeWrapper data, ResponseHandler<File> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, AbstractWxMaQrcodeWrapper data, ResponseHandler<File> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, AbstractWxMaQrcodeWrapper qrcodeWrapper) throws WxErrorException, IOException { | |||||
public File execute(String uri, AbstractWxMaQrcodeWrapper qrcodeWrapper, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
httpPost.setConfig( | httpPost.setConfig( | ||||
@@ -57,7 +57,7 @@ public class QrcodeRequestExecutor implements RequestExecutor<File, AbstractWxMa | |||||
&& ContentType.APPLICATION_JSON.getMimeType() | && ContentType.APPLICATION_JSON.getMimeType() | ||||
.equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) { | .equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) { | ||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | ||||
throw new WxErrorException(WxError.fromJson(responseContent)); | |||||
throw new WxErrorException(WxError.fromJson(responseContent, wxType)); | |||||
} | } | ||||
return FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), "jpg"); | return FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), "jpg"); | ||||
@@ -7,6 +7,7 @@ import com.google.gson.JsonElement; | |||||
import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
import com.google.gson.JsonParser; | import com.google.gson.JsonParser; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.bean.WxJsapiSignature; | import me.chanjar.weixin.common.bean.WxJsapiSignature; | ||||
import me.chanjar.weixin.common.bean.WxNetCheckResult; | import me.chanjar.weixin.common.bean.WxNetCheckResult; | ||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
@@ -180,7 +181,7 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH | |||||
private WxMpOAuth2AccessToken getOAuth2AccessToken(String url) throws WxErrorException { | private WxMpOAuth2AccessToken getOAuth2AccessToken(String url) throws WxErrorException { | ||||
try { | try { | ||||
RequestExecutor<String, String> executor = SimpleGetRequestExecutor.create(this); | RequestExecutor<String, String> executor = SimpleGetRequestExecutor.create(this); | ||||
String responseText = executor.execute(url, null); | |||||
String responseText = executor.execute(url, null, WxType.MP); | |||||
return WxMpOAuth2AccessToken.fromJson(responseText); | return WxMpOAuth2AccessToken.fromJson(responseText); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new RuntimeException(e); | throw new RuntimeException(e); | ||||
@@ -210,7 +211,7 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH | |||||
try { | try { | ||||
RequestExecutor<String, String> executor = SimpleGetRequestExecutor.create(this); | RequestExecutor<String, String> executor = SimpleGetRequestExecutor.create(this); | ||||
String responseText = executor.execute(url, null); | |||||
String responseText = executor.execute(url, null, WxType.MP); | |||||
return WxMpUser.fromJson(responseText); | return WxMpUser.fromJson(responseText); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new RuntimeException(e); | throw new RuntimeException(e); | ||||
@@ -222,7 +223,7 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH | |||||
String url = String.format(OAUTH2_VALIDATE_TOKEN_URL.getUrl(this.getWxMpConfigStorage()), token.getAccessToken(), token.getOpenId()); | String url = String.format(OAUTH2_VALIDATE_TOKEN_URL.getUrl(this.getWxMpConfigStorage()), token.getAccessToken(), token.getOpenId()); | ||||
try { | try { | ||||
SimpleGetRequestExecutor.create(this).execute(url, null); | |||||
SimpleGetRequestExecutor.create(this).execute(url, null, WxType.MP); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new RuntimeException(e); | throw new RuntimeException(e); | ||||
} catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
@@ -333,11 +334,10 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH | |||||
} | } | ||||
String accessToken = getAccessToken(false); | String accessToken = getAccessToken(false); | ||||
String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken; | String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken; | ||||
try { | try { | ||||
T result = executor.execute(uriWithAccessToken, data); | |||||
T result = executor.execute(uriWithAccessToken, data, WxType.MP); | |||||
log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); | ||||
return result; | return result; | ||||
} catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
@@ -26,7 +26,7 @@ public class MaterialDeleteApacheHttpRequestExecutor extends MaterialDeleteReque | |||||
} | } | ||||
@Override | @Override | ||||
public Boolean execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public Boolean execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | ||||
@@ -22,7 +22,7 @@ public class MaterialDeleteJoddHttpRequestExecutor extends MaterialDeleteRequest | |||||
} | } | ||||
@Override | @Override | ||||
public Boolean execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public Boolean execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
HttpRequest request = HttpRequest.post(uri); | HttpRequest request = HttpRequest.post(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | ||||
@@ -28,12 +28,12 @@ public class MaterialDeleteOkhttpRequestExecutor extends MaterialDeleteRequestEx | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, String data, ResponseHandler<Boolean> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, String data, ResponseHandler<Boolean> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
@Override | @Override | ||||
public Boolean execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public Boolean execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
logger.debug("MaterialDeleteOkhttpRequestExecutor is running"); | logger.debug("MaterialDeleteOkhttpRequestExecutor is running"); | ||||
//得到httpClient | //得到httpClient | ||||
OkHttpClient client = requestHttp.getRequestHttpClient(); | OkHttpClient client = requestHttp.getRequestHttpClient(); | ||||
@@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.util.requestexecuter.material; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -15,8 +16,8 @@ public abstract class MaterialDeleteRequestExecutor<H, P> implements RequestExec | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, String data, ResponseHandler<Boolean> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, String data, ResponseHandler<Boolean> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<Boolean, String> create(RequestHttp requestHttp) { | public static RequestExecutor<Boolean, String> create(RequestHttp requestHttp) { | ||||
@@ -35,7 +35,7 @@ public class MaterialNewsInfoApacheHttpRequestExecutor | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public WxMpMaterialNews execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | ||||
@@ -29,7 +29,7 @@ public class MaterialNewsInfoJoddHttpRequestExecutor extends MaterialNewsInfoReq | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public WxMpMaterialNews execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | ||||
} | } | ||||
@@ -1,6 +1,7 @@ | |||||
package me.chanjar.weixin.mp.util.requestexecuter.material; | package me.chanjar.weixin.mp.util.requestexecuter.material; | ||||
import com.google.common.collect.ImmutableMap; | import com.google.common.collect.ImmutableMap; | ||||
import lombok.extern.slf4j.Slf4j; | |||||
import me.chanjar.weixin.common.WxType; | import me.chanjar.weixin.common.WxType; | ||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
@@ -10,24 +11,23 @@ import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | ||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
import okhttp3.*; | import okhttp3.*; | ||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | |||||
* . | |||||
* | |||||
* @author ecoolper | |||||
* @date 2017/5/5 | |||||
*/ | */ | ||||
@Slf4j | |||||
public class MaterialNewsInfoOkhttpRequestExecutor extends MaterialNewsInfoRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | public class MaterialNewsInfoOkhttpRequestExecutor extends MaterialNewsInfoRequestExecutor<OkHttpClient, OkHttpProxyInfo> { | ||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
public MaterialNewsInfoOkhttpRequestExecutor(RequestHttp requestHttp) { | public MaterialNewsInfoOkhttpRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
//得到httpClient | |||||
public WxMpMaterialNews execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
OkHttpClient client = requestHttp.getRequestHttpClient(); | OkHttpClient client = requestHttp.getRequestHttpClient(); | ||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), | RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), | ||||
@@ -36,7 +36,7 @@ public class MaterialNewsInfoOkhttpRequestExecutor extends MaterialNewsInfoReque | |||||
Response response = client.newCall(request).execute(); | Response response = client.newCall(request).execute(); | ||||
String responseContent = response.body().string(); | String responseContent = response.body().string(); | ||||
this.logger.debug("响应原始数据:{}", responseContent); | |||||
log.debug("响应原始数据:{}", responseContent); | |||||
WxError error = WxError.fromJson(responseContent, WxType.MP); | WxError error = WxError.fromJson(responseContent, WxType.MP); | ||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
@@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.util.requestexecuter.material; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -16,8 +17,8 @@ public abstract class MaterialNewsInfoRequestExecutor<H, P> implements RequestEx | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, String data, ResponseHandler<WxMpMaterialNews> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, String data, ResponseHandler<WxMpMaterialNews> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<WxMpMaterialNews, String> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMpMaterialNews, String> create(RequestHttp requestHttp) { | ||||
@@ -33,7 +33,7 @@ public class MaterialUploadApacheHttpRequestExecutor extends MaterialUploadReque | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throws WxErrorException, IOException { | |||||
public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
RequestConfig response = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | RequestConfig response = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | ||||
@@ -28,7 +28,7 @@ public class MaterialUploadJoddHttpRequestExecutor extends MaterialUploadRequest | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throws WxErrorException, IOException { | |||||
public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material, WxType wxType) throws WxErrorException, IOException { | |||||
HttpRequest request = HttpRequest.post(uri); | HttpRequest request = HttpRequest.post(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | ||||
@@ -28,7 +28,7 @@ public class MaterialUploadOkhttpRequestExecutor extends MaterialUploadRequestEx | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throws WxErrorException, IOException { | |||||
public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material, WxType wxType) throws WxErrorException, IOException { | |||||
logger.debug("MaterialUploadOkhttpRequestExecutor is running"); | logger.debug("MaterialUploadOkhttpRequestExecutor is running"); | ||||
if (material == null) { | if (material == null) { | ||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法请求,material参数为空").build()); | throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法请求,material参数为空").build()); | ||||
@@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.util.requestexecuter.material; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -20,8 +21,8 @@ public abstract class MaterialUploadRequestExecutor<H, P> implements RequestExec | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, WxMpMaterial data, ResponseHandler<WxMpMaterialUploadResult> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, WxMpMaterial data, ResponseHandler<WxMpMaterialUploadResult> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<WxMpMaterialUploadResult, WxMpMaterial> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMpMaterialUploadResult, WxMpMaterial> create(RequestHttp requestHttp) { | ||||
@@ -27,7 +27,7 @@ public class MaterialVideoInfoApacheHttpRequestExecutor extends MaterialVideoInf | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialVideoInfoResult execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public WxMpMaterialVideoInfoResult execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | ||||
@@ -23,7 +23,7 @@ public class MaterialVideoInfoJoddHttpRequestExecutor extends MaterialVideoInfoR | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialVideoInfoResult execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public WxMpMaterialVideoInfoResult execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
HttpRequest request = HttpRequest.post(uri); | HttpRequest request = HttpRequest.post(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | ||||
@@ -23,7 +23,7 @@ public class MaterialVideoInfoOkhttpRequestExecutor extends MaterialVideoInfoReq | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpMaterialVideoInfoResult execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public WxMpMaterialVideoInfoResult execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
logger.debug("MaterialVideoInfoOkhttpRequestExecutor is running"); | logger.debug("MaterialVideoInfoOkhttpRequestExecutor is running"); | ||||
//得到httpClient | //得到httpClient | ||||
OkHttpClient client = requestHttp.getRequestHttpClient(); | OkHttpClient client = requestHttp.getRequestHttpClient(); | ||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.util.requestexecuter.material; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -17,8 +18,8 @@ public abstract class MaterialVideoInfoRequestExecutor<H, P> implements RequestE | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, String data, ResponseHandler<WxMpMaterialVideoInfoResult> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, String data, ResponseHandler<WxMpMaterialVideoInfoResult> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<WxMpMaterialVideoInfoResult, String> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMpMaterialVideoInfoResult, String> create(RequestHttp requestHttp) { | ||||
@@ -1,5 +1,6 @@ | |||||
package me.chanjar.weixin.mp.util.requestexecuter.material; | package me.chanjar.weixin.mp.util.requestexecuter.material; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -30,7 +31,7 @@ public class MaterialVoiceAndImageDownloadApacheHttpRequestExecutor extends Mate | |||||
} | } | ||||
@Override | @Override | ||||
public InputStream execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public InputStream execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | ||||
@@ -6,6 +6,7 @@ import jodd.http.HttpResponse; | |||||
import jodd.http.ProxyInfo; | import jodd.http.ProxyInfo; | ||||
import jodd.util.StringPool; | import jodd.util.StringPool; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -27,7 +28,7 @@ public class MaterialVoiceAndImageDownloadJoddHttpRequestExecutor extends Materi | |||||
} | } | ||||
@Override | @Override | ||||
public InputStream execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public InputStream execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
HttpRequest request = HttpRequest.post(uri); | HttpRequest request = HttpRequest.post(uri); | ||||
if (requestHttp.getRequestHttpProxy() != null) { | if (requestHttp.getRequestHttpProxy() != null) { | ||||
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); | ||||
@@ -24,7 +24,7 @@ public class MaterialVoiceAndImageDownloadOkhttpRequestExecutor extends Material | |||||
} | } | ||||
@Override | @Override | ||||
public InputStream execute(String uri, String materialId) throws WxErrorException, IOException { | |||||
public InputStream execute(String uri, String materialId, WxType wxType) throws WxErrorException, IOException { | |||||
logger.debug("MaterialVoiceAndImageDownloadOkhttpRequestExecutor is running"); | logger.debug("MaterialVoiceAndImageDownloadOkhttpRequestExecutor is running"); | ||||
OkHttpClient client = requestHttp.getRequestHttpClient(); | OkHttpClient client = requestHttp.getRequestHttpClient(); | ||||
RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build(); | RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build(); | ||||
@@ -4,6 +4,7 @@ import java.io.File; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -19,8 +20,8 @@ public abstract class MaterialVoiceAndImageDownloadRequestExecutor<H, P> impleme | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, String data, ResponseHandler<InputStream> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, String data, ResponseHandler<InputStream> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<InputStream, String> create(RequestHttp requestHttp, File tmpDirFile) { | public static RequestExecutor<InputStream, String> create(RequestHttp requestHttp, File tmpDirFile) { | ||||
@@ -30,7 +30,7 @@ public class MediaImgUploadApacheHttpRequestExecutor extends MediaImgUploadReque | |||||
} | } | ||||
@Override | @Override | ||||
public WxMediaImgUploadResult execute(String uri, File data) throws WxErrorException, IOException { | |||||
public WxMediaImgUploadResult execute(String uri, File data, WxType wxType) throws WxErrorException, IOException { | |||||
if (data == null) { | if (data == null) { | ||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build()); | throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build()); | ||||
} | } | ||||
@@ -26,7 +26,7 @@ public class MediaImgUploadHttpRequestExecutor extends MediaImgUploadRequestExec | |||||
} | } | ||||
@Override | @Override | ||||
public WxMediaImgUploadResult execute(String uri, File data) throws WxErrorException, IOException { | |||||
public WxMediaImgUploadResult execute(String uri, File data, WxType wxType) throws WxErrorException, IOException { | |||||
if (data == null) { | if (data == null) { | ||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build()); | throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build()); | ||||
} | } | ||||
@@ -26,7 +26,7 @@ public class MediaImgUploadOkhttpRequestExecutor extends MediaImgUploadRequestEx | |||||
} | } | ||||
@Override | @Override | ||||
public WxMediaImgUploadResult execute(String uri, File file) throws WxErrorException, IOException { | |||||
public WxMediaImgUploadResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { | |||||
logger.debug("MediaImgUploadOkhttpRequestExecutor is running"); | logger.debug("MediaImgUploadOkhttpRequestExecutor is running"); | ||||
//得到httpClient | //得到httpClient | ||||
OkHttpClient client = requestHttp.getRequestHttpClient(); | OkHttpClient client = requestHttp.getRequestHttpClient(); | ||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.util.requestexecuter.media; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -20,8 +21,8 @@ public abstract class MediaImgUploadRequestExecutor<H, P> implements RequestExec | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, File data, ResponseHandler<WxMediaImgUploadResult> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, File data, ResponseHandler<WxMediaImgUploadResult> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<WxMediaImgUploadResult, File> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMediaImgUploadResult, File> create(RequestHttp requestHttp) { | ||||
@@ -1,5 +1,6 @@ | |||||
package me.chanjar.weixin.mp.util.requestexecuter.ocr; | package me.chanjar.weixin.mp.util.requestexecuter.ocr; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -17,41 +18,40 @@ import java.io.File; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* . | |||||
* | |||||
* @author : zhayueran | * @author : zhayueran | ||||
* @Date: 2019/6/27 14:06 | |||||
* @Description: | |||||
* @date 2019/6/27 14:06 | |||||
*/ | */ | ||||
public class OcrDiscernApacheHttpRequestExecutor extends OcrDiscernRequestExecutor<CloseableHttpClient, HttpHost> { | public class OcrDiscernApacheHttpRequestExecutor extends OcrDiscernRequestExecutor<CloseableHttpClient, HttpHost> { | ||||
public OcrDiscernApacheHttpRequestExecutor(RequestHttp requestHttp) { | public OcrDiscernApacheHttpRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public String execute(String uri, File file) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | |||||
if (requestHttp.getRequestHttpProxy() != null) { | |||||
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | |||||
httpPost.setConfig(config); | |||||
} | |||||
if (file != null) { | |||||
HttpEntity entity = MultipartEntityBuilder | |||||
.create() | |||||
.addBinaryBody("file", file) | |||||
.setMode(HttpMultipartMode.RFC6532) | |||||
.build(); | |||||
httpPost.setEntity(entity); | |||||
} | |||||
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { | |||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | |||||
WxError error = WxError.fromJson(responseContent); | |||||
if (error.getErrorCode() != 0) { | |||||
throw new WxErrorException(error); | |||||
} | |||||
return responseContent; | |||||
} finally { | |||||
httpPost.releaseConnection(); | |||||
} | |||||
public String execute(String uri, File file, WxType wxType) throws WxErrorException, IOException { | |||||
HttpPost httpPost = new HttpPost(uri); | |||||
if (requestHttp.getRequestHttpProxy() != null) { | |||||
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | |||||
httpPost.setConfig(config); | |||||
} | |||||
if (file != null) { | |||||
HttpEntity entity = MultipartEntityBuilder | |||||
.create() | |||||
.addBinaryBody("file", file) | |||||
.setMode(HttpMultipartMode.RFC6532) | |||||
.build(); | |||||
httpPost.setEntity(entity); | |||||
} | } | ||||
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { | |||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | |||||
WxError error = WxError.fromJson(responseContent, wxType); | |||||
if (error.getErrorCode() != 0) { | |||||
throw new WxErrorException(error); | |||||
} | |||||
return responseContent; | |||||
} finally { | |||||
httpPost.releaseConnection(); | |||||
} | |||||
} | |||||
} | } |
@@ -1,5 +1,6 @@ | |||||
package me.chanjar.weixin.mp.util.requestexecuter.ocr; | package me.chanjar.weixin.mp.util.requestexecuter.ocr; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -9,28 +10,29 @@ import java.io.File; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
/** | /** | ||||
* @author : zhayueran | |||||
* @Date: 2019/6/27 15:06 | |||||
* @Description: | |||||
* . | |||||
* | |||||
* @author zhayueran | |||||
* @date 2019/6/27 15:06 | |||||
*/ | */ | ||||
public abstract class OcrDiscernRequestExecutor<H, P> implements RequestExecutor<String, File> { | public abstract class OcrDiscernRequestExecutor<H, P> implements RequestExecutor<String, File> { | ||||
protected RequestHttp<H, P> requestHttp; | |||||
protected RequestHttp<H, P> requestHttp; | |||||
public OcrDiscernRequestExecutor(RequestHttp requestHttp) { | |||||
this.requestHttp = requestHttp; | |||||
} | |||||
public OcrDiscernRequestExecutor(RequestHttp requestHttp) { | |||||
this.requestHttp = requestHttp; | |||||
} | |||||
@Override | |||||
public void execute(String uri, File data, ResponseHandler<String> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
} | |||||
@Override | |||||
public void execute(String uri, File data, ResponseHandler<String> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | |||||
public static RequestExecutor<String, File> create(RequestHttp requestHttp) { | |||||
switch (requestHttp.getRequestType()) { | |||||
case APACHE_HTTP: | |||||
return new OcrDiscernApacheHttpRequestExecutor(requestHttp); | |||||
default: | |||||
return null; | |||||
} | |||||
public static RequestExecutor<String, File> create(RequestHttp requestHttp) { | |||||
switch (requestHttp.getRequestType()) { | |||||
case APACHE_HTTP: | |||||
return new OcrDiscernApacheHttpRequestExecutor(requestHttp); | |||||
default: | |||||
return null; | |||||
} | } | ||||
} | |||||
} | } |
@@ -31,7 +31,7 @@ public class QrCodeApacheHttpRequestExecutor extends QrCodeRequestExecutor<Close | |||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, WxMpQrCodeTicket ticket) throws WxErrorException, IOException { | |||||
public File execute(String uri, WxMpQrCodeTicket ticket, WxType wxType) throws WxErrorException, IOException { | |||||
if (ticket != null) { | if (ticket != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -30,7 +30,7 @@ public class QrCodeJoddHttpRequestExecutor extends QrCodeRequestExecutor<HttpCon | |||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, WxMpQrCodeTicket ticket) throws WxErrorException, IOException { | |||||
public File execute(String uri, WxMpQrCodeTicket ticket, WxType wxType) throws WxErrorException, IOException { | |||||
if (ticket != null) { | if (ticket != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -32,7 +32,7 @@ public class QrCodeOkhttpRequestExecutor extends QrCodeRequestExecutor<OkHttpCli | |||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, WxMpQrCodeTicket ticket) throws WxErrorException, IOException { | |||||
public File execute(String uri, WxMpQrCodeTicket ticket, WxType wxType) throws WxErrorException, IOException { | |||||
logger.debug("QrCodeOkhttpRequestExecutor is running"); | logger.debug("QrCodeOkhttpRequestExecutor is running"); | ||||
if (ticket != null) { | if (ticket != null) { | ||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.util.requestexecuter.qrcode; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
@@ -23,8 +24,8 @@ public abstract class QrCodeRequestExecutor<H, P> implements RequestExecutor<Fil | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, WxMpQrCodeTicket data, ResponseHandler<File> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, WxMpQrCodeTicket data, ResponseHandler<File> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<File, WxMpQrCodeTicket> create(RequestHttp requestHttp) throws WxErrorException { | public static RequestExecutor<File, WxMpQrCodeTicket> create(RequestHttp requestHttp) throws WxErrorException { | ||||
@@ -31,7 +31,7 @@ public class VoiceUploadApacheHttpRequestExecutor extends VoiceUploadRequestExec | |||||
} | } | ||||
@Override | @Override | ||||
public Boolean execute(String uri, File data) throws WxErrorException, IOException { | |||||
public Boolean execute(String uri, File data, WxType wxType) throws WxErrorException, IOException { | |||||
if (data == null) { | if (data == null) { | ||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build()); | throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build()); | ||||
} | } | ||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.util.requestexecuter.voice; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
@@ -23,8 +24,8 @@ public abstract class VoiceUploadRequestExecutor<H, P> implements RequestExecuto | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, File data, ResponseHandler<Boolean> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, File data, ResponseHandler<Boolean> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<Boolean, File> create(RequestHttp requestHttp) { | public static RequestExecutor<Boolean, File> create(RequestHttp requestHttp) { | ||||
@@ -1,10 +1,6 @@ | |||||
package me.chanjar.weixin.open.api.impl; | package me.chanjar.weixin.open.api.impl; | ||||
import java.io.IOException; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
@@ -12,6 +8,10 @@ import me.chanjar.weixin.common.util.http.RequestHttp; | |||||
import me.chanjar.weixin.open.api.WxOpenComponentService; | import me.chanjar.weixin.open.api.WxOpenComponentService; | ||||
import me.chanjar.weixin.open.api.WxOpenConfigStorage; | import me.chanjar.weixin.open.api.WxOpenConfigStorage; | ||||
import me.chanjar.weixin.open.api.WxOpenService; | import me.chanjar.weixin.open.api.WxOpenService; | ||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import java.io.IOException; | |||||
/** | /** | ||||
* @author <a href="https://github.com/007gzs">007</a> | * @author <a href="https://github.com/007gzs">007</a> | ||||
@@ -44,7 +44,7 @@ public abstract class WxOpenServiceAbstractImpl<H, P> implements WxOpenService, | |||||
protected synchronized <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { | protected synchronized <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { | ||||
try { | try { | ||||
T result = executor.execute(uri, data); | |||||
T result = executor.execute(uri, data, WxType.Open); | |||||
this.log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uri, data, result); | this.log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uri, data, result); | ||||
return result; | return result; | ||||
} catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
@@ -33,7 +33,7 @@ public class MaQrCodeApacheHttpRequestExecutor extends MaQrCodeRequestExecutor<C | |||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, WxMaQrcodeParam qrcodeParam) throws WxErrorException, IOException { | |||||
public File execute(String uri, WxMaQrcodeParam qrcodeParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (qrcodeParam != null && StringUtils.isNotBlank(qrcodeParam.getPagePath())) { | if (qrcodeParam != null && StringUtils.isNotBlank(qrcodeParam.getPagePath())) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -31,7 +31,7 @@ public class MaQrCodeJoddHttpRequestExecutor extends MaQrCodeRequestExecutor<Htt | |||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, WxMaQrcodeParam qrcodeParam) throws WxErrorException, IOException { | |||||
public File execute(String uri, WxMaQrcodeParam qrcodeParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (qrcodeParam != null && StringUtils.isNotBlank(qrcodeParam.getPagePath())) { | if (qrcodeParam != null && StringUtils.isNotBlank(qrcodeParam.getPagePath())) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -32,7 +32,7 @@ public class MaQrCodeOkhttpRequestExecutor extends MaQrCodeRequestExecutor<OkHtt | |||||
} | } | ||||
@Override | @Override | ||||
public File execute(String uri, WxMaQrcodeParam qrcodeParam) throws WxErrorException, IOException { | |||||
public File execute(String uri, WxMaQrcodeParam qrcodeParam, WxType wxType) throws WxErrorException, IOException { | |||||
if (qrcodeParam != null && StringUtils.isNotBlank(qrcodeParam.getPagePath())) { | if (qrcodeParam != null && StringUtils.isNotBlank(qrcodeParam.getPagePath())) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
uri += '?'; | uri += '?'; | ||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.open.util.requestexecuter.ma; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import me.chanjar.weixin.common.WxType; | |||||
import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
@@ -24,8 +25,8 @@ public abstract class MaQrCodeRequestExecutor<H, P> implements RequestExecutor<F | |||||
} | } | ||||
@Override | @Override | ||||
public void execute(String uri, WxMaQrcodeParam data, ResponseHandler<File> handler) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data)); | |||||
public void execute(String uri, WxMaQrcodeParam data, ResponseHandler<File> handler, WxType wxType) throws WxErrorException, IOException { | |||||
handler.handle(this.execute(uri, data, wxType)); | |||||
} | } | ||||
public static RequestExecutor<File, WxMaQrcodeParam> create(RequestHttp requestHttp) throws WxErrorException { | public static RequestExecutor<File, WxMaQrcodeParam> create(RequestHttp requestHttp) throws WxErrorException { | ||||
@@ -50,7 +50,7 @@ public interface EntPayService { | |||||
* 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo | * 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo | ||||
* </pre> | * </pre> | ||||
* | * | ||||
* @param partnerTradeNo 商户订单号 | |||||
* @param request 请求对象 | |||||
* @return the ent pay query result | * @return the ent pay query result | ||||
* @throws WxPayException the wx pay exception | * @throws WxPayException the wx pay exception | ||||
*/ | */ | ||||
@@ -105,6 +105,7 @@ public interface EntPayService { | |||||
* @throws WxPayException the wx pay exception | * @throws WxPayException the wx pay exception | ||||
*/ | */ | ||||
EntPayBankQueryResult queryPayBank(String partnerTradeNo) throws WxPayException; | EntPayBankQueryResult queryPayBank(String partnerTradeNo) throws WxPayException; | ||||
/** | /** | ||||
* 企业付款到银行卡查询. | * 企业付款到银行卡查询. | ||||
* <pre> | * <pre> | ||||
@@ -113,7 +114,7 @@ public interface EntPayService { | |||||
* 接口链接:https://api.mch.weixin.qq.com/mmpaysptrans/query_bank | * 接口链接:https://api.mch.weixin.qq.com/mmpaysptrans/query_bank | ||||
* </pre> | * </pre> | ||||
* | * | ||||
* @param partnerTradeNo 商户订单号 | |||||
* @param request 请求对象 | |||||
* @return the ent pay bank query result | * @return the ent pay bank query result | ||||
* @throws WxPayException the wx pay exception | * @throws WxPayException the wx pay exception | ||||
*/ | */ | ||||