更新项目常量,同时修改使用 RxJava
This commit is contained in:
parent
5d906b1fba
commit
843193024c
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,5 +1,6 @@
|
||||
package com.ossez.wechat.common.exception;
|
||||
|
||||
import com.ossez.wechat.common.enums.WeChatErrorCode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -23,7 +24,7 @@ import java.io.Serializable;
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class WxError implements Serializable {
|
||||
private static final long serialVersionUID = 7869786563361406291L;
|
||||
private static final long serialVersionUID = -2696724276555657960L;
|
||||
|
||||
/**
|
||||
* 微信错误代码.
|
||||
@ -64,7 +65,7 @@ public class WxError implements Serializable {
|
||||
|
||||
switch (type) {
|
||||
case MP: {
|
||||
final String msg = WxMpErrorMsgEnum.findMsgByCode(wxError.getErrorCode());
|
||||
final String msg = WeChatErrorCode.findMsgByCode(wxError.getErrorCode());
|
||||
if (msg != null) {
|
||||
wxError.setErrorMsg(msg);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.ossez.wechat.common.exception;
|
||||
|
||||
import static com.ossez.wechat.common.exception.WxError.*;
|
||||
|
||||
/**
|
||||
* @author Daniel Qian
|
||||
*/
|
||||
|
@ -1,688 +0,0 @@
|
||||
package com.ossez.wechat.common.exception;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 微信公众平台全局返回码.
|
||||
* 参考文档:<a href="https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Global_Return_Code.html">公众平台全局返回码</a>
|
||||
* Created by Binary Wang on 2018/5/13.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Getter
|
||||
public enum WxMpErrorMsgEnum {
|
||||
/**
|
||||
* 系统繁忙,此时请开发者稍候再试.
|
||||
*/
|
||||
CODE_1(-1, "系统繁忙,此时请开发者稍候再试"),
|
||||
/**
|
||||
* 请求成功.
|
||||
*/
|
||||
CODE_0(0, "请求成功"),
|
||||
/**
|
||||
* 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口.
|
||||
*/
|
||||
CODE_40001(40001, "获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口"),
|
||||
/**
|
||||
* 不合法的凭证类型.
|
||||
*/
|
||||
CODE_40002(40002, "不合法的凭证类型"),
|
||||
/**
|
||||
* 不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID.
|
||||
*/
|
||||
CODE_40003(40003, "不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID"),
|
||||
/**
|
||||
* 不合法的媒体文件类型.
|
||||
*/
|
||||
CODE_40004(40004, "不合法的媒体文件类型"),
|
||||
/**
|
||||
* 不合法的文件类型.
|
||||
*/
|
||||
CODE_40005(40005, "不合法的文件类型"),
|
||||
/**
|
||||
* 不合法的文件大小.
|
||||
*/
|
||||
CODE_40006(40006, "不合法的文件大小"),
|
||||
/**
|
||||
* 不合法的媒体文件 id.
|
||||
*/
|
||||
CODE_40007(40007, "不合法的媒体文件 id"),
|
||||
/**
|
||||
* 不合法的消息类型.
|
||||
*/
|
||||
CODE_40008(40008, "不合法的消息类型"),
|
||||
/**
|
||||
* 不合法的图片文件大小.
|
||||
*/
|
||||
CODE_40009(40009, "不合法的图片文件大小"),
|
||||
/**
|
||||
* 不合法的语音文件大小.
|
||||
*/
|
||||
CODE_40010(40010, "不合法的语音文件大小"),
|
||||
/**
|
||||
* 不合法的视频文件大小.
|
||||
*/
|
||||
CODE_40011(40011, "不合法的视频文件大小"),
|
||||
/**
|
||||
* 不合法的缩略图文件大小.
|
||||
*/
|
||||
CODE_40012(40012, "不合法的缩略图文件大小"),
|
||||
/**
|
||||
* 不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写.
|
||||
*/
|
||||
CODE_40013(40013, "不合法的 AppID ,请开发者检查 AppID 的正确性,避免异常字符,注意大小写"),
|
||||
/**
|
||||
* 不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口.
|
||||
*/
|
||||
CODE_40014(40014, "不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口"),
|
||||
/**
|
||||
* 不合法的菜单类型.
|
||||
*/
|
||||
CODE_40015(40015, "不合法的菜单类型"),
|
||||
/**
|
||||
* 不合法的按钮个数.
|
||||
*/
|
||||
CODE_40016(40016, "不合法的按钮个数"),
|
||||
/**
|
||||
* 不合法的按钮类型.
|
||||
*/
|
||||
CODE_40017(40017, "不合法的按钮类型"),
|
||||
/**
|
||||
* 不合法的按钮名字长度.
|
||||
*/
|
||||
CODE_40018(40018, "不合法的按钮名字长度"),
|
||||
/**
|
||||
* 不合法的按钮 KEY 长度.
|
||||
*/
|
||||
CODE_40019(40019, "不合法的按钮 KEY 长度"),
|
||||
/**
|
||||
* 不合法的按钮 URL 长度.
|
||||
*/
|
||||
CODE_40020(40020, "不合法的按钮 URL 长度"),
|
||||
/**
|
||||
* 不合法的菜单版本号.
|
||||
*/
|
||||
CODE_40021(40021, "不合法的菜单版本号"),
|
||||
/**
|
||||
* 不合法的子菜单级数.
|
||||
*/
|
||||
CODE_40022(40022, "不合法的子菜单级数"),
|
||||
/**
|
||||
* 不合法的子菜单按钮个数.
|
||||
*/
|
||||
CODE_40023(40023, "不合法的子菜单按钮个数"),
|
||||
/**
|
||||
* 不合法的子菜单按钮类型.
|
||||
*/
|
||||
CODE_40024(40024, "不合法的子菜单按钮类型"),
|
||||
/**
|
||||
* 不合法的子菜单按钮名字长度.
|
||||
*/
|
||||
CODE_40025(40025, "不合法的子菜单按钮名字长度"),
|
||||
/**
|
||||
* 不合法的子菜单按钮 KEY 长度.
|
||||
*/
|
||||
CODE_40026(40026, "不合法的子菜单按钮 KEY 长度"),
|
||||
/**
|
||||
* 不合法的子菜单按钮 URL 长度.
|
||||
*/
|
||||
CODE_40027(40027, "不合法的子菜单按钮 URL 长度"),
|
||||
/**
|
||||
* 不合法的自定义菜单使用用户.
|
||||
*/
|
||||
CODE_40028(40028, "不合法的自定义菜单使用用户"),
|
||||
/**
|
||||
* 不合法的 oauth_code.
|
||||
*/
|
||||
CODE_40029(40029, "不合法的 oauth_code"),
|
||||
/**
|
||||
* 不合法的 refresh_token.
|
||||
*/
|
||||
CODE_40030(40030, "不合法的 refresh_token"),
|
||||
/**
|
||||
* 不合法的 openid 列表.
|
||||
*/
|
||||
CODE_40031(40031, "不合法的 openid 列表"),
|
||||
/**
|
||||
* 不合法的 openid 列表长度.
|
||||
*/
|
||||
CODE_40032(40032, "不合法的 openid 列表长度"),
|
||||
/**
|
||||
* 不合法的请求字符,不能包含\\uxxxx 格式的字符.
|
||||
*/
|
||||
CODE_40033(40033, "不合法的请求字符,不能包含\\uxxxx 格式的字符"),
|
||||
/**
|
||||
* 不合法的参数.
|
||||
*/
|
||||
CODE_40035(40035, "不合法的参数"),
|
||||
/**
|
||||
* 不合法的请求格式.
|
||||
*/
|
||||
CODE_40038(40038, "不合法的请求格式"),
|
||||
/**
|
||||
* 不合法的 URL 长度.
|
||||
*/
|
||||
CODE_40039(40039, "不合法的 URL 长度"),
|
||||
/**
|
||||
* 不合法的分组 id.
|
||||
*/
|
||||
CODE_40050(40050, "不合法的分组 id"),
|
||||
/**
|
||||
* 分组名字不合法.
|
||||
*/
|
||||
CODE_40051(40051, "分组名字不合法"),
|
||||
/**
|
||||
* 删除单篇图文时,指定的 article_idx 不合法.
|
||||
*/
|
||||
CODE_40060(40060, "删除单篇图文时,指定的 article_idx 不合法"),
|
||||
/**
|
||||
* 分组名字不合法.
|
||||
*/
|
||||
CODE_40117(40117, "分组名字不合法"),
|
||||
/**
|
||||
* media_id 大小不合法.
|
||||
*/
|
||||
CODE_40118(40118, "media_id 大小不合法"),
|
||||
/**
|
||||
* button 类型错误.
|
||||
*/
|
||||
CODE_40119(40119, "button 类型错误"),
|
||||
/**
|
||||
* button 类型错误.
|
||||
*/
|
||||
CODE_40120(40120, "button 类型错误"),
|
||||
/**
|
||||
* 不合法的 media_id 类型.
|
||||
*/
|
||||
CODE_40121(40121, "不合法的 media_id 类型"),
|
||||
/**
|
||||
* 微信号不合法.
|
||||
*/
|
||||
CODE_40132(40132, "微信号不合法"),
|
||||
/**
|
||||
* 不支持的图片格式.
|
||||
*/
|
||||
CODE_40137(40137, "不支持的图片格式"),
|
||||
/**
|
||||
* 请勿添加其他公众号的主页链接.
|
||||
*/
|
||||
CODE_40155(40155, "请勿添加其他公众号的主页链接"),
|
||||
/**
|
||||
* oauth_code已使用
|
||||
*/
|
||||
CODE_40163(40163, "oauth_code已使用"),
|
||||
/**
|
||||
* 缺少 access_token 参数.
|
||||
*/
|
||||
CODE_41001(41001, "缺少 access_token 参数"),
|
||||
/**
|
||||
* 缺少 appid 参数.
|
||||
*/
|
||||
CODE_41002(41002, "缺少 appid 参数"),
|
||||
/**
|
||||
* 缺少 refresh_token 参数.
|
||||
*/
|
||||
CODE_41003(41003, "缺少 refresh_token 参数"),
|
||||
/**
|
||||
* 缺少 secret 参数.
|
||||
*/
|
||||
CODE_41004(41004, "缺少 secret 参数"),
|
||||
/**
|
||||
* 缺少多媒体文件数据.
|
||||
*/
|
||||
CODE_41005(41005, "缺少多媒体文件数据"),
|
||||
/**
|
||||
* 缺少 media_id 参数.
|
||||
*/
|
||||
CODE_41006(41006, "缺少 media_id 参数"),
|
||||
/**
|
||||
* 缺少子菜单数据.
|
||||
*/
|
||||
CODE_41007(41007, "缺少子菜单数据"),
|
||||
/**
|
||||
* 缺少 oauth code.
|
||||
*/
|
||||
CODE_41008(41008, "缺少 oauth code"),
|
||||
/**
|
||||
* 缺少 openid.
|
||||
*/
|
||||
CODE_41009(41009, "缺少 openid"),
|
||||
/**
|
||||
* access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明.
|
||||
*/
|
||||
CODE_42001(42001, "access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明"),
|
||||
/**
|
||||
* refresh_token 超时.
|
||||
*/
|
||||
CODE_42002(42002, "refresh_token 超时"),
|
||||
/**
|
||||
* oauth_code 超时.
|
||||
*/
|
||||
CODE_42003(42003, "oauth_code 超时"),
|
||||
/**
|
||||
* 用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权.
|
||||
*/
|
||||
CODE_42007(42007, "用户修改微信密码, accesstoken 和 refreshtoken 失效,需要重新授权"),
|
||||
/**
|
||||
* 需要 GET 请求.
|
||||
*/
|
||||
CODE_43001(43001, "需要 GET 请求"),
|
||||
/**
|
||||
* 需要 POST 请求.
|
||||
*/
|
||||
CODE_43002(43002, "需要 POST 请求"),
|
||||
/**
|
||||
* 需要 HTTPS 请求.
|
||||
*/
|
||||
CODE_43003(43003, "需要 HTTPS 请求"),
|
||||
/**
|
||||
* 需要接收者关注.
|
||||
*/
|
||||
CODE_43004(43004, "需要接收者关注"),
|
||||
/**
|
||||
* 需要好友关系.
|
||||
*/
|
||||
CODE_43005(43005, "需要好友关系"),
|
||||
/**
|
||||
* 需要将接收者从黑名单中移除.
|
||||
*/
|
||||
CODE_43019(43019, "需要将接收者从黑名单中移除"),
|
||||
/**
|
||||
* 多媒体文件为空.
|
||||
*/
|
||||
CODE_44001(44001, "多媒体文件为空"),
|
||||
/**
|
||||
* POST 的数据包为空.
|
||||
*/
|
||||
CODE_44002(44002, "POST 的数据包为空"),
|
||||
/**
|
||||
* 图文消息内容为空.
|
||||
*/
|
||||
CODE_44003(44003, "图文消息内容为空"),
|
||||
/**
|
||||
* 文本消息内容为空.
|
||||
*/
|
||||
CODE_44004(44004, "文本消息内容为空"),
|
||||
/**
|
||||
* 多媒体文件大小超过限制.
|
||||
*/
|
||||
CODE_45001(45001, "多媒体文件大小超过限制"),
|
||||
/**
|
||||
* 消息内容超过限制.
|
||||
*/
|
||||
CODE_45002(45002, "消息内容超过限制"),
|
||||
/**
|
||||
* 标题字段超过限制.
|
||||
*/
|
||||
CODE_45003(45003, "标题字段超过限制"),
|
||||
/**
|
||||
* 描述字段超过限制.
|
||||
*/
|
||||
CODE_45004(45004, "描述字段超过限制"),
|
||||
/**
|
||||
* 链接字段超过限制.
|
||||
*/
|
||||
CODE_45005(45005, "链接字段超过限制"),
|
||||
/**
|
||||
* 图片链接字段超过限制.
|
||||
*/
|
||||
CODE_45006(45006, "图片链接字段超过限制"),
|
||||
/**
|
||||
* 语音播放时间超过限制.
|
||||
*/
|
||||
CODE_45007(45007, "语音播放时间超过限制"),
|
||||
/**
|
||||
* 图文消息超过限制.
|
||||
*/
|
||||
CODE_45008(45008, "图文消息超过限制"),
|
||||
/**
|
||||
* 接口调用超过限制.
|
||||
*/
|
||||
CODE_45009(45009, "接口调用超过限制"),
|
||||
/**
|
||||
* 创建菜单个数超过限制.
|
||||
*/
|
||||
CODE_45010(45010, "创建菜单个数超过限制"),
|
||||
/**
|
||||
* API 调用太频繁,请稍候再试.
|
||||
*/
|
||||
CODE_45011(45011, "API 调用太频繁,请稍候再试"),
|
||||
/**
|
||||
* 回复时间超过限制.
|
||||
*/
|
||||
CODE_45015(45015, "回复时间超过限制"),
|
||||
/**
|
||||
* 系统分组,不允许修改.
|
||||
*/
|
||||
CODE_45016(45016, "系统分组,不允许修改"),
|
||||
/**
|
||||
* 分组名字过长.
|
||||
*/
|
||||
CODE_45017(45017, "分组名字过长"),
|
||||
/**
|
||||
* 分组数量超过上限.
|
||||
*/
|
||||
CODE_45018(45018, "分组数量超过上限"),
|
||||
/**
|
||||
* 客服接口下行条数超过上限.
|
||||
*/
|
||||
CODE_45047(45047, "客服接口下行条数超过上限"),
|
||||
/**
|
||||
* 非法的tag_id.
|
||||
*/
|
||||
CODE_45159(45159, "非法的tag_id"),
|
||||
/**
|
||||
* 相同 clientmsgid 已存在群发记录,返回数据中带有已存在的群发任务的 msgid
|
||||
*/
|
||||
CODE_45065(45065, "相同 clientmsgid 已存在群发记录,返回数据中带有已存在的群发任务的 msgid"),
|
||||
/**
|
||||
* 相同 clientmsgid 重试速度过快,请间隔1分钟重试
|
||||
*/
|
||||
CODE_45066(45066, "相同 clientmsgid 重试速度过快,请间隔1分钟重试"),
|
||||
/**
|
||||
* clientmsgid 长度超过限制
|
||||
*/
|
||||
CODE_45067(45067, "clientmsgid 长度超过限制"),
|
||||
/**
|
||||
* 不存在媒体数据.
|
||||
*/
|
||||
CODE_46001(46001, "不存在媒体数据"),
|
||||
/**
|
||||
* 不存在的菜单版本.
|
||||
*/
|
||||
CODE_46002(46002, "不存在的菜单版本"),
|
||||
/**
|
||||
* 不存在的菜单数据.
|
||||
*/
|
||||
CODE_46003(46003, "不存在的菜单数据"),
|
||||
/**
|
||||
* 不存在的用户.
|
||||
*/
|
||||
CODE_46004(46004, "不存在的用户"),
|
||||
/**
|
||||
* 解析 JSON/XML 内容错误.
|
||||
*/
|
||||
CODE_47001(47001, "解析 JSON/XML 内容错误"),
|
||||
/**
|
||||
* api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限.
|
||||
*/
|
||||
CODE_48001(48001, "api 功能未授权,请确认公众号已获得该接口,可以在公众平台官网 - 开发者中心页中查看接口权限"),
|
||||
/**
|
||||
* 粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” ).
|
||||
*/
|
||||
CODE_48002(48002, "粉丝拒收消息(粉丝在公众号选项中,关闭了 “ 接收消息 ” )"),
|
||||
/**
|
||||
* api 接口被封禁,请登录 mp.weixin.qq.com 查看详情.
|
||||
*/
|
||||
CODE_48004(48004, "api 接口被封禁,请登录 mp.weixin.qq.com 查看详情"),
|
||||
/**
|
||||
* api 禁止删除被自动回复和自定义菜单引用的素材.
|
||||
*/
|
||||
CODE_48005(48005, "api 禁止删除被自动回复和自定义菜单引用的素材"),
|
||||
/**
|
||||
* api 禁止清零调用次数,因为清零次数达到上限.
|
||||
*/
|
||||
CODE_48006(48006, "api 禁止清零调用次数,因为清零次数达到上限"),
|
||||
/**
|
||||
* 没有该类型消息的发送权限.
|
||||
*/
|
||||
CODE_48008(48008, "没有该类型消息的发送权限"),
|
||||
/**
|
||||
* 用户未授权该 api.
|
||||
*/
|
||||
CODE_50001(50001, "用户未授权该 api"),
|
||||
/**
|
||||
* 用户受限,可能是违规后接口被封禁.
|
||||
*/
|
||||
CODE_50002(50002, "用户受限,可能是违规后接口被封禁"),
|
||||
/**
|
||||
* 用户未关注公众号.
|
||||
*/
|
||||
CODE_50005(50005, "用户未关注公众号"),
|
||||
/**
|
||||
* 参数错误 (invalid parameter).
|
||||
*/
|
||||
CODE_61451(61451, "参数错误 (invalid parameter)"),
|
||||
/**
|
||||
* 无效客服账号 (invalid kf_account).
|
||||
*/
|
||||
CODE_61452(61452, "无效客服账号 (invalid kf_account)"),
|
||||
/**
|
||||
* 客服帐号已存在 (kf_account exsited).
|
||||
*/
|
||||
CODE_61453(61453, "客服帐号已存在 (kf_account exsited)"),
|
||||
/**
|
||||
* 客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length).
|
||||
*/
|
||||
CODE_61454(61454, "客服帐号名长度超过限制 ( 仅允许 10 个英文字符,不包括 @ 及 @ 后的公众号的微信号 )(invalid kf_acount length)"),
|
||||
/**
|
||||
* 客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account).
|
||||
*/
|
||||
CODE_61455(61455, "客服帐号名包含非法字符 ( 仅允许英文 + 数字 )(illegal character in kf_account)"),
|
||||
/**
|
||||
* 客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded).
|
||||
*/
|
||||
CODE_61456(61456, "客服帐号个数超过限制 (10 个客服账号 )(kf_account count exceeded)"),
|
||||
/**
|
||||
* 无效头像文件类型 (invalid file type).
|
||||
*/
|
||||
CODE_61457(61457, "无效头像文件类型 (invalid file type)"),
|
||||
/**
|
||||
* 系统错误 (system error).
|
||||
*/
|
||||
CODE_61450(61450, "系统错误 (system error)"),
|
||||
/**
|
||||
* 日期格式错误.
|
||||
*/
|
||||
CODE_61500(61500, "日期格式错误"),
|
||||
/**
|
||||
* 不存在此 menuid 对应的个性化菜单.
|
||||
*/
|
||||
CODE_65301(65301, "不存在此 menuid 对应的个性化菜单"),
|
||||
/**
|
||||
* 没有相应的用户.
|
||||
*/
|
||||
CODE_65302(65302, "没有相应的用户"),
|
||||
/**
|
||||
* 没有默认菜单,不能创建个性化菜单.
|
||||
*/
|
||||
CODE_65303(65303, "没有默认菜单,不能创建个性化菜单"),
|
||||
/**
|
||||
* MatchRule 信息为空.
|
||||
*/
|
||||
CODE_65304(65304, "MatchRule 信息为空"),
|
||||
/**
|
||||
* 个性化菜单数量受限.
|
||||
*/
|
||||
CODE_65305(65305, "个性化菜单数量受限"),
|
||||
/**
|
||||
* 不支持个性化菜单的帐号.
|
||||
*/
|
||||
CODE_65306(65306, "不支持个性化菜单的帐号"),
|
||||
/**
|
||||
* 个性化菜单信息为空.
|
||||
*/
|
||||
CODE_65307(65307, "个性化菜单信息为空"),
|
||||
/**
|
||||
* 包含没有响应类型的 button.
|
||||
*/
|
||||
CODE_65308(65308, "包含没有响应类型的 button"),
|
||||
/**
|
||||
* 个性化菜单开关处于关闭状态.
|
||||
*/
|
||||
CODE_65309(65309, "个性化菜单开关处于关闭状态"),
|
||||
/**
|
||||
* 填写了省份或城市信息,国家信息不能为空.
|
||||
*/
|
||||
CODE_65310(65310, "填写了省份或城市信息,国家信息不能为空"),
|
||||
/**
|
||||
* 填写了城市信息,省份信息不能为空.
|
||||
*/
|
||||
CODE_65311(65311, "填写了城市信息,省份信息不能为空"),
|
||||
/**
|
||||
* 不合法的国家信息.
|
||||
*/
|
||||
CODE_65312(65312, "不合法的国家信息"),
|
||||
/**
|
||||
* 不合法的省份信息.
|
||||
*/
|
||||
CODE_65313(65313, "不合法的省份信息"),
|
||||
/**
|
||||
* 不合法的城市信息.
|
||||
*/
|
||||
CODE_65314(65314, "不合法的城市信息"),
|
||||
/**
|
||||
* 该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接).
|
||||
*/
|
||||
CODE_65316(65316, "该公众号的菜单设置了过多的域名外跳(最多跳转到 3 个域名的链接)"),
|
||||
/**
|
||||
* 不合法的 URL.
|
||||
*/
|
||||
CODE_65317(65317, "不合法的 URL"),
|
||||
/**
|
||||
* POST 数据参数不合法.
|
||||
*/
|
||||
CODE_9001001(9001001, "POST 数据参数不合法"),
|
||||
/**
|
||||
* 远端服务不可用.
|
||||
*/
|
||||
CODE_9001002(9001002, "远端服务不可用"),
|
||||
/**
|
||||
* Ticket 不合法.
|
||||
*/
|
||||
CODE_9001003(9001003, "Ticket 不合法"),
|
||||
/**
|
||||
* 获取摇周边用户信息失败.
|
||||
*/
|
||||
CODE_9001004(9001004, "获取摇周边用户信息失败"),
|
||||
/**
|
||||
* 获取商户信息失败.
|
||||
*/
|
||||
CODE_9001005(9001005, "获取商户信息失败"),
|
||||
/**
|
||||
* 获取 OpenID 失败.
|
||||
*/
|
||||
CODE_9001006(9001006, "获取 OpenID 失败"),
|
||||
/**
|
||||
* 上传文件缺失.
|
||||
*/
|
||||
CODE_9001007(9001007, "上传文件缺失"),
|
||||
/**
|
||||
* 上传素材的文件类型不合法.
|
||||
*/
|
||||
CODE_9001008(9001008, "上传素材的文件类型不合法"),
|
||||
/**
|
||||
* 上传素材的文件尺寸不合法.
|
||||
*/
|
||||
CODE_9001009(9001009, "上传素材的文件尺寸不合法"),
|
||||
/**
|
||||
* 上传失败.
|
||||
*/
|
||||
CODE_9001010(9001010, "上传失败"),
|
||||
/**
|
||||
* 帐号不合法.
|
||||
*/
|
||||
CODE_9001020(9001020, "帐号不合法"),
|
||||
/**
|
||||
* 已有设备激活率低于 50% ,不能新增设备.
|
||||
*/
|
||||
CODE_9001021(9001021, "已有设备激活率低于 50% ,不能新增设备"),
|
||||
/**
|
||||
* 设备申请数不合法,必须为大于 0 的数字.
|
||||
*/
|
||||
CODE_9001022(9001022, "设备申请数不合法,必须为大于 0 的数字"),
|
||||
/**
|
||||
* 已存在审核中的设备 ID 申请.
|
||||
*/
|
||||
CODE_9001023(9001023, "已存在审核中的设备 ID 申请"),
|
||||
/**
|
||||
* 一次查询设备 ID 数量不能超过 50.
|
||||
*/
|
||||
CODE_9001024(9001024, "一次查询设备 ID 数量不能超过 50"),
|
||||
/**
|
||||
* 设备 ID 不合法.
|
||||
*/
|
||||
CODE_9001025(9001025, "设备 ID 不合法"),
|
||||
/**
|
||||
* 页面 ID 不合法.
|
||||
*/
|
||||
CODE_9001026(9001026, "页面 ID 不合法"),
|
||||
/**
|
||||
* 页面参数不合法.
|
||||
*/
|
||||
CODE_9001027(9001027, "页面参数不合法"),
|
||||
/**
|
||||
* 一次删除页面 ID 数量不能超过 10.
|
||||
*/
|
||||
CODE_9001028(9001028, "一次删除页面 ID 数量不能超过 10"),
|
||||
/**
|
||||
* 页面已应用在设备中,请先解除应用关系再删除.
|
||||
*/
|
||||
CODE_9001029(9001029, "页面已应用在设备中,请先解除应用关系再删除"),
|
||||
/**
|
||||
* 一次查询页面 ID 数量不能超过 50.
|
||||
*/
|
||||
CODE_9001030(9001030, "一次查询页面 ID 数量不能超过 50"),
|
||||
/**
|
||||
* 时间区间不合法.
|
||||
*/
|
||||
CODE_9001031(9001031, "时间区间不合法"),
|
||||
/**
|
||||
* 保存设备与页面的绑定关系参数错误.
|
||||
*/
|
||||
CODE_9001032(9001032, "保存设备与页面的绑定关系参数错误"),
|
||||
/**
|
||||
* 门店 ID 不合法.
|
||||
*/
|
||||
CODE_9001033(9001033, "门店 ID 不合法"),
|
||||
/**
|
||||
* 设备备注信息过长.
|
||||
*/
|
||||
CODE_9001034(9001034, "设备备注信息过长"),
|
||||
/**
|
||||
* 设备申请参数不合法.
|
||||
*/
|
||||
CODE_9001035(9001035, "设备申请参数不合法"),
|
||||
/**
|
||||
* 查询起始值 begin 不合法.
|
||||
*/
|
||||
CODE_9001036(9001036, "查询起始值 begin 不合法"),
|
||||
|
||||
/**
|
||||
* 设置的 speed 参数不在0到4的范围内
|
||||
*/
|
||||
CODE_45083(45083, "设置的 speed 参数不在0到4的范围内"),
|
||||
|
||||
/**
|
||||
* 没有设置 speed 参数
|
||||
*/
|
||||
CODE_45084(45084, "没有设置 speed 参数");
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
WxMpErrorMsgEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
static final Map<Integer, String> valueMap = Maps.newHashMap();
|
||||
|
||||
static {
|
||||
for (WxMpErrorMsgEnum value : WxMpErrorMsgEnum.values()) {
|
||||
valueMap.put(value.code, value.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过错误代码查找其中文含义..
|
||||
*/
|
||||
public static String findMsgByCode(int code) {
|
||||
return valueMap.getOrDefault(code, null);
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.ToJson;
|
||||
import com.ossez.wechat.common.model.WeChatAccessToken;
|
||||
import com.ossez.wechat.common.enums.WxType;
|
||||
@ -277,7 +277,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
return result;
|
||||
} catch (WxErrorException e) {
|
||||
WxError error = e.getError();
|
||||
if (WxConsts.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) {
|
||||
if (WeChatConstant.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) {
|
||||
// 强制设置WxMaConfig的access token过期了,这样在下一次请求里就会刷新access token
|
||||
Lock lock = this.getWxMaConfig().getAccessTokenLock();
|
||||
lock.lock();
|
||||
|
@ -7,7 +7,7 @@ import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.ossez.wechat.common.exception.WxError;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.common.exception.WxMpErrorMsgEnum;
|
||||
import com.ossez.wechat.common.enums.WeChatErrorCode;
|
||||
import com.ossez.wechat.common.util.http.RequestExecutor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mockito.Mockito;
|
||||
@ -129,14 +129,14 @@ public class WxMaServiceImplTest {
|
||||
AtomicInteger counter = new AtomicInteger();
|
||||
Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer((invocation) -> {
|
||||
counter.incrementAndGet();
|
||||
WxError error = WxError.builder().errorCode(WxMpErrorMsgEnum.CODE_40001.getCode()).errorMsg(WxMpErrorMsgEnum.CODE_40001.getMsg()).build();
|
||||
WxError error = WxError.builder().errorCode(WeChatErrorCode.CODE_40001.getCode()).errorMsg(WeChatErrorCode.CODE_40001.getMsg()).build();
|
||||
throw new WxErrorException(error);
|
||||
});
|
||||
try {
|
||||
Object execute = service.execute(re, "http://baidu.com", new HashMap<>());
|
||||
Assert.assertTrue(false, "代码应该不会执行到这里");
|
||||
} catch (WxErrorException e) {
|
||||
Assert.assertEquals(WxMpErrorMsgEnum.CODE_40001.getCode(), e.getError().getErrorCode());
|
||||
Assert.assertEquals(WeChatErrorCode.CODE_40001.getCode(), e.getError().getErrorCode());
|
||||
Assert.assertEquals(2, counter.get());
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.binarywang.wx.miniapp.bean;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.List;
|
||||
@ -38,7 +38,7 @@ public class WxMaMessageTest {
|
||||
assertEquals(wxMessage.getToUser(), "toUser");
|
||||
assertEquals(wxMessage.getFromUser(), "fromUser");
|
||||
assertEquals(wxMessage.getCreateTime(), new Integer(1482048670));
|
||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT);
|
||||
assertEquals(wxMessage.getMsgType(), WeChatConstant.XmlMsgType.TEXT);
|
||||
assertEquals(wxMessage.getContent(), "this is a test");
|
||||
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L));
|
||||
assertEquals(wxMessage.getPicUrl(), "this is a url");
|
||||
@ -108,7 +108,7 @@ public class WxMaMessageTest {
|
||||
assertEquals(wxMessage.getToUser(), "gh_123456789abc");
|
||||
assertEquals(wxMessage.getFromUser(), "otFpruAK8D-E6EfStSYonYSBZ8_4");
|
||||
assertEquals(wxMessage.getCreateTime(), new Integer(1610969440));
|
||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT);
|
||||
assertEquals(wxMessage.getMsgType(), WeChatConstant.XmlMsgType.EVENT);
|
||||
assertEquals(wxMessage.getEvent(), "subscribe_msg_popup_event");
|
||||
assertEquals(wxMessage.getSubscribeMsgPopupEvent().getList().size(), 1);
|
||||
WxMaSubscribeMsgEvent.PopupEvent event = wxMessage.getSubscribeMsgPopupEvent().getList().get(0);
|
||||
@ -170,7 +170,7 @@ public class WxMaMessageTest {
|
||||
assertEquals(wxMessage.getToUser(), "gh_123456789abc");
|
||||
assertEquals(wxMessage.getFromUser(), "o7esq5OI1Uej6Xixw1lA2H7XDVbc");
|
||||
assertEquals(wxMessage.getCreateTime(), new Integer(1610968440));
|
||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT);
|
||||
assertEquals(wxMessage.getMsgType(), WeChatConstant.XmlMsgType.EVENT);
|
||||
assertEquals(wxMessage.getEvent(), "subscribe_msg_change_event");
|
||||
assertEquals(wxMessage.getSubscribeMsgChangeEvent().getList().size(), 1);
|
||||
WxMaSubscribeMsgEvent.ChangeEvent event = wxMessage.getSubscribeMsgChangeEvent().getList().get(0);
|
||||
@ -221,7 +221,7 @@ public class WxMaMessageTest {
|
||||
assertEquals(wxMessage.getToUser(), "gh_123456789abc");
|
||||
assertEquals(wxMessage.getFromUser(), "o7esq5PHRGBQYmeNyfG064wEFVpQ");
|
||||
assertEquals(wxMessage.getCreateTime(), new Integer(1620963428));
|
||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT);
|
||||
assertEquals(wxMessage.getMsgType(), WeChatConstant.XmlMsgType.EVENT);
|
||||
assertEquals(wxMessage.getEvent(), "subscribe_msg_sent_event");
|
||||
assertNotNull(wxMessage.getSubscribeMsgSentEvent());
|
||||
WxMaSubscribeMsgEvent.SentEvent event = wxMessage.getSubscribeMsgSentEvent().getList();
|
||||
@ -315,7 +315,7 @@ public class WxMaMessageTest {
|
||||
"</xml>";
|
||||
WxMaMessage wxMessage = WxMaMessage.fromXml(xml);
|
||||
assertThat(wxMessage.getMsgType()).isEqualTo("event");
|
||||
assertThat(wxMessage.getEvent()).isEqualTo(WxConsts.EventType.OPEN_PRODUCT_ORDER_PAY);
|
||||
assertThat(wxMessage.getEvent()).isEqualTo(WeChatConstant.EventType.OPEN_PRODUCT_ORDER_PAY);
|
||||
Map<String, Object> allFieldsMap = wxMessage.getAllFieldsMap();
|
||||
Map<String, Object> orderInfo = (Map<String, Object>) allFieldsMap.get("order_info");
|
||||
assertThat(orderInfo).isNotEmpty();
|
||||
|
@ -10,7 +10,7 @@ import cn.binarywang.wx.miniapp.message.WxMaMessageHandler;
|
||||
import cn.binarywang.wx.miniapp.message.WxMaMessageRouter;
|
||||
import cn.binarywang.wx.miniapp.message.WxMaXmlOutMessage;
|
||||
import cn.binarywang.wx.miniapp.test.TestConfig;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.common.session.WxSessionManager;
|
||||
@ -98,7 +98,7 @@ public class WxMaDemoServer {
|
||||
@Override
|
||||
public WxMaXmlOutMessage handle(WxMaMessage message, Map<String, Object> context, WxMaService service, WxSessionManager sessionManager) {
|
||||
return new WxMaXmlOutMessage()
|
||||
.setMsgType(WxConsts.XmlMsgType.TRANSFER_CUSTOMER_SERVICE)
|
||||
.setMsgType(WeChatConstant.XmlMsgType.TRANSFER_CUSTOMER_SERVICE)
|
||||
.setFromUserName(message.getToUser())
|
||||
.setCreateTime(Calendar.getInstance().getTimeInMillis() / 1000)
|
||||
.setToUserName(message.getFromUser());
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.binarywang.wx.miniapp.message;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -12,7 +12,7 @@ public class WxMaXmlOutMessageTest {
|
||||
WxMaXmlOutMessage message = WxMaXmlOutMessage.builder()
|
||||
.fromUserName("1")
|
||||
.toUserName("2")
|
||||
.msgType(WxConsts.XmlMsgType.TRANSFER_CUSTOMER_SERVICE)
|
||||
.msgType(WeChatConstant.XmlMsgType.TRANSFER_CUSTOMER_SERVICE)
|
||||
.createTime(System.currentTimeMillis() / 1000)
|
||||
.build();
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.ossez.wechat.oa.api;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.oa.bean.material.WxMediaImgUploadResult;
|
||||
@ -49,7 +49,7 @@ public interface WxMpMaterialService {
|
||||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
|
||||
* </pre>
|
||||
*
|
||||
* @param mediaType 媒体类型, 请看{@link WxConsts}
|
||||
* @param mediaType 媒体类型, 请看{@link WeChatConstant}
|
||||
* @param file 文件对象
|
||||
* @return the wx media upload result
|
||||
* @throws WxErrorException the wx error exception
|
||||
@ -66,8 +66,8 @@ public interface WxMpMaterialService {
|
||||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
|
||||
* </pre>
|
||||
*
|
||||
* @param mediaType 媒体类型, 请看{@link WxConsts}
|
||||
* @param fileType 文件类型,请看{@link WxConsts}
|
||||
* @param mediaType 媒体类型, 请看{@link WeChatConstant}
|
||||
* @param fileType 文件类型,请看{@link WeChatConstant}
|
||||
* @param inputStream 输入流
|
||||
* @return the wx media upload result
|
||||
* @throws WxErrorException the wx error exception
|
||||
@ -140,7 +140,7 @@ public interface WxMpMaterialService {
|
||||
* 4、调用该接口需https协议
|
||||
* </pre>
|
||||
*
|
||||
* @param mediaType 媒体类型, 请看{@link WxConsts}
|
||||
* @param mediaType 媒体类型, 请看{@link WeChatConstant}
|
||||
* @param material 上传的素材, 请看{@link WxMpMaterial}
|
||||
* @return the wx mp material upload result
|
||||
* @throws WxErrorException the wx error exception
|
||||
@ -288,7 +288,7 @@ public interface WxMpMaterialService {
|
||||
* 接口url格式:https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN
|
||||
* </pre>
|
||||
*
|
||||
* @param type 媒体类型, 请看{@link WxConsts}
|
||||
* @param type 媒体类型, 请看{@link WeChatConstant}
|
||||
* @param offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回
|
||||
* @param count 返回素材的数量,取值在1到20之间
|
||||
* @return the wx mp material file batch get result
|
||||
|
@ -1,21 +1,21 @@
|
||||
package com.ossez.wechat.oa.api.impl;
|
||||
|
||||
import com.ossez.wechat.oa.bean.material.*;
|
||||
import com.ossez.wechat.oa.util.requestexecuter.material.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.ossez.wechat.common.enums.WxType;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.enums.WxType;
|
||||
import com.ossez.wechat.common.exception.WxError;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.common.util.fs.FileUtils;
|
||||
import com.ossez.wechat.common.util.http.BaseMediaDownloadRequestExecutor;
|
||||
import com.ossez.wechat.common.util.http.MediaUploadRequestExecutor;
|
||||
import com.ossez.wechat.common.util.json.WxGsonBuilder;
|
||||
import com.ossez.wechat.oa.api.WxMpMaterialService;
|
||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||
import com.ossez.wechat.oa.api.WxMpMaterialService;
|
||||
import com.ossez.wechat.oa.bean.material.*;
|
||||
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
||||
import com.ossez.wechat.oa.util.requestexecuter.material.*;
|
||||
import com.ossez.wechat.oa.util.requestexecuter.media.MediaImgUploadRequestExecutor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -26,147 +26,146 @@ import java.util.UUID;
|
||||
|
||||
import static com.ossez.wechat.oa.enums.WxMpApiUrl.Material.*;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Binary Wang on 2016/7/21.
|
||||
*
|
||||
* @author Binary Wang
|
||||
* @author YuCheng Hu
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class WxMpMaterialServiceImpl implements WxMpMaterialService {
|
||||
private final WeChatOfficialAccountService weChatOfficialAccountService;
|
||||
private final WeChatOfficialAccountService weChatOfficialAccountService;
|
||||
|
||||
@Override
|
||||
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException {
|
||||
File tmpFile = null;
|
||||
try {
|
||||
tmpFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType);
|
||||
return this.mediaUpload(mediaType, tmpFile);
|
||||
} catch (IOException e) {
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg(e.getMessage()).build(), e);
|
||||
} finally {
|
||||
if (tmpFile != null) {
|
||||
tmpFile.delete();
|
||||
}
|
||||
@Override
|
||||
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException {
|
||||
File tmpFile = null;
|
||||
try {
|
||||
tmpFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType);
|
||||
return this.mediaUpload(mediaType, tmpFile);
|
||||
} catch (IOException e) {
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg(e.getMessage()).build(), e);
|
||||
} finally {
|
||||
if (tmpFile != null) {
|
||||
tmpFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException {
|
||||
String url = String.format(MEDIA_UPLOAD_URL.getUrl(this.weChatOfficialAccountService.getWxMpConfigStorage()), mediaType);
|
||||
return this.weChatOfficialAccountService.execute(MediaUploadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()), url, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File mediaDownload(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(
|
||||
BaseMediaDownloadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp(), this.weChatOfficialAccountService.getWxMpConfigStorage().getTmpDirFile()),
|
||||
MEDIA_GET_URL,
|
||||
"media_id=" + mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File jssdkMediaDownload(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(
|
||||
BaseMediaDownloadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp(), this.weChatOfficialAccountService.getWxMpConfigStorage().getTmpDirFile()),
|
||||
JSSDK_MEDIA_GET_URL,
|
||||
"media_id=" + mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMediaImgUploadResult mediaImgUpload(File file) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MediaImgUploadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()), IMG_UPLOAD_URL, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException {
|
||||
String url = String.format(MATERIAL_ADD_URL.getUrl(this.weChatOfficialAccountService.getWxMpConfigStorage()), mediaType);
|
||||
return this.weChatOfficialAccountService.execute(MaterialUploadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()), url, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException {
|
||||
if (news == null || news.isEmpty()) {
|
||||
throw new IllegalArgumentException("news is empty!");
|
||||
@Override
|
||||
public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException {
|
||||
String url = String.format(MEDIA_UPLOAD_URL.getUrl(this.weChatOfficialAccountService.getWxMpConfigStorage()), mediaType);
|
||||
return this.weChatOfficialAccountService.execute(MediaUploadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()), url, file);
|
||||
}
|
||||
String responseContent = this.weChatOfficialAccountService.post(NEWS_ADD_URL, news.toJson());
|
||||
return WxMpMaterialUploadResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream materialImageOrVoiceDownload(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MaterialVoiceAndImageDownloadRequestExecutor
|
||||
.create(this.weChatOfficialAccountService.getRequestHttp(), this.weChatOfficialAccountService.getWxMpConfigStorage().getTmpDirFile()),
|
||||
MATERIAL_GET_URL, mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MaterialVideoInfoRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()),
|
||||
MATERIAL_GET_URL, mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialNews materialNewsInfo(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MaterialNewsInfoRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()),
|
||||
MATERIAL_GET_URL, mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException {
|
||||
String responseText = this.weChatOfficialAccountService.post(NEWS_UPDATE_URL, wxMpMaterialArticleUpdate.toJson());
|
||||
WxError wxError = WxError.fromJson(responseText, WxType.MP);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return true;
|
||||
} else {
|
||||
throw new WxErrorException(wxError);
|
||||
@Override
|
||||
public File mediaDownload(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(
|
||||
BaseMediaDownloadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp(), this.weChatOfficialAccountService.getWxMpConfigStorage().getTmpDirFile()),
|
||||
MEDIA_GET_URL,
|
||||
"media_id=" + mediaId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean materialDelete(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MaterialDeleteRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()),
|
||||
MATERIAL_DEL_URL, mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialCountResult materialCount() throws WxErrorException {
|
||||
String responseText = this.weChatOfficialAccountService.get(MATERIAL_GET_COUNT_URL, null);
|
||||
WxError wxError = WxError.fromJson(responseText, WxType.MP);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialCountResult.class);
|
||||
} else {
|
||||
throw new WxErrorException(wxError);
|
||||
@Override
|
||||
public File jssdkMediaDownload(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(
|
||||
BaseMediaDownloadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp(), this.weChatOfficialAccountService.getWxMpConfigStorage().getTmpDirFile()),
|
||||
JSSDK_MEDIA_GET_URL,
|
||||
"media_id=" + mediaId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("type", WxConsts.MaterialType.NEWS);
|
||||
params.put("offset", offset);
|
||||
params.put("count", count);
|
||||
String responseText = this.weChatOfficialAccountService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params));
|
||||
WxError wxError = WxError.fromJson(responseText, WxType.MP);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialNewsBatchGetResult.class);
|
||||
} else {
|
||||
throw new WxErrorException(wxError);
|
||||
@Override
|
||||
public WxMediaImgUploadResult mediaImgUpload(File file) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MediaImgUploadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()), IMG_UPLOAD_URL, file);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("type", type);
|
||||
params.put("offset", offset);
|
||||
params.put("count", count);
|
||||
String responseText = this.weChatOfficialAccountService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params));
|
||||
WxError wxError = WxError.fromJson(responseText, WxType.MP);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class);
|
||||
} else {
|
||||
throw new WxErrorException(wxError);
|
||||
@Override
|
||||
public WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException {
|
||||
String url = String.format(MATERIAL_ADD_URL.getUrl(this.weChatOfficialAccountService.getWxMpConfigStorage()), mediaType);
|
||||
return this.weChatOfficialAccountService.execute(MaterialUploadRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()), url, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException {
|
||||
if (news == null || news.isEmpty()) {
|
||||
throw new IllegalArgumentException("news is empty!");
|
||||
}
|
||||
String responseContent = this.weChatOfficialAccountService.post(NEWS_ADD_URL, news.toJson());
|
||||
return WxMpMaterialUploadResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream materialImageOrVoiceDownload(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MaterialVoiceAndImageDownloadRequestExecutor
|
||||
.create(this.weChatOfficialAccountService.getRequestHttp(), this.weChatOfficialAccountService.getWxMpConfigStorage().getTmpDirFile()),
|
||||
MATERIAL_GET_URL, mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MaterialVideoInfoRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()),
|
||||
MATERIAL_GET_URL, mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialNews materialNewsInfo(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MaterialNewsInfoRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()),
|
||||
MATERIAL_GET_URL, mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException {
|
||||
String responseText = this.weChatOfficialAccountService.post(NEWS_UPDATE_URL, wxMpMaterialArticleUpdate.toJson());
|
||||
WxError wxError = WxError.fromJson(responseText, WxType.MP);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return true;
|
||||
} else {
|
||||
throw new WxErrorException(wxError);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean materialDelete(String mediaId) throws WxErrorException {
|
||||
return this.weChatOfficialAccountService.execute(MaterialDeleteRequestExecutor.create(this.weChatOfficialAccountService.getRequestHttp()),
|
||||
MATERIAL_DEL_URL, mediaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialCountResult materialCount() throws WxErrorException {
|
||||
String responseText = this.weChatOfficialAccountService.get(MATERIAL_GET_COUNT_URL, null);
|
||||
WxError wxError = WxError.fromJson(responseText, WxType.MP);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialCountResult.class);
|
||||
} else {
|
||||
throw new WxErrorException(wxError);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("type", WeChatConstant.MaterialType.NEWS);
|
||||
params.put("offset", offset);
|
||||
params.put("count", count);
|
||||
String responseText = this.weChatOfficialAccountService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params));
|
||||
WxError wxError = WxError.fromJson(responseText, WxType.MP);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialNewsBatchGetResult.class);
|
||||
} else {
|
||||
throw new WxErrorException(wxError);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("type", type);
|
||||
params.put("offset", offset);
|
||||
params.put("count", count);
|
||||
String responseText = this.weChatOfficialAccountService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params));
|
||||
WxError wxError = WxError.fromJson(responseText, WxType.MP);
|
||||
if (wxError.getErrorCode() == 0) {
|
||||
return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class);
|
||||
} else {
|
||||
throw new WxErrorException(wxError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,10 +26,9 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* okhttp实现.
|
||||
*
|
||||
* @author someone
|
||||
* @author YuCheng Hu
|
||||
*/
|
||||
public class WeChatOfficialAccountServiceOkHttp extends BaseWeChatOfficialAccountServiceImpl<OkHttpClient, OkHttpProxyInfo> {
|
||||
|
||||
final Logger log = LoggerFactory.getLogger(WeChatOfficialAccountServiceOkHttp.class);
|
||||
|
||||
WeChatOfficialAccountApi weChatOfficialAccountApi;
|
||||
@ -63,13 +62,12 @@ public class WeChatOfficialAccountServiceOkHttp extends BaseWeChatOfficialAccoun
|
||||
|
||||
try {
|
||||
weChatAccessToken = weChatOfficialAccountApi.getAccessToken(WeChatApiParameter.ACCESS_TOKEN_GRANT_TYPE_CLIENT_CREDENTIAL, config.getAppId(), config.getSecret()).blockingGet();
|
||||
}
|
||||
catch (HttpException ex) {
|
||||
log.warn("Access WeChat API return error.",ex);
|
||||
if(ex.code() == 400) {
|
||||
} catch (HttpException ex) {
|
||||
log.warn("Access WeChat API return error.", ex);
|
||||
if (ex.code() == 400) {
|
||||
throw new WxErrorException(ex);
|
||||
}
|
||||
System.out.println(">>>>>>>>>>>>>>>>>>>> "+ex.getMessage());
|
||||
System.out.println(">>>>>>>>>>>>>>>>>>>> " + ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.ossez.wechat.oa.bean;
|
||||
|
||||
import lombok.Data;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -25,11 +25,11 @@ public class WxMpMassOpenIdsMessage implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 请使用
|
||||
* {@link WxConsts.MassMsgType#IMAGE}
|
||||
* {@link WxConsts.MassMsgType#MPNEWS}
|
||||
* {@link WxConsts.MassMsgType#TEXT}
|
||||
* {@link WxConsts.MassMsgType#MPVIDEO}
|
||||
* {@link WxConsts.MassMsgType#VOICE}
|
||||
* {@link WeChatConstant.MassMsgType#IMAGE}
|
||||
* {@link WeChatConstant.MassMsgType#MPNEWS}
|
||||
* {@link WeChatConstant.MassMsgType#TEXT}
|
||||
* {@link WeChatConstant.MassMsgType#MPVIDEO}
|
||||
* {@link WeChatConstant.MassMsgType#VOICE}
|
||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
|
||||
* </pre>
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.ossez.wechat.oa.bean;
|
||||
|
||||
import lombok.Data;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -19,11 +19,11 @@ public class WxMpMassPreviewMessage implements Serializable {
|
||||
* <pre>
|
||||
* 消息类型
|
||||
* 请使用
|
||||
* {@link WxConsts.MassMsgType#IMAGE}
|
||||
* {@link WxConsts.MassMsgType#MPNEWS}
|
||||
* {@link WxConsts.MassMsgType#TEXT}
|
||||
* {@link WxConsts.MassMsgType#MPVIDEO}
|
||||
* {@link WxConsts.MassMsgType#VOICE}
|
||||
* {@link WeChatConstant.MassMsgType#IMAGE}
|
||||
* {@link WeChatConstant.MassMsgType#MPNEWS}
|
||||
* {@link WeChatConstant.MassMsgType#TEXT}
|
||||
* {@link WeChatConstant.MassMsgType#MPVIDEO}
|
||||
* {@link WeChatConstant.MassMsgType#VOICE}
|
||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
|
||||
* </pre>
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.ossez.wechat.oa.bean;
|
||||
|
||||
import lombok.Data;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -24,11 +24,11 @@ public class WxMpMassTagMessage implements Serializable {
|
||||
* <pre>
|
||||
* 消息类型.
|
||||
* 请使用
|
||||
* {@link WxConsts.MassMsgType#IMAGE}
|
||||
* {@link WxConsts.MassMsgType#MPNEWS}
|
||||
* {@link WxConsts.MassMsgType#TEXT}
|
||||
* {@link WxConsts.MassMsgType#MPVIDEO}
|
||||
* {@link WxConsts.MassMsgType#VOICE}
|
||||
* {@link WeChatConstant.MassMsgType#IMAGE}
|
||||
* {@link WeChatConstant.MassMsgType#MPNEWS}
|
||||
* {@link WeChatConstant.MassMsgType#TEXT}
|
||||
* {@link WeChatConstant.MassMsgType#MPVIDEO}
|
||||
* {@link WeChatConstant.MassMsgType#VOICE}
|
||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
|
||||
* </pre>
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.bean.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.builder.kefu.*;
|
||||
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -124,18 +124,18 @@ public class WxMpKefuMessage implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 请使用
|
||||
* {@link WxConsts.KefuMsgType#TEXT}
|
||||
* {@link WxConsts.KefuMsgType#IMAGE}
|
||||
* {@link WxConsts.KefuMsgType#VOICE}
|
||||
* {@link WxConsts.KefuMsgType#MUSIC}
|
||||
* {@link WxConsts.KefuMsgType#VIDEO}
|
||||
* {@link WxConsts.KefuMsgType#NEWS}
|
||||
* {@link WxConsts.KefuMsgType#MPNEWS}
|
||||
* {@link WxConsts.KefuMsgType#WXCARD}
|
||||
* {@link WxConsts.KefuMsgType#MINIPROGRAMPAGE}
|
||||
* {@link WxConsts.KefuMsgType#TASKCARD}
|
||||
* {@link WxConsts.KefuMsgType#MSGMENU}
|
||||
* {@link WxConsts.KefuMsgType#MP_NEWS_ARTICLE}
|
||||
* {@link WeChatConstant.KefuMsgType#TEXT}
|
||||
* {@link WeChatConstant.KefuMsgType#IMAGE}
|
||||
* {@link WeChatConstant.KefuMsgType#VOICE}
|
||||
* {@link WeChatConstant.KefuMsgType#MUSIC}
|
||||
* {@link WeChatConstant.KefuMsgType#VIDEO}
|
||||
* {@link WeChatConstant.KefuMsgType#NEWS}
|
||||
* {@link WeChatConstant.KefuMsgType#MPNEWS}
|
||||
* {@link WeChatConstant.KefuMsgType#WXCARD}
|
||||
* {@link WeChatConstant.KefuMsgType#MINIPROGRAMPAGE}
|
||||
* {@link WeChatConstant.KefuMsgType#TASKCARD}
|
||||
* {@link WeChatConstant.KefuMsgType#MSGMENU}
|
||||
* {@link WeChatConstant.KefuMsgType#MP_NEWS_ARTICLE}
|
||||
* </pre>
|
||||
*/
|
||||
public void setMsgType(String msgType) {
|
||||
|
@ -11,7 +11,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.exception.WxRuntimeException;
|
||||
import com.ossez.wechat.common.util.XmlUtils;
|
||||
import com.ossez.wechat.common.util.xml.XStreamCDataConverter;
|
||||
@ -908,13 +908,13 @@ public class WxMpXmlMessage implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 当接受用户消息时,可能会获得以下值:
|
||||
* {@link WxConsts.XmlMsgType#TEXT}
|
||||
* {@link WxConsts.XmlMsgType#IMAGE}
|
||||
* {@link WxConsts.XmlMsgType#VOICE}
|
||||
* {@link WxConsts.XmlMsgType#VIDEO}
|
||||
* {@link WxConsts.XmlMsgType#LOCATION}
|
||||
* {@link WxConsts.XmlMsgType#LINK}
|
||||
* {@link WxConsts.XmlMsgType#EVENT}
|
||||
* {@link WeChatConstant.XmlMsgType#TEXT}
|
||||
* {@link WeChatConstant.XmlMsgType#IMAGE}
|
||||
* {@link WeChatConstant.XmlMsgType#VOICE}
|
||||
* {@link WeChatConstant.XmlMsgType#VIDEO}
|
||||
* {@link WeChatConstant.XmlMsgType#LOCATION}
|
||||
* {@link WeChatConstant.XmlMsgType#LINK}
|
||||
* {@link WeChatConstant.XmlMsgType#EVENT}
|
||||
* </pre>
|
||||
*/
|
||||
public String getMsgType() {
|
||||
@ -924,12 +924,12 @@ public class WxMpXmlMessage implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 当发送消息的时候使用:
|
||||
* {@link WxConsts.XmlMsgType#TEXT}
|
||||
* {@link WxConsts.XmlMsgType#IMAGE}
|
||||
* {@link WxConsts.XmlMsgType#VOICE}
|
||||
* {@link WxConsts.XmlMsgType#VIDEO}
|
||||
* {@link WxConsts.XmlMsgType#NEWS}
|
||||
* {@link WxConsts.XmlMsgType#MUSIC}
|
||||
* {@link WeChatConstant.XmlMsgType#TEXT}
|
||||
* {@link WeChatConstant.XmlMsgType#IMAGE}
|
||||
* {@link WeChatConstant.XmlMsgType#VOICE}
|
||||
* {@link WeChatConstant.XmlMsgType#VIDEO}
|
||||
* {@link WeChatConstant.XmlMsgType#NEWS}
|
||||
* {@link WeChatConstant.XmlMsgType#MUSIC}
|
||||
* </pre>
|
||||
*/
|
||||
public void setMsgType(String msgType) {
|
||||
|
@ -8,7 +8,7 @@ import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.util.xml.XStreamCDataConverter;
|
||||
|
||||
@Data
|
||||
@ -43,6 +43,6 @@ public class WxMpXmlOutDeviceMessage extends WxMpXmlOutMessage {
|
||||
private String sessionId;
|
||||
|
||||
public WxMpXmlOutDeviceMessage() {
|
||||
this.msgType = WxConsts.XmlMsgType.DEVICE_TEXT;
|
||||
this.msgType = WeChatConstant.XmlMsgType.DEVICE_TEXT;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.util.xml.XStreamMediaIdConverter;
|
||||
|
||||
@Data
|
||||
@ -24,7 +24,7 @@ public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage {
|
||||
private String mediaId;
|
||||
|
||||
public WxMpXmlOutImageMessage() {
|
||||
this.msgType = WxConsts.XmlMsgType.IMAGE;
|
||||
this.msgType = WeChatConstant.XmlMsgType.IMAGE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.util.xml.XStreamCDataConverter;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -24,7 +24,7 @@ public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage {
|
||||
protected final Music music = new Music();
|
||||
|
||||
public WxMpXmlOutMusicMessage() {
|
||||
this.msgType = WxConsts.XmlMsgType.MUSIC;
|
||||
this.msgType = WeChatConstant.XmlMsgType.MUSIC;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -11,7 +11,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.util.xml.XStreamCDataConverter;
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ public class WxMpXmlOutNewsMessage extends WxMpXmlOutMessage {
|
||||
protected int articleCount;
|
||||
|
||||
public WxMpXmlOutNewsMessage() {
|
||||
this.msgType = WxConsts.XmlMsgType.NEWS;
|
||||
this.msgType = WeChatConstant.XmlMsgType.NEWS;
|
||||
}
|
||||
|
||||
public void addArticle(Item item) {
|
||||
|
@ -7,7 +7,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.util.xml.XStreamCDataConverter;
|
||||
|
||||
@Data
|
||||
@ -24,7 +24,7 @@ public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage {
|
||||
private String content;
|
||||
|
||||
public WxMpXmlOutTextMessage() {
|
||||
this.msgType = WxConsts.XmlMsgType.TEXT;
|
||||
this.msgType = WeChatConstant.XmlMsgType.TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.util.xml.XStreamCDataConverter;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -24,7 +24,7 @@ public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage {
|
||||
protected TransInfo transInfo;
|
||||
|
||||
public WxMpXmlOutTransferKefuMessage() {
|
||||
this.msgType = WxConsts.KefuMsgType.TRANSFER_CUSTOMER_SERVICE;
|
||||
this.msgType = WeChatConstant.KefuMsgType.TRANSFER_CUSTOMER_SERVICE;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -7,7 +7,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.util.xml.XStreamCDataConverter;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -24,7 +24,7 @@ public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage {
|
||||
protected final Video video = new Video();
|
||||
|
||||
public WxMpXmlOutVideoMessage() {
|
||||
this.msgType = WxConsts.XmlMsgType.VIDEO;
|
||||
this.msgType = WeChatConstant.XmlMsgType.VIDEO;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -7,7 +7,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.util.xml.XStreamMediaIdConverter;
|
||||
|
||||
@Data
|
||||
@ -24,7 +24,7 @@ public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage {
|
||||
private String mediaId;
|
||||
|
||||
public WxMpXmlOutVoiceMessage() {
|
||||
this.msgType = WxConsts.XmlMsgType.VOICE;
|
||||
this.msgType = WeChatConstant.XmlMsgType.VOICE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
|
||||
private String mediaId;
|
||||
|
||||
public ImageBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.IMAGE;
|
||||
this.msgType = WeChatConstant.KefuMsgType.IMAGE;
|
||||
}
|
||||
|
||||
public ImageBuilder mediaId(String media_id) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts.KefuMsgType;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant.KefuMsgType;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
@ -16,7 +16,7 @@ public final class MpNewsArticleBuilder extends BaseBuilder<MpNewsArticleBuilder
|
||||
private String articleId;
|
||||
|
||||
public MpNewsArticleBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.MP_NEWS_ARTICLE;
|
||||
this.msgType = WeChatConstant.KefuMsgType.MP_NEWS_ARTICLE;
|
||||
}
|
||||
|
||||
public MpNewsArticleBuilder articleId(String articleId) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
@ -16,7 +16,7 @@ public final class MpNewsBuilder extends BaseBuilder<MpNewsBuilder> {
|
||||
private String mediaId;
|
||||
|
||||
public MpNewsBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.MPNEWS;
|
||||
this.msgType = WeChatConstant.KefuMsgType.MPNEWS;
|
||||
}
|
||||
|
||||
public MpNewsBuilder mediaId(String mediaId) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
@ -24,7 +24,7 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
|
||||
private String hqMusicUrl;
|
||||
|
||||
public MusicBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.MUSIC;
|
||||
this.msgType = WeChatConstant.KefuMsgType.MUSIC;
|
||||
}
|
||||
|
||||
public MusicBuilder musicUrl(String musicurl) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -20,7 +20,7 @@ public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
|
||||
private List<WxMpKefuMessage.WxArticle> articles = new ArrayList<>();
|
||||
|
||||
public NewsBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.NEWS;
|
||||
this.msgType = WeChatConstant.KefuMsgType.NEWS;
|
||||
}
|
||||
|
||||
public NewsBuilder addArticle(WxMpKefuMessage.WxArticle... articles) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> {
|
||||
private String content;
|
||||
|
||||
public TextBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.TEXT;
|
||||
this.msgType = WeChatConstant.KefuMsgType.TEXT;
|
||||
}
|
||||
|
||||
public TextBuilder content(String content) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
|
||||
private String thumbMediaId;
|
||||
|
||||
public VideoBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.VIDEO;
|
||||
this.msgType = WeChatConstant.KefuMsgType.VIDEO;
|
||||
}
|
||||
|
||||
public VideoBuilder mediaId(String mediaId) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
|
||||
private String mediaId;
|
||||
|
||||
public VoiceBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.VOICE;
|
||||
this.msgType = WeChatConstant.KefuMsgType.VOICE;
|
||||
}
|
||||
|
||||
public VoiceBuilder mediaId(String media_id) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@ public final class WxCardBuilder extends BaseBuilder<WxCardBuilder> {
|
||||
private String cardId;
|
||||
|
||||
public WxCardBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.WXCARD;
|
||||
this.msgType = WeChatConstant.KefuMsgType.WXCARD;
|
||||
}
|
||||
|
||||
public WxCardBuilder cardId(String cardId) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.builder.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -23,7 +23,7 @@ public final class WxMsgMenuBuilder extends BaseBuilder<WxMsgMenuBuilder> {
|
||||
|
||||
|
||||
public WxMsgMenuBuilder() {
|
||||
this.msgType = WxConsts.KefuMsgType.MSGMENU;
|
||||
this.msgType = WeChatConstant.KefuMsgType.MSGMENU;
|
||||
}
|
||||
|
||||
public WxMsgMenuBuilder addMenus(WxMpKefuMessage.MsgMenu... msgMenus) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.ossez.wechat.oa.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.ossez.wechat.common.api.WxConsts.KefuMsgType;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant.KefuMsgType;
|
||||
import com.ossez.wechat.common.exception.WxRuntimeException;
|
||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -2,7 +2,7 @@ package com.ossez.wechat.oa.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.WxMpMassOpenIdsMessage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -24,39 +24,39 @@ public class WxMpMassOpenIdsMessageGsonAdapter implements JsonSerializer<WxMpMas
|
||||
}
|
||||
messageJson.add("touser", toUsers);
|
||||
|
||||
if (WxConsts.MassMsgType.MPNEWS.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.MPNEWS.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MassMsgType.MPNEWS, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.MPNEWS, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.TEXT.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.TEXT.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("content", message.getContent());
|
||||
messageJson.add(WxConsts.MassMsgType.TEXT, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.TEXT, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.VOICE.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.VOICE.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MassMsgType.VOICE, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.VOICE, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.IMAGE.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.IMAGE.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
List<String> mediaIds = message.getMediaIds();
|
||||
if (mediaIds != null && !mediaIds.isEmpty() ) {
|
||||
JsonArray json = new JsonArray();
|
||||
mediaIds.forEach(json::add);
|
||||
sub.add("media_ids", json);
|
||||
messageJson.add(WxConsts.MassMsgType.IMAGES, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.IMAGES, sub);
|
||||
} else {
|
||||
String mediaId = message.getMediaId();
|
||||
sub.addProperty("media_id", mediaId);
|
||||
messageJson.add(WxConsts.MassMsgType.IMAGE, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.IMAGE, sub);
|
||||
}
|
||||
}
|
||||
if (WxConsts.MassMsgType.MPVIDEO.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.MPVIDEO.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MassMsgType.MPVIDEO, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.MPVIDEO, sub);
|
||||
}
|
||||
messageJson.addProperty("msgtype", message.getMsgType());
|
||||
|
||||
|
@ -4,7 +4,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.WxMpMassPreviewMessage;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@ -18,30 +18,30 @@ public class WxMpMassPreviewMessageGsonAdapter implements JsonSerializer<WxMpMas
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("towxname", wxMpMassPreviewMessage.getToWxUserName());
|
||||
jsonObject.addProperty("touser", wxMpMassPreviewMessage.getToWxUserOpenid());
|
||||
if (WxConsts.MassMsgType.MPNEWS.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.MPNEWS.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
JsonObject news = new JsonObject();
|
||||
news.addProperty("media_id", wxMpMassPreviewMessage.getMediaId());
|
||||
jsonObject.add(WxConsts.MassMsgType.MPNEWS, news);
|
||||
jsonObject.add(WeChatConstant.MassMsgType.MPNEWS, news);
|
||||
}
|
||||
if (WxConsts.MassMsgType.TEXT.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.TEXT.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("content", wxMpMassPreviewMessage.getContent());
|
||||
jsonObject.add(WxConsts.MassMsgType.TEXT, sub);
|
||||
jsonObject.add(WeChatConstant.MassMsgType.TEXT, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.VOICE.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.VOICE.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId());
|
||||
jsonObject.add(WxConsts.MassMsgType.VOICE, sub);
|
||||
jsonObject.add(WeChatConstant.MassMsgType.VOICE, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.IMAGE.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.IMAGE.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId());
|
||||
jsonObject.add(WxConsts.MassMsgType.IMAGE, sub);
|
||||
jsonObject.add(WeChatConstant.MassMsgType.IMAGE, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.MPVIDEO.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.MPVIDEO.equals(wxMpMassPreviewMessage.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId());
|
||||
jsonObject.add(WxConsts.MassMsgType.MPVIDEO, sub);
|
||||
jsonObject.add(WeChatConstant.MassMsgType.MPVIDEO, sub);
|
||||
}
|
||||
jsonObject.addProperty("msgtype", wxMpMassPreviewMessage.getMsgType());
|
||||
return jsonObject;
|
||||
|
@ -2,7 +2,7 @@ package com.ossez.wechat.oa.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.bean.WxMpMassTagMessage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -29,39 +29,39 @@ public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTag
|
||||
}
|
||||
messageJson.add("filter", filter);
|
||||
|
||||
if (WxConsts.MassMsgType.MPNEWS.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.MPNEWS.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MassMsgType.MPNEWS, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.MPNEWS, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.TEXT.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.TEXT.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("content", message.getContent());
|
||||
messageJson.add(WxConsts.MassMsgType.TEXT, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.TEXT, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.VOICE.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.VOICE.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MassMsgType.VOICE, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.VOICE, sub);
|
||||
}
|
||||
if (WxConsts.MassMsgType.IMAGE.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.IMAGE.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
List<String> mediaIds = message.getMediaIds();
|
||||
if (mediaIds != null && !mediaIds.isEmpty() ) {
|
||||
JsonArray json = new JsonArray();
|
||||
mediaIds.forEach(json::add);
|
||||
sub.add("media_ids", json);
|
||||
messageJson.add(WxConsts.MassMsgType.IMAGES, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.IMAGES, sub);
|
||||
} else {
|
||||
String mediaId = message.getMediaId();
|
||||
sub.addProperty("media_id", mediaId);
|
||||
messageJson.add(WxConsts.MassMsgType.IMAGE, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.IMAGE, sub);
|
||||
}
|
||||
}
|
||||
if (WxConsts.MassMsgType.MPVIDEO.equals(message.getMsgType())) {
|
||||
if (WeChatConstant.MassMsgType.MPVIDEO.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MassMsgType.MPVIDEO, sub);
|
||||
messageJson.add(WeChatConstant.MassMsgType.MPVIDEO, sub);
|
||||
}
|
||||
messageJson.addProperty("msgtype", message.getMsgType());
|
||||
messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 1 : 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.api;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.session.StandardSessionManager;
|
||||
import com.ossez.wechat.common.session.WxSessionManager;
|
||||
import com.ossez.wechat.oa.bean.message.WxMpXmlMessage;
|
||||
@ -25,21 +25,21 @@ public class WxMpMessageRouterTest {
|
||||
router
|
||||
.rule()
|
||||
.async(async)
|
||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1").content("CONTENT_1")
|
||||
.msgType(WeChatConstant.XmlMsgType.TEXT).event(WeChatConstant.EventType.CLICK).eventKey("KEY_1").content("CONTENT_1")
|
||||
.handler(new WxEchoMpMessageHandler(sb, "COMBINE_4"))
|
||||
.end()
|
||||
.rule()
|
||||
.async(async)
|
||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1")
|
||||
.msgType(WeChatConstant.XmlMsgType.TEXT).event(WeChatConstant.EventType.CLICK).eventKey("KEY_1")
|
||||
.handler(new WxEchoMpMessageHandler(sb, "COMBINE_3"))
|
||||
.end()
|
||||
.rule()
|
||||
.async(async)
|
||||
.msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK)
|
||||
.msgType(WeChatConstant.XmlMsgType.TEXT).event(WeChatConstant.EventType.CLICK)
|
||||
.handler(new WxEchoMpMessageHandler(sb, "COMBINE_2"))
|
||||
.end()
|
||||
.rule().async(async).msgType(WxConsts.XmlMsgType.TEXT).handler(new WxEchoMpMessageHandler(sb, WxConsts.XmlMsgType.TEXT)).end()
|
||||
.rule().async(async).event(WxConsts.EventType.CLICK).handler(new WxEchoMpMessageHandler(sb, WxConsts.EventType.CLICK)).end()
|
||||
.rule().async(async).msgType(WeChatConstant.XmlMsgType.TEXT).handler(new WxEchoMpMessageHandler(sb, WeChatConstant.XmlMsgType.TEXT)).end()
|
||||
.rule().async(async).event(WeChatConstant.EventType.CLICK).handler(new WxEchoMpMessageHandler(sb, WeChatConstant.EventType.CLICK)).end()
|
||||
.rule().async(async).eventKey("KEY_1").handler(new WxEchoMpMessageHandler(sb, "KEY_1")).end()
|
||||
.rule().async(async).eventKeyRegex("KEY_1*").handler(new WxEchoMpMessageHandler(sb, "KEY_123")).end()
|
||||
.rule().async(async).content("CONTENT_1").handler(new WxEchoMpMessageHandler(sb, "CONTENT_1")).end()
|
||||
@ -114,10 +114,10 @@ public class WxMpMessageRouterTest {
|
||||
@DataProvider(name = "messages-1")
|
||||
public Object[][] messages2() {
|
||||
WxMpXmlMessage message1 = new WxMpXmlMessage();
|
||||
message1.setMsgType(WxConsts.XmlMsgType.TEXT);
|
||||
message1.setMsgType(WeChatConstant.XmlMsgType.TEXT);
|
||||
|
||||
WxMpXmlMessage message2 = new WxMpXmlMessage();
|
||||
message2.setEvent(WxConsts.EventType.CLICK);
|
||||
message2.setEvent(WeChatConstant.EventType.CLICK);
|
||||
|
||||
WxMpXmlMessage message3 = new WxMpXmlMessage();
|
||||
message3.setEventKey("KEY_1");
|
||||
@ -135,23 +135,23 @@ public class WxMpMessageRouterTest {
|
||||
message7.setFormat("strangeformat");
|
||||
|
||||
WxMpXmlMessage c2 = new WxMpXmlMessage();
|
||||
c2.setMsgType(WxConsts.XmlMsgType.TEXT);
|
||||
c2.setEvent(WxConsts.EventType.CLICK);
|
||||
c2.setMsgType(WeChatConstant.XmlMsgType.TEXT);
|
||||
c2.setEvent(WeChatConstant.EventType.CLICK);
|
||||
|
||||
WxMpXmlMessage c3 = new WxMpXmlMessage();
|
||||
c3.setMsgType(WxConsts.XmlMsgType.TEXT);
|
||||
c3.setEvent(WxConsts.EventType.CLICK);
|
||||
c3.setMsgType(WeChatConstant.XmlMsgType.TEXT);
|
||||
c3.setEvent(WeChatConstant.EventType.CLICK);
|
||||
c3.setEventKey("KEY_1");
|
||||
|
||||
WxMpXmlMessage c4 = new WxMpXmlMessage();
|
||||
c4.setMsgType(WxConsts.XmlMsgType.TEXT);
|
||||
c4.setEvent(WxConsts.EventType.CLICK);
|
||||
c4.setMsgType(WeChatConstant.XmlMsgType.TEXT);
|
||||
c4.setEvent(WeChatConstant.EventType.CLICK);
|
||||
c4.setEventKey("KEY_1");
|
||||
c4.setContent("CONTENT_1");
|
||||
|
||||
return new Object[][]{
|
||||
new Object[]{message1, WxConsts.XmlMsgType.TEXT + ","},
|
||||
new Object[]{message2, WxConsts.EventType.CLICK + ","},
|
||||
new Object[]{message1, WeChatConstant.XmlMsgType.TEXT + ","},
|
||||
new Object[]{message2, WeChatConstant.EventType.CLICK + ","},
|
||||
new Object[]{message3, "KEY_1,"},
|
||||
new Object[]{message4, "CONTENT_1,"},
|
||||
new Object[]{message5, "ALL,"},
|
||||
|
@ -2,12 +2,12 @@ package com.ossez.wechat.oa.api.impl;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Inject;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.WxJsapiSignature;
|
||||
import com.ossez.wechat.common.bean.WxNetCheckResult;
|
||||
import com.ossez.wechat.common.exception.WxError;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.common.exception.WxMpErrorMsgEnum;
|
||||
import com.ossez.wechat.common.enums.WeChatErrorCode;
|
||||
import com.ossez.wechat.common.util.http.HttpType;
|
||||
import com.ossez.wechat.common.util.http.RequestExecutor;
|
||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||
@ -61,7 +61,7 @@ public class BaseWeChatOfficialAccountServiceImplTest {
|
||||
|
||||
@Test
|
||||
public void testNetCheck() throws WxErrorException {
|
||||
WxNetCheckResult result = this.wxService.netCheck(WxConsts.NetCheckArgs.ACTIONALL, WxConsts.NetCheckArgs.OPERATORDEFAULT);
|
||||
WxNetCheckResult result = this.wxService.netCheck(WeChatConstant.NetCheckArgs.ACTIONALL, WeChatConstant.NetCheckArgs.OPERATORDEFAULT);
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
}
|
||||
@ -239,14 +239,14 @@ public class BaseWeChatOfficialAccountServiceImplTest {
|
||||
AtomicInteger counter = new AtomicInteger();
|
||||
Mockito.when(re.execute(Mockito.anyString(), Mockito.any(), Mockito.any())).thenAnswer(invocation -> {
|
||||
counter.incrementAndGet();
|
||||
WxError error = WxError.builder().errorCode(WxMpErrorMsgEnum.CODE_40001.getCode()).errorMsg(WxMpErrorMsgEnum.CODE_40001.getMsg()).build();
|
||||
WxError error = WxError.builder().errorCode(WeChatErrorCode.CODE_40001.getCode()).errorMsg(WeChatErrorCode.CODE_40001.getMsg()).build();
|
||||
throw new WxErrorException(error);
|
||||
});
|
||||
try {
|
||||
Object execute = service.execute(re, "http://baidu.com", new HashMap<>());
|
||||
Assert.assertTrue(false, "代码应该不会执行到这里");
|
||||
} catch (WxErrorException e) {
|
||||
Assert.assertEquals(WxMpErrorMsgEnum.CODE_40001.getCode(), e.getError().getErrorCode());
|
||||
Assert.assertEquals(WeChatErrorCode.CODE_40001.getCode(), e.getError().getErrorCode());
|
||||
Assert.assertEquals(2, counter.get());
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.testng.*;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.oa.config.WxMpConfigStorage;
|
||||
import com.ossez.wechat.common.enums.TicketType;
|
||||
@ -37,7 +37,7 @@ public class WeChatOfficialAccountServiceImplTest {
|
||||
public void testBuildQrConnectUrl() {
|
||||
String qrconnectRedirectUrl = ((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getQrconnectRedirectUrl();
|
||||
String qrConnectUrl = this.wxService.buildQrConnectUrl(qrconnectRedirectUrl,
|
||||
WxConsts.QrConnectScope.SNSAPI_LOGIN, null);
|
||||
WeChatConstant.QrConnectScope.SNSAPI_LOGIN, null);
|
||||
Assert.assertNotNull(qrConnectUrl);
|
||||
System.out.println(qrConnectUrl);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.ossez.wechat.oa.api.impl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||
@ -37,7 +37,7 @@ public class WxMpGuideMaterialServiceImplTest {
|
||||
@Test
|
||||
public void testSetGuideCardMaterial() throws WxErrorException {
|
||||
WxMediaUploadResult wxMediaUploadResult = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MediaFileType.IMAGE, new File(IMG_URL));
|
||||
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, new File(IMG_URL));
|
||||
this.wxService.getGuideMaterialService().setGuideCardMaterial(wxMediaUploadResult.getMediaId(), 0, "小程序素材标题", "pages/login-type/index.html", "wx4f793c04fd3be5a8");
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class WxMpGuideMaterialServiceImplTest {
|
||||
@Test
|
||||
public void testSetGuideImageMaterial() throws WxErrorException {
|
||||
WxMediaUploadResult wxMediaUploadResult = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MediaFileType.IMAGE, new File(IMG_URL));
|
||||
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, new File(IMG_URL));
|
||||
this.wxService.getGuideMaterialService().setGuideImageMaterial(wxMediaUploadResult.getMediaId(), 0);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import org.assertj.core.api.Assertions;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfInfo;
|
||||
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfList;
|
||||
@ -41,7 +41,7 @@ public class WxMpKefuServiceImplTest {
|
||||
public void testSendKefuMpNewsMessage() throws WxErrorException {
|
||||
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||
WxMpKefuMessage message = new WxMpKefuMessage();
|
||||
message.setMsgType(WxConsts.KefuMsgType.MPNEWS);
|
||||
message.setMsgType(WeChatConstant.KefuMsgType.MPNEWS);
|
||||
message.setToUser(configStorage.getOpenid());
|
||||
message.setMpNewsMediaId("52R6dL2FxDpM9N1rCY3sYBqHwq-L7K_lz1sPI71idMg");
|
||||
|
||||
@ -52,7 +52,7 @@ public class WxMpKefuServiceImplTest {
|
||||
public void testSendKefuMessage() throws WxErrorException {
|
||||
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||
WxMpKefuMessage message = new WxMpKefuMessage();
|
||||
message.setMsgType(WxConsts.KefuMsgType.TEXT);
|
||||
message.setMsgType(WeChatConstant.KefuMsgType.TEXT);
|
||||
message.setToUser(configStorage.getOpenid());
|
||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
|
||||
@ -63,7 +63,7 @@ public class WxMpKefuServiceImplTest {
|
||||
public void testSendKefuMessageWithKfAccount() throws WxErrorException {
|
||||
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||
WxMpKefuMessage message = new WxMpKefuMessage();
|
||||
message.setMsgType(WxConsts.KefuMsgType.TEXT);
|
||||
message.setMsgType(WeChatConstant.KefuMsgType.TEXT);
|
||||
message.setToUser(configStorage.getOpenid());
|
||||
message.setKfAccount(configStorage.getKfAccount());
|
||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
|
@ -2,7 +2,7 @@ package com.ossez.wechat.oa.api.impl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||
@ -44,7 +44,7 @@ public class WxMpMassMessageServiceImplTest {
|
||||
// 发送群发消息
|
||||
TestConfigStorage configProvider = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||
WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
|
||||
massMessage.setMsgType(WxConsts.MassMsgType.TEXT);
|
||||
massMessage.setMsgType(WeChatConstant.MassMsgType.TEXT);
|
||||
massMessage.setContent("测试群发消息\n欢迎欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
massMessage.getToUsers().add(configProvider.getOpenid());
|
||||
|
||||
@ -74,7 +74,7 @@ public class WxMpMassMessageServiceImplTest {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
try (InputStream inputStream = ClassLoader
|
||||
.getSystemResourceAsStream(i + ".jpeg")) {
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService().mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream);
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService().mediaUpload(WeChatConstant.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
massMsg.add(uploadMediaRes.getMediaId());
|
||||
@ -83,7 +83,7 @@ public class WxMpMassMessageServiceImplTest {
|
||||
}
|
||||
}
|
||||
WxMpMassTagMessage massMessage = new WxMpMassTagMessage();
|
||||
massMessage.setMsgType(WxConsts.MassMsgType.IMAGE);
|
||||
massMessage.setMsgType(WeChatConstant.MassMsgType.IMAGE);
|
||||
massMessage.setMediaIds(new ArrayList<>(massMsg));
|
||||
massMessage.setSendAll(true);
|
||||
WxMpMassSendResult massResult = this.wxService.getMassMessageService().massGroupMessageSend(massMessage);
|
||||
@ -94,7 +94,7 @@ public class WxMpMassMessageServiceImplTest {
|
||||
@Test
|
||||
public void testTextMassGroupMessageSend() throws WxErrorException {
|
||||
WxMpMassTagMessage massMessage = new WxMpMassTagMessage();
|
||||
massMessage.setMsgType(WxConsts.MassMsgType.TEXT);
|
||||
massMessage.setMsgType(WeChatConstant.MassMsgType.TEXT);
|
||||
massMessage.setContent("测试群发消息\n欢迎欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
massMessage
|
||||
.setTagId(this.wxService.getUserTagService().tagGet().get(0).getId());
|
||||
@ -127,7 +127,7 @@ public class WxMpMassMessageServiceImplTest {
|
||||
.getSystemResourceAsStream("mm.mp4")) {
|
||||
// 上传视频到媒体库
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, inputStream);
|
||||
.mediaUpload(WeChatConstant.MediaFileType.VIDEO, TestConstants.FILE_MP4, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
|
||||
@ -139,7 +139,7 @@ public class WxMpMassMessageServiceImplTest {
|
||||
WxMpMassUploadResult uploadResult = this.wxService.getMassMessageService().massVideoUpload(video);
|
||||
Assert.assertNotNull(uploadResult);
|
||||
Assert.assertNotNull(uploadResult.getMediaId());
|
||||
messages[0] = new Object[]{WxConsts.MassMsgType.MPVIDEO, uploadResult.getMediaId()};
|
||||
messages[0] = new Object[]{WeChatConstant.MassMsgType.MPVIDEO, uploadResult.getMediaId()};
|
||||
}
|
||||
|
||||
/*
|
||||
@ -148,10 +148,10 @@ public class WxMpMassMessageServiceImplTest {
|
||||
try (InputStream inputStream = ClassLoader
|
||||
.getSystemResourceAsStream("mm.jpeg")) {
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream);
|
||||
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
messages[1] = new Object[]{WxConsts.MassMsgType.IMAGE, uploadMediaRes.getMediaId()
|
||||
messages[1] = new Object[]{WeChatConstant.MassMsgType.IMAGE, uploadMediaRes.getMediaId()
|
||||
};
|
||||
}
|
||||
|
||||
@ -161,10 +161,10 @@ public class WxMpMassMessageServiceImplTest {
|
||||
try (InputStream inputStream = ClassLoader
|
||||
.getSystemResourceAsStream("mm.mp3")) {
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, inputStream);
|
||||
.mediaUpload(WeChatConstant.MediaFileType.VOICE, TestConstants.FILE_MP3, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
messages[2] = new Object[]{WxConsts.MassMsgType.VOICE, uploadMediaRes.getMediaId()};
|
||||
messages[2] = new Object[]{WeChatConstant.MassMsgType.VOICE, uploadMediaRes.getMediaId()};
|
||||
}
|
||||
|
||||
/*
|
||||
@ -174,7 +174,7 @@ public class WxMpMassMessageServiceImplTest {
|
||||
.getSystemResourceAsStream("mm.jpeg")) {
|
||||
// 上传照片到媒体库
|
||||
WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream);
|
||||
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
|
||||
@ -200,7 +200,7 @@ public class WxMpMassMessageServiceImplTest {
|
||||
.massNewsUpload(news);
|
||||
Assert.assertNotNull(massUploadResult);
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
messages[3] = new Object[]{WxConsts.MassMsgType.MPNEWS, massUploadResult.getMediaId()};
|
||||
messages[3] = new Object[]{WeChatConstant.MassMsgType.MPNEWS, massUploadResult.getMediaId()};
|
||||
}
|
||||
|
||||
return messages;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.ossez.wechat.oa.api.impl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.common.util.fs.FileUtils;
|
||||
@ -51,10 +51,10 @@ public class WxMpMaterialServiceImplTest {
|
||||
@DataProvider
|
||||
public Object[][] mediaFiles() {
|
||||
return new Object[][]{
|
||||
new Object[]{WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, "mm.jpeg"},
|
||||
new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, "mm.mp3"},
|
||||
new Object[]{WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, "mm.mp4"},
|
||||
new Object[]{WxConsts.MediaFileType.THUMB, TestConstants.FILE_JPG, "mm.jpeg"}
|
||||
new Object[]{WeChatConstant.MediaFileType.IMAGE, TestConstants.FILE_JPG, "mm.jpeg"},
|
||||
new Object[]{WeChatConstant.MediaFileType.VOICE, TestConstants.FILE_MP3, "mm.mp3"},
|
||||
new Object[]{WeChatConstant.MediaFileType.VIDEO, TestConstants.FILE_MP4, "mm.mp4"},
|
||||
new Object[]{WeChatConstant.MediaFileType.THUMB, TestConstants.FILE_JPG, "mm.jpeg"}
|
||||
};
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class WxMpMaterialServiceImplTest {
|
||||
WxMpMaterial wxMaterial = new WxMpMaterial();
|
||||
wxMaterial.setFile(tempFile);
|
||||
wxMaterial.setName(fileName);
|
||||
if (WxConsts.MediaFileType.VIDEO.equals(mediaType)) {
|
||||
if (WeChatConstant.MediaFileType.VIDEO.equals(mediaType)) {
|
||||
wxMaterial.setVideoTitle("title");
|
||||
wxMaterial.setVideoIntroduction("test video description");
|
||||
}
|
||||
@ -81,12 +81,12 @@ public class WxMpMaterialServiceImplTest {
|
||||
.materialFileUpload(mediaType, wxMaterial);
|
||||
Assert.assertNotNull(res.getMediaId());
|
||||
|
||||
if (WxConsts.MediaFileType.IMAGE.equals(mediaType)
|
||||
|| WxConsts.MediaFileType.THUMB.equals(mediaType)) {
|
||||
if (WeChatConstant.MediaFileType.IMAGE.equals(mediaType)
|
||||
|| WeChatConstant.MediaFileType.THUMB.equals(mediaType)) {
|
||||
Assert.assertNotNull(res.getUrl());
|
||||
}
|
||||
|
||||
if (WxConsts.MediaFileType.THUMB.equals(mediaType)) {
|
||||
if (WeChatConstant.MediaFileType.THUMB.equals(mediaType)) {
|
||||
this.thumbMediaId = res.getMediaId();
|
||||
}
|
||||
|
||||
@ -236,9 +236,9 @@ public class WxMpMaterialServiceImplTest {
|
||||
|
||||
@Test//(dependsOnMethods = {"testMaterialNewsList"})
|
||||
public void testMaterialFileList() throws WxErrorException {
|
||||
WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VOICE, 0, 20);
|
||||
WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VIDEO, 0, 20);
|
||||
WxMpMaterialFileBatchGetResult wxMpMaterialImageBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.IMAGE, 0, 20);
|
||||
WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WeChatConstant.MaterialType.VOICE, 0, 20);
|
||||
WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WeChatConstant.MaterialType.VIDEO, 0, 20);
|
||||
WxMpMaterialFileBatchGetResult wxMpMaterialImageBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WeChatConstant.MaterialType.IMAGE, 0, 20);
|
||||
Assert.assertNotNull(wxMpMaterialVoiceBatchGetResult);
|
||||
Assert.assertNotNull(wxMpMaterialVideoBatchGetResult);
|
||||
Assert.assertNotNull(wxMpMaterialImageBatchGetResult);
|
||||
@ -289,12 +289,12 @@ public class WxMpMaterialServiceImplTest {
|
||||
Assert.assertNotNull(res.getCreatedAt());
|
||||
Assert.assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null);
|
||||
|
||||
if (res.getMediaId() != null && !mediaType.equals(WxConsts.MediaFileType.VIDEO)) {
|
||||
if (res.getMediaId() != null && !mediaType.equals(WeChatConstant.MediaFileType.VIDEO)) {
|
||||
//video 不支持下载,所以不加入
|
||||
this.mediaIdsToDownload.add(res.getMediaId());
|
||||
|
||||
// 音频media, 用于测试下载高清语音接口
|
||||
if (mediaType.equals(WxConsts.MediaFileType.VOICE)) {
|
||||
if (mediaType.equals(WeChatConstant.MediaFileType.VOICE)) {
|
||||
this.voiceMediaIdsToDownload.add(res.getMediaId());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.ossez.wechat.oa.api.impl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||
import com.ossez.wechat.common.bean.menu.WxMenuButton;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
@ -201,7 +201,7 @@ public class WxMpMenuServiceImplTest {
|
||||
public Object[][] getMenu() {
|
||||
WxMenu menu = new WxMenu();
|
||||
WxMenuButton button1 = new WxMenuButton();
|
||||
button1.setType(WxConsts.MenuButtonType.CLICK);
|
||||
button1.setType(WeChatConstant.MenuButtonType.CLICK);
|
||||
button1.setName("今日歌曲");
|
||||
button1.setKey("V1001_TODAY_MUSIC");
|
||||
|
||||
@ -220,17 +220,17 @@ public class WxMpMenuServiceImplTest {
|
||||
menu.getButtons().add(button3);
|
||||
|
||||
WxMenuButton button31 = new WxMenuButton();
|
||||
button31.setType(WxConsts.MenuButtonType.VIEW);
|
||||
button31.setType(WeChatConstant.MenuButtonType.VIEW);
|
||||
button31.setName("搜索");
|
||||
button31.setUrl("http://www.soso.com/");
|
||||
|
||||
WxMenuButton button32 = new WxMenuButton();
|
||||
button32.setType(WxConsts.MenuButtonType.VIEW);
|
||||
button32.setType(WeChatConstant.MenuButtonType.VIEW);
|
||||
button32.setName("视频");
|
||||
button32.setUrl("http://v.qq.com/");
|
||||
|
||||
WxMenuButton button33 = new WxMenuButton();
|
||||
button33.setType(WxConsts.MenuButtonType.CLICK);
|
||||
button33.setType(WeChatConstant.MenuButtonType.CLICK);
|
||||
button33.setName("赞一下我们");
|
||||
button33.setKey("V1001_GOOD");
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.bean.kefu;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -10,7 +10,7 @@ public class WxMpKefuMessageTest {
|
||||
public void testTextReply() {
|
||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.KefuMsgType.TEXT);
|
||||
reply.setMsgType(WeChatConstant.KefuMsgType.TEXT);
|
||||
reply.setContent("sfsfdsdf");
|
||||
Assert
|
||||
.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
|
||||
@ -25,7 +25,7 @@ public class WxMpKefuMessageTest {
|
||||
public void testImageReply() {
|
||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.KefuMsgType.IMAGE);
|
||||
reply.setMsgType(WeChatConstant.KefuMsgType.IMAGE);
|
||||
reply.setMediaId("MEDIA_ID");
|
||||
Assert.assertEquals(reply.toJson(),
|
||||
"{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
|
||||
@ -40,7 +40,7 @@ public class WxMpKefuMessageTest {
|
||||
public void testVoiceReply() {
|
||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.KefuMsgType.VOICE);
|
||||
reply.setMsgType(WeChatConstant.KefuMsgType.VOICE);
|
||||
reply.setMediaId("MEDIA_ID");
|
||||
Assert.assertEquals(reply.toJson(),
|
||||
"{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}");
|
||||
@ -55,7 +55,7 @@ public class WxMpKefuMessageTest {
|
||||
public void testVideoReply() {
|
||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.KefuMsgType.VIDEO);
|
||||
reply.setMsgType(WeChatConstant.KefuMsgType.VIDEO);
|
||||
reply.setMediaId("MEDIA_ID");
|
||||
reply.setThumbMediaId("MEDIA_ID");
|
||||
reply.setTitle("TITLE");
|
||||
@ -74,7 +74,7 @@ public class WxMpKefuMessageTest {
|
||||
public void testMusicReply() {
|
||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.KefuMsgType.MUSIC);
|
||||
reply.setMsgType(WeChatConstant.KefuMsgType.MUSIC);
|
||||
reply.setThumbMediaId("MEDIA_ID");
|
||||
reply.setDescription("DESCRIPTION");
|
||||
reply.setTitle("TITLE");
|
||||
@ -100,7 +100,7 @@ public class WxMpKefuMessageTest {
|
||||
public void testNewsReply() {
|
||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.KefuMsgType.NEWS);
|
||||
reply.setMsgType(WeChatConstant.KefuMsgType.NEWS);
|
||||
|
||||
WxMpKefuMessage.WxArticle article1 = new WxMpKefuMessage.WxArticle();
|
||||
article1.setUrl("URL");
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.bean.message;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -73,7 +73,7 @@ public class WxMpXmlMessageTest {
|
||||
assertEquals(wxMessage.getToUser(), "toUser");
|
||||
assertEquals(wxMessage.getFromUser(), "fromUser");
|
||||
assertEquals(wxMessage.getCreateTime(), new Long(1348831860L));
|
||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT);
|
||||
assertEquals(wxMessage.getMsgType(), WeChatConstant.XmlMsgType.TEXT);
|
||||
assertEquals(wxMessage.getContent(), "this is a test");
|
||||
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L));
|
||||
assertEquals(wxMessage.getPicUrl(), "this is a url");
|
||||
@ -164,7 +164,7 @@ public class WxMpXmlMessageTest {
|
||||
assertEquals(wxMessage.getToUser(), "toUser");
|
||||
assertEquals(wxMessage.getFromUser(), "fromUser");
|
||||
assertEquals(wxMessage.getCreateTime(), new Long(1348831860L));
|
||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT);
|
||||
assertEquals(wxMessage.getMsgType(), WeChatConstant.XmlMsgType.TEXT);
|
||||
assertEquals(wxMessage.getContent(), "this is a test");
|
||||
assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L));
|
||||
assertEquals(wxMessage.getPicUrl(), "this is a url");
|
||||
@ -240,7 +240,7 @@ public class WxMpXmlMessageTest {
|
||||
assertEquals(wxMessage.getToUser(), "gh_4d00ed8d6399");
|
||||
assertEquals(wxMessage.getFromUser(), "oV5CrjpxgaGXNHIQigzNlgLTnwic");
|
||||
assertEquals(wxMessage.getCreateTime(), new Long(1481013459));
|
||||
assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT);
|
||||
assertEquals(wxMessage.getMsgType(), WeChatConstant.XmlMsgType.EVENT);
|
||||
assertEquals(wxMessage.getEvent(), "MASSSENDJOBFINISH");
|
||||
assertEquals(wxMessage.getMsgId(), new Long(1000001625L));
|
||||
assertEquals(wxMessage.getStatus(), "err(30003)");
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.demo;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
||||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
import com.ossez.wechat.common.session.WxSessionManager;
|
||||
@ -19,7 +19,7 @@ public class DemoImageHandler implements WxMpMessageHandler {
|
||||
WeChatOfficialAccountService weChatOfficialAccountService, WxSessionManager sessionManager) {
|
||||
try {
|
||||
WxMediaUploadResult wxMediaUploadResult = weChatOfficialAccountService.getMaterialService()
|
||||
.mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg"));
|
||||
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, TestConstants.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg"));
|
||||
WxMpXmlOutImageMessage m
|
||||
= WxMpXmlOutMessage
|
||||
.IMAGE()
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.demo;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.session.WxSessionManager;
|
||||
import com.ossez.wechat.oa.api.WxMpMessageHandler;
|
||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||
@ -19,7 +19,7 @@ public class DemoOAuth2Handler implements WxMpMessageHandler {
|
||||
WxSessionManager sessionManager) {
|
||||
String href = "<a href=\"" + weChatOfficialAccountService.getOAuth2Service().buildAuthorizationUrl(
|
||||
weChatOfficialAccountService.getWxMpConfigStorage().getOauth2redirectUri(),
|
||||
WxConsts.OAuth2Scope.SNSAPI_USERINFO, null) + "\">测试oauth2</a>";
|
||||
WeChatConstant.OAuth2Scope.SNSAPI_USERINFO, null) + "\">测试oauth2</a>";
|
||||
return WxMpXmlOutMessage.TEXT().content(href)
|
||||
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
|
||||
.build();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ossez.wechat.oa.demo;
|
||||
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.oa.api.WxMpMessageHandler;
|
||||
import com.ossez.wechat.oa.api.WxMpMessageRouter;
|
||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||
@ -54,7 +54,7 @@ public class WxMpDemoServer {
|
||||
|
||||
wxMpMessageRouter = new WxMpMessageRouter(weChatOfficialAccountService);
|
||||
wxMpMessageRouter.rule().handler(logHandler).next().rule()
|
||||
.msgType(WxConsts.XmlMsgType.TEXT).matcher(guessNumberHandler)
|
||||
.msgType(WeChatConstant.XmlMsgType.TEXT).matcher(guessNumberHandler)
|
||||
.handler(guessNumberHandler).end().rule().async(false).content("哈哈")
|
||||
.handler(textHandler).end().rule().async(false).content("图片")
|
||||
.handler(imageHandler).end().rule().async(false).content("oauth")
|
||||
|
@ -5,7 +5,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.ossez.wechat.common.api.WxConsts;
|
||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||
import com.ossez.wechat.common.bean.oauth2.WxOAuth2AccessToken;
|
||||
import com.ossez.wechat.common.bean.result.WxMinishopImageUploadResult;
|
||||
import com.ossez.wechat.common.exception.WxError;
|
||||
@ -204,7 +204,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
return getWxOpenService().post(uriWithComponentAccessToken, postData);
|
||||
} catch (WxErrorException e) {
|
||||
WxError error = e.getError();
|
||||
if (WxConsts.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) {
|
||||
if (WeChatConstant.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) {
|
||||
// 强制设置access token过期,这样在下一次请求里就会刷新access token
|
||||
Lock lock = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
|
||||
lock.lock();
|
||||
@ -243,7 +243,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
return getWxOpenService().get(uriWithComponentAccessToken, null);
|
||||
} catch (WxErrorException e) {
|
||||
WxError error = e.getError();
|
||||
if (WxConsts.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) {
|
||||
if (WeChatConstant.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) {
|
||||
// 强制设置wxMpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token
|
||||
Lock lock = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
|
||||
lock.lock();
|
||||
@ -551,11 +551,11 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
private String openAccountServicePost(String appId, String appIdType, String requestUrl, JsonObject param) throws WxErrorException {
|
||||
String result = "";
|
||||
switch (appIdType) {
|
||||
case WxConsts.AppIdType.MP_TYPE:
|
||||
case WeChatConstant.AppIdType.MP_TYPE:
|
||||
WeChatOfficialAccountService weChatOfficialAccountService = this.getWxMpServiceByAppid(appId);
|
||||
result = weChatOfficialAccountService.post(requestUrl, param.toString());
|
||||
return result;
|
||||
case WxConsts.AppIdType.MINI_TYPE:
|
||||
case WeChatConstant.AppIdType.MINI_TYPE:
|
||||
WxOpenMaService maService = this.getWxMaServiceByAppid(appId);
|
||||
result = maService.post(requestUrl, param.toString());
|
||||
return result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user