mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	规范化并优化代码
This commit is contained in:
		| @ -15,6 +15,9 @@ import java.util.List; | |||||||
|  * @author <a href="https://github.com/huansinho">huansinho</a> |  * @author <a href="https://github.com/huansinho">huansinho</a> | ||||||
|  */ |  */ | ||||||
| public interface WxCpAgentService { | public interface WxCpAgentService { | ||||||
|  |   String GET_AGENT = "https://qyapi.weixin.qq.com/cgi-bin/agent/get?agentid=%d"; | ||||||
|  |   String AGENT_SET = "https://qyapi.weixin.qq.com/cgi-bin/agent/set"; | ||||||
|  |   String AGENT_LIST = "https://qyapi.weixin.qq.com/cgi-bin/agent/list"; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| package me.chanjar.weixin.cp.api; | package me.chanjar.weixin.cp.api; | ||||||
|  |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpAppChatMessage; | import me.chanjar.weixin.cp.bean.WxCpAppChatMessage; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpChat; | import me.chanjar.weixin.cp.bean.WxCpChat; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 群聊服务. |  * 群聊服务. | ||||||
|  * |  * | ||||||
| @ -15,6 +15,10 @@ public interface WxCpChatService { | |||||||
|   String APPCHAT_CREATE = "https://qyapi.weixin.qq.com/cgi-bin/appchat/create"; |   String APPCHAT_CREATE = "https://qyapi.weixin.qq.com/cgi-bin/appchat/create"; | ||||||
|   String APPCHAT_UPDATE = "https://qyapi.weixin.qq.com/cgi-bin/appchat/update"; |   String APPCHAT_UPDATE = "https://qyapi.weixin.qq.com/cgi-bin/appchat/update"; | ||||||
|   String APPCHAT_GET_CHATID = "https://qyapi.weixin.qq.com/cgi-bin/appchat/get?chatid="; |   String APPCHAT_GET_CHATID = "https://qyapi.weixin.qq.com/cgi-bin/appchat/get?chatid="; | ||||||
|  |   String APPCHAT_SEND = "https://qyapi.weixin.qq.com/cgi-bin/appchat/send"; | ||||||
|  |  | ||||||
|  |   @Deprecated | ||||||
|  |   String chatCreate(String name, String owner, List<String> users, String chatId) throws WxErrorException; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 创建群聊会话,注意:刚创建的群,如果没有下发消息,在企业微信不会出现该群. |    * 创建群聊会话,注意:刚创建的群,如果没有下发消息,在企业微信不会出现该群. | ||||||
| @ -24,15 +28,13 @@ public interface WxCpChatService { | |||||||
|    * @param users  群成员id列表。至少2人,至多500人 |    * @param users  群成员id列表。至少2人,至多500人 | ||||||
|    * @param chatId 群聊的唯一标志,不能与已有的群重复;字符串类型,最长32个字符。只允许字符0-9及字母a-zA-Z。如果不填,系统会随机生成群id |    * @param chatId 群聊的唯一标志,不能与已有的群重复;字符串类型,最长32个字符。只允许字符0-9及字母a-zA-Z。如果不填,系统会随机生成群id | ||||||
|    * @return 创建的群聊会话chatId |    * @return 创建的群聊会话chatId | ||||||
|    * @throws WxErrorException 发生异常 |    * @throws WxErrorException 异常 | ||||||
|    */ |  | ||||||
|   String chatCreate(String name, String owner, List<String> users, String chatId) throws WxErrorException; |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * chatCreate 同名方法 |  | ||||||
|    */ |    */ | ||||||
|   String create(String name, String owner, List<String> users, String chatId) throws WxErrorException; |   String create(String name, String owner, List<String> users, String chatId) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   @Deprecated | ||||||
|  |   void chatUpdate(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 修改群聊会话. |    * 修改群聊会话. | ||||||
|    * |    * | ||||||
| @ -41,26 +43,19 @@ public interface WxCpChatService { | |||||||
|    * @param owner         新群主的id。若不需更新,请忽略此参数(null or empty) |    * @param owner         新群主的id。若不需更新,请忽略此参数(null or empty) | ||||||
|    * @param usersToAdd    添加成员的id列表,若不需要更新,则传递空对象或者空集合 |    * @param usersToAdd    添加成员的id列表,若不需要更新,则传递空对象或者空集合 | ||||||
|    * @param usersToDelete 踢出成员的id列表,若不需要更新,则传递空对象或者空集合 |    * @param usersToDelete 踢出成员的id列表,若不需要更新,则传递空对象或者空集合 | ||||||
|    * @throws WxErrorException 发生异常 |    * @throws WxErrorException 异常 | ||||||
|    */ |  | ||||||
|   void chatUpdate(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException; |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * chatUpdate 同名方法 |  | ||||||
|    */ |    */ | ||||||
|   void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException; |   void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   @Deprecated | ||||||
|  |   WxCpChat chatGet(String chatId) throws WxErrorException; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 获取群聊会话. |    * 获取群聊会话. | ||||||
|    * |    * | ||||||
|    * @param chatId 群聊编号 |    * @param chatId 群聊编号 | ||||||
|    * @return 群聊会话 |    * @return 群聊会话 | ||||||
|    * @throws WxErrorException 发生异常 |    * @throws WxErrorException 异常 | ||||||
|    */ |  | ||||||
|   WxCpChat chatGet(String chatId) throws WxErrorException; |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * chatGet 同名方法 |  | ||||||
|    */ |    */ | ||||||
|   WxCpChat get(String chatId) throws WxErrorException; |   WxCpChat get(String chatId) throws WxErrorException; | ||||||
|  |  | ||||||
| @ -71,6 +66,7 @@ public interface WxCpChatService { | |||||||
|    * 文档地址:https://work.weixin.qq.com/api/doc#90000/90135/90248 |    * 文档地址:https://work.weixin.qq.com/api/doc#90000/90135/90248 | ||||||
|    * |    * | ||||||
|    * @param message 要发送的消息内容对象 |    * @param message 要发送的消息内容对象 | ||||||
|  |    * @throws WxErrorException 异常 | ||||||
|    */ |    */ | ||||||
|   void sendMsg(WxCpAppChatMessage message) throws WxErrorException; |   void sendMsg(WxCpAppChatMessage message) throws WxErrorException; | ||||||
|  |  | ||||||
|  | |||||||
| @ -14,6 +14,10 @@ import me.chanjar.weixin.cp.bean.WxCpDepart; | |||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| public interface WxCpDepartmentService { | public interface WxCpDepartmentService { | ||||||
|  |   String DEPARTMENT_CREATE = "https://qyapi.weixin.qq.com/cgi-bin/department/create"; | ||||||
|  |   String DEPARTMENT_UPDATE = "https://qyapi.weixin.qq.com/cgi-bin/department/update"; | ||||||
|  |   String DEPARTMENT_DELETE = "https://qyapi.weixin.qq.com/cgi-bin/department/delete?id=%d"; | ||||||
|  |   String DEPARTMENT_LIST = "https://qyapi.weixin.qq.com/cgi-bin/department/list"; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
|  | |||||||
| @ -12,6 +12,10 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| public interface WxCpMenuService { | public interface WxCpMenuService { | ||||||
|  |   String MENU_CREATE = "https://qyapi.weixin.qq.com/cgi-bin/menu/create?agentid=%d"; | ||||||
|  |   String MENU_DELETE = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=%d"; | ||||||
|  |   String MENU_GET = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=%d"; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
|    * 自定义菜单创建接口 |    * 自定义菜单创建接口 | ||||||
|  | |||||||
| @ -1,66 +0,0 @@ | |||||||
| package me.chanjar.weixin.cp.api; |  | ||||||
|  |  | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; |  | ||||||
| import me.chanjar.weixin.cp.bean.WxCpApprovalDataResult; |  | ||||||
| import me.chanjar.weixin.cp.bean.WxCpCheckinData; |  | ||||||
| import me.chanjar.weixin.cp.bean.WxCpCheckinOption; |  | ||||||
| import me.chanjar.weixin.cp.bean.WxCpDialRecord; |  | ||||||
|  |  | ||||||
| import java.util.Date; |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * @author Element |  | ||||||
|  * @Package me.chanjar.weixin.cp.api |  | ||||||
|  * @date 2019-04-06 10:52 |  | ||||||
|  * @Description: <pre> |  | ||||||
|  *     企业微信OA相关接口 |  | ||||||
|  * |  | ||||||
|  * </pre> |  | ||||||
|  */ |  | ||||||
| public interface WxCpOAService { |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * <pre> |  | ||||||
|    *     获取打卡数据 |  | ||||||
|    *     API doc : https://work.weixin.qq.com/api/doc#90000/90135/90262 |  | ||||||
|    * </pre> |  | ||||||
|    * |  | ||||||
|    * @param openCheckinDataType 打卡类型。1:上下班打卡;2:外出打卡;3:全部打卡 |  | ||||||
|    * @param starttime           获取打卡记录的开始时间 |  | ||||||
|    * @param endtime             获取打卡记录的结束时间 |  | ||||||
|    * @param userIdList          需要获取打卡记录的用户列表 |  | ||||||
|    */ |  | ||||||
|   List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date starttime, Date endtime, List<String> userIdList) throws WxErrorException; |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * <pre> |  | ||||||
|    *     获取打卡规则 |  | ||||||
|    *     API doc : https://work.weixin.qq.com/api/doc#90000/90135/90263 |  | ||||||
|    * </pre> |  | ||||||
|    * |  | ||||||
|    * @param datetime   需要获取规则的当天日期 |  | ||||||
|    * @param userIdList 需要获取打卡规则的用户列表 |  | ||||||
|    * @return |  | ||||||
|    * @throws WxErrorException |  | ||||||
|    */ |  | ||||||
|   List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> userIdList) throws WxErrorException; |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * <pre> |  | ||||||
|    *     获取审批数据 |  | ||||||
|    *     通过本接口来获取公司一段时间内的审批记录。一次拉取调用最多拉取10000个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。 |  | ||||||
|    *     API doc : https://work.weixin.qq.com/api/doc#90000/90135/91530 |  | ||||||
|    * </pre> |  | ||||||
|    * |  | ||||||
|    * @param starttime 获取审批记录的开始时间 |  | ||||||
|    * @param endtime   获取审批记录的结束时间 |  | ||||||
|    * @param nextSpnum 第一个拉取的审批单号,不填从该时间段的第一个审批单拉取 |  | ||||||
|    * @return |  | ||||||
|    * @throws WxErrorException |  | ||||||
|    */ |  | ||||||
|   WxCpApprovalDataResult getApprovalData(Date starttime, Date endtime, Long nextSpnum) throws WxErrorException; |  | ||||||
|  |  | ||||||
|   List<WxCpDialRecord> getDialRecord(Date starttime, Date endtime, Integer offset, Integer limit) throws WxErrorException; |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -0,0 +1,68 @@ | |||||||
|  | package me.chanjar.weixin.cp.api; | ||||||
|  |  | ||||||
|  | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
|  | import me.chanjar.weixin.cp.bean.WxCpApprovalDataResult; | ||||||
|  | import me.chanjar.weixin.cp.bean.WxCpCheckinData; | ||||||
|  | import me.chanjar.weixin.cp.bean.WxCpCheckinOption; | ||||||
|  | import me.chanjar.weixin.cp.bean.WxCpDialRecord; | ||||||
|  |  | ||||||
|  | import java.util.Date; | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 企业微信OA相关接口. | ||||||
|  |  * | ||||||
|  |  * @author Element | ||||||
|  |  * @date 2019-04-06 10:52 | ||||||
|  |  */ | ||||||
|  | public interface WxCpOaService { | ||||||
|  |   String GET_CHECKIN_DATA = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata"; | ||||||
|  |   String GET_CHECKIN_OPTION = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckinoption"; | ||||||
|  |   String GET_APPROVAL_DATA = "https://qyapi.weixin.qq.com/cgi-bin/corp/getapprovaldata"; | ||||||
|  |   String GET_DIAL_RECORD = "https://qyapi.weixin.qq.com/cgi-bin/dial/get_dial_record"; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * <pre> | ||||||
|  |    *  获取打卡数据 | ||||||
|  |    *  API doc : https://work.weixin.qq.com/api/doc#90000/90135/90262 | ||||||
|  |    * </pre> | ||||||
|  |    * | ||||||
|  |    * @param openCheckinDataType 打卡类型。1:上下班打卡;2:外出打卡;3:全部打卡 | ||||||
|  |    * @param startTime           获取打卡记录的开始时间 | ||||||
|  |    * @param endTime             获取打卡记录的结束时间 | ||||||
|  |    * @param userIdList          需要获取打卡记录的用户列表 | ||||||
|  |    * @return 打卡数据列表 | ||||||
|  |    * @throws WxErrorException 异常 | ||||||
|  |    */ | ||||||
|  |   List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime, Date endTime, List<String> userIdList) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * <pre> | ||||||
|  |    *   获取打卡规则 | ||||||
|  |    *   API doc : https://work.weixin.qq.com/api/doc#90000/90135/90263 | ||||||
|  |    * </pre> | ||||||
|  |    * | ||||||
|  |    * @param datetime   需要获取规则的当天日期 | ||||||
|  |    * @param userIdList 需要获取打卡规则的用户列表 | ||||||
|  |    * @return 打卡规则列表 | ||||||
|  |    * @throws WxErrorException 异常 | ||||||
|  |    */ | ||||||
|  |   List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> userIdList) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * <pre> | ||||||
|  |    *   获取审批数据 | ||||||
|  |    *   通过本接口来获取公司一段时间内的审批记录。一次拉取调用最多拉取10000个审批记录,可以通过多次拉取的方式来满足需求,但调用频率不可超过600次/分。 | ||||||
|  |    *   API doc : https://work.weixin.qq.com/api/doc#90000/90135/91530 | ||||||
|  |    * </pre> | ||||||
|  |    * | ||||||
|  |    * @param startTime 获取审批记录的开始时间 | ||||||
|  |    * @param endTime   获取审批记录的结束时间 | ||||||
|  |    * @param nextSpnum 第一个拉取的审批单号,不填从该时间段的第一个审批单拉取 | ||||||
|  |    * @throws WxErrorException 异常 | ||||||
|  |    */ | ||||||
|  |   WxCpApprovalDataResult getApprovalData(Date startTime, Date endTime, Long nextSpnum) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit) throws WxErrorException; | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -13,7 +13,7 @@ import me.chanjar.weixin.cp.bean.WxCpMessageSendResult; | |||||||
| import me.chanjar.weixin.cp.config.WxCpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpConfigStorage; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 微信API的Service |  * 微信API的Service. | ||||||
|  * @author chanjaster |  * @author chanjaster | ||||||
|  */ |  */ | ||||||
| public interface WxCpService { | public interface WxCpService { | ||||||
| @ -25,6 +25,7 @@ public interface WxCpService { | |||||||
|   String BATCH_REPLACE_USER = "https://qyapi.weixin.qq.com/cgi-bin/batch/replaceuser"; |   String BATCH_REPLACE_USER = "https://qyapi.weixin.qq.com/cgi-bin/batch/replaceuser"; | ||||||
|   String BATCH_GET_RESULT = "https://qyapi.weixin.qq.com/cgi-bin/batch/getresult?jobid="; |   String BATCH_GET_RESULT = "https://qyapi.weixin.qq.com/cgi-bin/batch/getresult?jobid="; | ||||||
|   String JSCODE_TO_SESSION_URL = "https://qyapi.weixin.qq.com/cgi-bin/miniprogram/jscode2session"; |   String JSCODE_TO_SESSION_URL = "https://qyapi.weixin.qq.com/cgi-bin/miniprogram/jscode2session"; | ||||||
|  |   String GET_TOKEN = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?&corpid=%s&corpsecret=%s"; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
| @ -310,7 +311,7 @@ public interface WxCpService { | |||||||
|  |  | ||||||
|   WxCpAgentService getAgentService(); |   WxCpAgentService getAgentService(); | ||||||
|  |  | ||||||
|   WxCpOAService getOAService(); |   WxCpOaService getOAService(); | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * http请求对象 |    * http请求对象 | ||||||
|  | |||||||
| @ -17,6 +17,14 @@ import java.util.List; | |||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| public interface WxCpTagService { | public interface WxCpTagService { | ||||||
|  |   String TAG_CREATE = "https://qyapi.weixin.qq.com/cgi-bin/tag/create"; | ||||||
|  |   String TAG_UPDATE = "https://qyapi.weixin.qq.com/cgi-bin/tag/update"; | ||||||
|  |   String TAG_DELETE = "https://qyapi.weixin.qq.com/cgi-bin/tag/delete?tagid=%s"; | ||||||
|  |   String TAG_LIST = "https://qyapi.weixin.qq.com/cgi-bin/tag/list"; | ||||||
|  |   String TAG_GET = "https://qyapi.weixin.qq.com/cgi-bin/tag/get?tagid=%s"; | ||||||
|  |   String TAG_ADDTAGUSERS = "https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers"; | ||||||
|  |   String TAG_DELTAGUSERS = "https://qyapi.weixin.qq.com/cgi-bin/tag/deltagusers"; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 创建标签. |    * 创建标签. | ||||||
|    * |    * | ||||||
| @ -51,6 +59,14 @@ public interface WxCpTagService { | |||||||
|    */ |    */ | ||||||
|   List<WxCpUser> listUsersByTagId(String tagId) throws WxErrorException; |   List<WxCpUser> listUsersByTagId(String tagId) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 获取标签成员. | ||||||
|  |    * 对应: http://qydev.weixin.qq.com/wiki/index.php?title=管理标签 中的get接口 | ||||||
|  |    * | ||||||
|  |    * @param tagId 标签id | ||||||
|  |    */ | ||||||
|  |   WxCpTagGetResult get(String tagId) throws WxErrorException; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 增加标签成员. |    * 增加标签成员. | ||||||
|    * |    * | ||||||
| @ -69,13 +85,4 @@ public interface WxCpTagService { | |||||||
|    */ |    */ | ||||||
|   WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException; |   WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException; | ||||||
|  |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * 获取标签成员. |  | ||||||
|    * 对应: http://qydev.weixin.qq.com/wiki/index.php?title=管理标签 中的get接口 |  | ||||||
|    * |  | ||||||
|    * @param tagId 标签id |  | ||||||
|    */ |  | ||||||
|   WxCpTagGetResult get(String tagId) throws WxErrorException; |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -14,6 +14,8 @@ import java.util.List; | |||||||
|  * @date 2019-05-16 |  * @date 2019-05-16 | ||||||
|  */ |  */ | ||||||
| public interface WxCpTaskCardService { | public interface WxCpTaskCardService { | ||||||
|  |   String MESSAGE_UPDATE_TASKCARD = "https://qyapi.weixin.qq.com/cgi-bin/message/update_taskcard"; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
|    * 更新任务卡片消息状态 |    * 更新任务卡片消息状态 | ||||||
|  | |||||||
| @ -7,17 +7,19 @@ import me.chanjar.weixin.common.util.http.RequestExecutor; | |||||||
| import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; | import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpTpCorp; | import me.chanjar.weixin.cp.bean.WxCpTpCorp; | ||||||
| import me.chanjar.weixin.cp.config.WxCpConfigStorage; |  | ||||||
| import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 微信第三方应用API的Service |  * 微信第三方应用API的Service. | ||||||
|  |  * | ||||||
|  * @author zhenjun cai |  * @author zhenjun cai | ||||||
|  */ |  */ | ||||||
| public interface WxCpTpService { | public interface WxCpTpService { | ||||||
|   String JSCODE_TO_SESSION_URL = "https://qyapi.weixin.qq.com/cgi-bin/service/miniprogram/jscode2session"; |   String JSCODE_TO_SESSION_URL = "https://qyapi.weixin.qq.com/cgi-bin/service/miniprogram/jscode2session"; | ||||||
|   String GET_CORP_TOKEN = "https://qyapi.weixin.qq.com/cgi-bin/service/get_corp_token"; |   String GET_CORP_TOKEN = "https://qyapi.weixin.qq.com/cgi-bin/service/get_corp_token"; | ||||||
|   String GET_PERMANENT_CODE = "https://qyapi.weixin.qq.com/cgi-bin/service/get_permanent_code"; |   String GET_PERMANENT_CODE = "https://qyapi.weixin.qq.com/cgi-bin/service/get_permanent_code"; | ||||||
|  |   String GET_SUITE_TOKEN = "https://qyapi.weixin.qq.com/cgi-bin/service/get_suite_token"; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
|    * 验证推送过来的消息的正确性 |    * 验证推送过来的消息的正确性 | ||||||
| @ -79,6 +81,7 @@ public interface WxCpTpService { | |||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 获取企业凭证 |    * 获取企业凭证 | ||||||
|  |    * | ||||||
|    * @param authCorpid    授权方corpid |    * @param authCorpid    授权方corpid | ||||||
|    * @param permanentCode 永久授权码,通过get_permanent_code获取 |    * @param permanentCode 永久授权码,通过get_permanent_code获取 | ||||||
|    */ |    */ | ||||||
| @ -86,6 +89,7 @@ public interface WxCpTpService { | |||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 获取企业永久授权码 |    * 获取企业永久授权码 | ||||||
|  |    * | ||||||
|    * @param authCode |    * @param authCode | ||||||
|    * @return |    * @return | ||||||
|    */ |    */ | ||||||
|  | |||||||
| @ -17,6 +17,19 @@ import me.chanjar.weixin.cp.bean.WxCpUserExternalContactInfo; | |||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| public interface WxCpUserService { | public interface WxCpUserService { | ||||||
|  |   String URL_AUTHENTICATE = "https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?userid="; | ||||||
|  |   String URL_USER_CREATE = "https://qyapi.weixin.qq.com/cgi-bin/user/create"; | ||||||
|  |   String URL_USER_UPDATE = "https://qyapi.weixin.qq.com/cgi-bin/user/update"; | ||||||
|  |   String URL_USER_DELETE = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?userid="; | ||||||
|  |   String URL_USER_BATCH_DELETE = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete"; | ||||||
|  |   String URL_USER_GET = "https://qyapi.weixin.qq.com/cgi-bin/user/get?userid="; | ||||||
|  |   String URL_USER_LIST = "https://qyapi.weixin.qq.com/cgi-bin/user/list?department_id="; | ||||||
|  |   String URL_USER_SIMPLE_LIST = "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?department_id="; | ||||||
|  |   String URL_BATCH_INVITE = "https://qyapi.weixin.qq.com/cgi-bin/batch/invite"; | ||||||
|  |   String URL_CONVERT_TO_OPENID = "https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_openid"; | ||||||
|  |   String URL_CONVERT_TO_USERID = "https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid"; | ||||||
|  |   String URL_GET_EXTERNAL_CONTACT = "https://qyapi.weixin.qq.com/cgi-bin/crm/get_external_contact?external_userid="; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
|    *   用在二次验证的时候. |    *   用在二次验证的时候. | ||||||
|  | |||||||
| @ -45,7 +45,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||||||
|   private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this); |   private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this); | ||||||
|   private WxCpTagService tagService = new WxCpTagServiceImpl(this); |   private WxCpTagService tagService = new WxCpTagServiceImpl(this); | ||||||
|   private WxCpAgentService agentService = new WxCpAgentServiceImpl(this); |   private WxCpAgentService agentService = new WxCpAgentServiceImpl(this); | ||||||
|   private WxCpOAService oaService = new WxCpOAServiceImpl(this); |   private WxCpOaService oaService = new WxCpOaServiceImpl(this); | ||||||
|   private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this); |   private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this); | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
| @ -389,7 +389,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxCpOAService getOAService() { |   public WxCpOaService getOAService() { | ||||||
|     return oaService; |     return oaService; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
| @ -37,15 +37,13 @@ public class WxCpAgentServiceImpl implements WxCpAgentService { | |||||||
|       throw new IllegalArgumentException("缺少agentid参数"); |       throw new IllegalArgumentException("缺少agentid参数"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/agent/get?agentid=" + agentId; |     String responseContent = this.mainService.get(String.format(WxCpAgentService.GET_AGENT, agentId), null); | ||||||
|     String responseContent = this.mainService.get(url, null); |  | ||||||
|     return WxCpAgent.fromJson(responseContent); |     return WxCpAgent.fromJson(responseContent); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void set(WxCpAgent agentInfo) throws WxErrorException { |   public void set(WxCpAgent agentInfo) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/agent/set"; |     String responseContent = this.mainService.post(WxCpAgentService.AGENT_SET, agentInfo.toJson()); | ||||||
|     String responseContent = this.mainService.post(url, agentInfo.toJson()); |  | ||||||
|     JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); |     JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | ||||||
|     if (jsonObject.get("errcode").getAsInt() != 0) { |     if (jsonObject.get("errcode").getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent)); |       throw new WxErrorException(WxError.fromJson(responseContent)); | ||||||
| @ -54,8 +52,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpAgent> list() throws WxErrorException { |   public List<WxCpAgent> list() throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/agent/list"; |     String responseContent = this.mainService.get(WxCpAgentService.AGENT_LIST, null); | ||||||
|     String responseContent = this.mainService.get(url, null); |  | ||||||
|     JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); |     JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); | ||||||
|     if (jsonObject.get("errcode").getAsInt() != 0) { |     if (jsonObject.get("errcode").getAsInt() != 0) { | ||||||
|       throw new WxErrorException(WxError.fromJson(responseContent)); |       throw new WxErrorException(WxError.fromJson(responseContent)); | ||||||
|  | |||||||
| @ -98,7 +98,7 @@ public class WxCpChatServiceImpl implements WxCpChatService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void sendMsg(WxCpAppChatMessage message) throws WxErrorException { |   public void sendMsg(WxCpAppChatMessage message) throws WxErrorException { | ||||||
|     this.cpService.post("https://qyapi.weixin.qq.com/cgi-bin/appchat/send", message.toJson()); |     this.cpService.post(WxCpChatService.APPCHAT_SEND, message.toJson()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -29,27 +29,25 @@ public class WxCpDepartmentServiceImpl implements WxCpDepartmentService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public Long create(WxCpDepart depart) throws WxErrorException { |   public Long create(WxCpDepart depart) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/department/create"; |     String responseContent = this.mainService.post(WxCpDepartmentService.DEPARTMENT_CREATE, depart.toJson()); | ||||||
|     String responseContent = this.mainService.post(url, depart.toJson()); |  | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return GsonHelper.getAsLong(tmpJsonElement.getAsJsonObject().get("id")); |     return GsonHelper.getAsLong(tmpJsonElement.getAsJsonObject().get("id")); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void update(WxCpDepart group) throws WxErrorException { |   public void update(WxCpDepart group) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/department/update"; |     this.mainService.post(WxCpDepartmentService.DEPARTMENT_UPDATE, group.toJson()); | ||||||
|     this.mainService.post(url, group.toJson()); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void delete(Long departId) throws WxErrorException { |   public void delete(Long departId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/department/delete?id=" + departId; |     String url = String.format(WxCpDepartmentService.DEPARTMENT_DELETE, departId); | ||||||
|     this.mainService.get(url, null); |     this.mainService.get(url, null); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpDepart> list(Long id) throws WxErrorException { |   public List<WxCpDepart> list(Long id) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list"; |     String url = WxCpDepartmentService.DEPARTMENT_LIST; | ||||||
|     if (id != null) { |     if (id != null) { | ||||||
|       url += "?id=" + id; |       url += "?id=" + id; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -8,10 +8,11 @@ import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * <pre> |  * <pre> | ||||||
|  * 菜单管理相关接口 |  * 菜单管理相关接口. | ||||||
|  * Created by Binary Wang on 2017-6-25. |  * Created by Binary Wang on 2017-6-25. | ||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  | ||||||
|  * </pre> |  * </pre> | ||||||
|  |  * | ||||||
|  |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| public class WxCpMenuServiceImpl implements WxCpMenuService { | public class WxCpMenuServiceImpl implements WxCpMenuService { | ||||||
|   private WxCpService mainService; |   private WxCpService mainService; | ||||||
| @ -27,8 +28,7 @@ public class WxCpMenuServiceImpl implements WxCpMenuService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void create(Integer agentId, WxMenu menu) throws WxErrorException { |   public void create(Integer agentId, WxMenu menu) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/create?agentid=" + agentId; |     this.mainService.post(String.format(WxCpMenuService.MENU_CREATE, agentId), menu.toJson()); | ||||||
|     this.mainService.post(url, menu.toJson()); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
| @ -38,7 +38,7 @@ public class WxCpMenuServiceImpl implements WxCpMenuService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void delete(Integer agentId) throws WxErrorException { |   public void delete(Integer agentId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=" + agentId; |     String url = String.format(WxCpMenuService.MENU_DELETE, agentId); | ||||||
|     this.mainService.get(url, null); |     this.mainService.get(url, null); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @ -49,7 +49,7 @@ public class WxCpMenuServiceImpl implements WxCpMenuService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxMenu get(Integer agentId) throws WxErrorException { |   public WxMenu get(Integer agentId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + agentId; |     String url = String.format(WxCpMenuService.MENU_GET, agentId); | ||||||
|     try { |     try { | ||||||
|       String resultContent = this.mainService.get(url, null); |       String resultContent = this.mainService.get(url, null); | ||||||
|       return WxCpGsonBuilder.create().fromJson(resultContent, WxMenu.class); |       return WxCpGsonBuilder.create().fromJson(resultContent, WxMenu.class); | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ import com.google.gson.JsonObject; | |||||||
| import com.google.gson.JsonParser; | import com.google.gson.JsonParser; | ||||||
| import com.google.gson.reflect.TypeToken; | import com.google.gson.reflect.TypeToken; | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.api.WxCpOAService; | import me.chanjar.weixin.cp.api.WxCpOaService; | ||||||
| import me.chanjar.weixin.cp.api.WxCpService; | import me.chanjar.weixin.cp.api.WxCpService; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpApprovalDataResult; | import me.chanjar.weixin.cp.bean.WxCpApprovalDataResult; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpCheckinData; | import me.chanjar.weixin.cp.bean.WxCpCheckinData; | ||||||
| @ -19,22 +19,19 @@ import java.util.List; | |||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * @author Element |  * @author Element | ||||||
|  * @Package me.chanjar.weixin.cp.api.impl |  | ||||||
|  * @date 2019-04-06 11:20 |  * @date 2019-04-06 11:20 | ||||||
|  * @Description: TODO |  | ||||||
|  */ |  */ | ||||||
| public class WxCpOAServiceImpl implements WxCpOAService { | public class WxCpOaServiceImpl implements WxCpOaService { | ||||||
| 
 |  | ||||||
|   private WxCpService mainService; |   private WxCpService mainService; | ||||||
| 
 | 
 | ||||||
|   public WxCpOAServiceImpl(WxCpService mainService) { |   public WxCpOaServiceImpl(WxCpService mainService) { | ||||||
|     this.mainService = mainService; |     this.mainService = mainService; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date starttime, Date endtime, List<String> userIdList) throws WxErrorException { |   public List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime, Date endTime, List<String> userIdList) throws WxErrorException { | ||||||
| 
 | 
 | ||||||
|     if (starttime == null || endtime == null) { |     if (startTime == null || endTime == null) { | ||||||
|       throw new RuntimeException("starttime and endtime can't be null"); |       throw new RuntimeException("starttime and endtime can't be null"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -42,15 +39,13 @@ public class WxCpOAServiceImpl implements WxCpOAService { | |||||||
|       throw new RuntimeException("用户列表不能为空,不超过100个,若用户超过100个,请分批获取"); |       throw new RuntimeException("用户列表不能为空,不超过100个,若用户超过100个,请分批获取"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     long endtimestamp = endtime.getTime() / 1000L; |     long endtimestamp = endTime.getTime() / 1000L; | ||||||
|     long starttimestamp = starttime.getTime() / 1000L; |     long starttimestamp = startTime.getTime() / 1000L; | ||||||
| 
 | 
 | ||||||
|     if (endtimestamp - starttimestamp < 0 || endtimestamp - starttimestamp >= 30 * 24 * 60 * 60) { |     if (endtimestamp - starttimestamp < 0 || endtimestamp - starttimestamp >= 30 * 24 * 60 * 60) { | ||||||
|       throw new RuntimeException("获取记录时间跨度不超过一个月"); |       throw new RuntimeException("获取记录时间跨度不超过一个月"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata"; |  | ||||||
| 
 |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
|     JsonArray jsonArray = new JsonArray(); |     JsonArray jsonArray = new JsonArray(); | ||||||
| 
 | 
 | ||||||
| @ -64,7 +59,7 @@ public class WxCpOAServiceImpl implements WxCpOAService { | |||||||
| 
 | 
 | ||||||
|     jsonObject.add("useridlist", jsonArray); |     jsonObject.add("useridlist", jsonArray); | ||||||
| 
 | 
 | ||||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); |     String responseContent = this.mainService.post(WxCpOaService.GET_CHECKIN_DATA, jsonObject.toString()); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return WxCpGsonBuilder.create() |     return WxCpGsonBuilder.create() | ||||||
|       .fromJson( |       .fromJson( | ||||||
| @ -76,7 +71,6 @@ public class WxCpOAServiceImpl implements WxCpOAService { | |||||||
| 
 | 
 | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> userIdList) throws WxErrorException { |   public List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> userIdList) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckinoption"; |  | ||||||
|     if (datetime == null) { |     if (datetime == null) { | ||||||
|       throw new RuntimeException("datetime can't be null"); |       throw new RuntimeException("datetime can't be null"); | ||||||
|     } |     } | ||||||
| @ -94,7 +88,7 @@ public class WxCpOAServiceImpl implements WxCpOAService { | |||||||
|     jsonObject.addProperty("datetime", datetime.getTime() / 1000L); |     jsonObject.addProperty("datetime", datetime.getTime() / 1000L); | ||||||
|     jsonObject.add("useridlist", jsonArray); |     jsonObject.add("useridlist", jsonArray); | ||||||
| 
 | 
 | ||||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); |     String responseContent = this.mainService.post(WxCpOaService.GET_CHECKIN_OPTION, jsonObject.toString()); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
| 
 | 
 | ||||||
|     return WxCpGsonBuilder.create() |     return WxCpGsonBuilder.create() | ||||||
| @ -106,24 +100,20 @@ public class WxCpOAServiceImpl implements WxCpOAService { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   @Override |   @Override | ||||||
|   public WxCpApprovalDataResult getApprovalData(Date starttime, Date endtime, Long nextSpnum) throws WxErrorException { |   public WxCpApprovalDataResult getApprovalData(Date startTime, Date endTime, Long nextSpnum) throws WxErrorException { | ||||||
| 
 |  | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/corp/getapprovaldata"; |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
|     jsonObject.addProperty("starttime", starttime.getTime() / 1000L); |     jsonObject.addProperty("starttime", startTime.getTime() / 1000L); | ||||||
|     jsonObject.addProperty("endtime", endtime.getTime() / 1000L); |     jsonObject.addProperty("endtime", endTime.getTime() / 1000L); | ||||||
|     if (nextSpnum != null) { |     if (nextSpnum != null) { | ||||||
|       jsonObject.addProperty("next_spnum", nextSpnum); |       jsonObject.addProperty("next_spnum", nextSpnum); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); |     String responseContent = this.mainService.post(WxCpOaService.GET_APPROVAL_DATA, jsonObject.toString()); | ||||||
|     return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDataResult.class); |     return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDataResult.class); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpDialRecord> getDialRecord(Date starttime, Date endtime, Integer offset, Integer limit) throws WxErrorException { |   public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit) throws WxErrorException { | ||||||
| 
 |  | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/dial/get_dial_record"; |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
| 
 | 
 | ||||||
|     if (offset == null) { |     if (offset == null) { | ||||||
| @ -137,10 +127,10 @@ public class WxCpOAServiceImpl implements WxCpOAService { | |||||||
|     jsonObject.addProperty("offset", offset); |     jsonObject.addProperty("offset", offset); | ||||||
|     jsonObject.addProperty("limit", limit); |     jsonObject.addProperty("limit", limit); | ||||||
| 
 | 
 | ||||||
|     if (starttime != null && endtime != null) { |     if (startTime != null && endTime != null) { | ||||||
| 
 | 
 | ||||||
|       long endtimestamp = endtime.getTime() / 1000L; |       long endtimestamp = endTime.getTime() / 1000L; | ||||||
|       long starttimestamp = starttime.getTime() / 1000L; |       long starttimestamp = startTime.getTime() / 1000L; | ||||||
| 
 | 
 | ||||||
|       if (endtimestamp - starttimestamp < 0 || endtimestamp - starttimestamp >= 30 * 24 * 60 * 60) { |       if (endtimestamp - starttimestamp < 0 || endtimestamp - starttimestamp >= 30 * 24 * 60 * 60) { | ||||||
|         throw new RuntimeException("受限于网络传输,起止时间的最大跨度为30天,如超过30天,则以结束时间为基准向前取30天进行查询"); |         throw new RuntimeException("受限于网络传输,起止时间的最大跨度为30天,如超过30天,则以结束时间为基准向前取30天进行查询"); | ||||||
| @ -148,11 +138,9 @@ public class WxCpOAServiceImpl implements WxCpOAService { | |||||||
| 
 | 
 | ||||||
|       jsonObject.addProperty("start_time", starttimestamp); |       jsonObject.addProperty("start_time", starttimestamp); | ||||||
|       jsonObject.addProperty("end_time", endtimestamp); |       jsonObject.addProperty("end_time", endtimestamp); | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); |     String responseContent = this.mainService.post(WxCpOaService.GET_DIAL_RECORD, jsonObject.toString()); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
| 
 | 
 | ||||||
|     return WxCpGsonBuilder.create() |     return WxCpGsonBuilder.create() | ||||||
| @ -8,7 +8,7 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||||||
| import me.chanjar.weixin.common.util.http.HttpType; | import me.chanjar.weixin.common.util.http.HttpType; | ||||||
| import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | ||||||
| import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | ||||||
| import me.chanjar.weixin.cp.api.WxCpOAService; | import me.chanjar.weixin.cp.api.WxCpService; | ||||||
| import me.chanjar.weixin.cp.config.WxCpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpConfigStorage; | ||||||
| import org.apache.http.HttpHost; | import org.apache.http.HttpHost; | ||||||
| import org.apache.http.client.config.RequestConfig; | import org.apache.http.client.config.RequestConfig; | ||||||
| @ -19,6 +19,9 @@ import org.apache.http.impl.client.CloseableHttpClient; | |||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @author someone | ||||||
|  |  */ | ||||||
| public class WxCpServiceApacheHttpClientImpl extends BaseWxCpServiceImpl<CloseableHttpClient, HttpHost> { | public class WxCpServiceApacheHttpClientImpl extends BaseWxCpServiceImpl<CloseableHttpClient, HttpHost> { | ||||||
|   protected CloseableHttpClient httpClient; |   protected CloseableHttpClient httpClient; | ||||||
|   protected HttpHost httpProxy; |   protected HttpHost httpProxy; | ||||||
| @ -45,9 +48,7 @@ public class WxCpServiceApacheHttpClientImpl extends BaseWxCpServiceImpl<Closeab | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     synchronized (this.globalAccessTokenRefreshLock) { |     synchronized (this.globalAccessTokenRefreshLock) { | ||||||
|       String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?" |       String url = String.format(WxCpService.GET_TOKEN, this.configStorage.getCorpId(), this.configStorage.getCorpSecret()); | ||||||
|         + "&corpid=" + this.configStorage.getCorpId() |  | ||||||
|         + "&corpsecret=" + this.configStorage.getCorpSecret(); |  | ||||||
|       try { |       try { | ||||||
|         HttpGet httpGet = new HttpGet(url); |         HttpGet httpGet = new HttpGet(url); | ||||||
|         if (this.httpProxy != null) { |         if (this.httpProxy != null) { | ||||||
| @ -56,8 +57,8 @@ public class WxCpServiceApacheHttpClientImpl extends BaseWxCpServiceImpl<Closeab | |||||||
|           httpGet.setConfig(config); |           httpGet.setConfig(config); | ||||||
|         } |         } | ||||||
|         String resultContent; |         String resultContent; | ||||||
|         try (CloseableHttpClient httpclient = getRequestHttpClient(); |         try (CloseableHttpClient httpClient = getRequestHttpClient(); | ||||||
|              CloseableHttpResponse response = httpclient.execute(httpGet)) { |              CloseableHttpResponse response = httpClient.execute(httpGet)) { | ||||||
|           resultContent = new BasicResponseHandler().handleResponse(response); |           resultContent = new BasicResponseHandler().handleResponse(response); | ||||||
|         } finally { |         } finally { | ||||||
|           httpGet.releaseConnection(); |           httpGet.releaseConnection(); | ||||||
|  | |||||||
| @ -6,8 +6,12 @@ import me.chanjar.weixin.common.bean.WxAccessToken; | |||||||
| import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
| import me.chanjar.weixin.common.util.http.HttpType; | import me.chanjar.weixin.common.util.http.HttpType; | ||||||
|  | import me.chanjar.weixin.cp.api.WxCpService; | ||||||
| import me.chanjar.weixin.cp.config.WxCpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpConfigStorage; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @author someone | ||||||
|  |  */ | ||||||
| public class WxCpServiceJoddHttpImpl extends BaseWxCpServiceImpl<HttpConnectionProvider, ProxyInfo> { | public class WxCpServiceJoddHttpImpl extends BaseWxCpServiceImpl<HttpConnectionProvider, ProxyInfo> { | ||||||
|   protected HttpConnectionProvider httpClient; |   protected HttpConnectionProvider httpClient; | ||||||
|   protected ProxyInfo httpProxy; |   protected ProxyInfo httpProxy; | ||||||
| @ -35,11 +39,7 @@ public class WxCpServiceJoddHttpImpl extends BaseWxCpServiceImpl<HttpConnectionP | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     synchronized (this.globalAccessTokenRefreshLock) { |     synchronized (this.globalAccessTokenRefreshLock) { | ||||||
|       String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?" |       HttpRequest request = HttpRequest.get(String.format(WxCpService.GET_TOKEN, this.configStorage.getCorpId(), this.configStorage.getCorpSecret())); | ||||||
|         + "&corpid=" + this.configStorage.getCorpId() |  | ||||||
|         + "&corpsecret=" + this.configStorage.getCorpSecret(); |  | ||||||
|  |  | ||||||
|       HttpRequest request = HttpRequest.get(url); |  | ||||||
|       if (this.httpProxy != null) { |       if (this.httpProxy != null) { | ||||||
|         httpClient.useProxy(this.httpProxy); |         httpClient.useProxy(this.httpProxy); | ||||||
|       } |       } | ||||||
|  | |||||||
| @ -6,15 +6,18 @@ import me.chanjar.weixin.common.error.WxError; | |||||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
| import me.chanjar.weixin.common.util.http.HttpType; | import me.chanjar.weixin.common.util.http.HttpType; | ||||||
| import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | ||||||
|  | import me.chanjar.weixin.cp.api.WxCpService; | ||||||
| import me.chanjar.weixin.cp.config.WxCpConfigStorage; | import me.chanjar.weixin.cp.config.WxCpConfigStorage; | ||||||
| import okhttp3.*; | import okhttp3.*; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @author someone | ||||||
|  |  */ | ||||||
| public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkHttpProxyInfo> { | public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkHttpProxyInfo> { | ||||||
|   protected OkHttpClient httpClient; |   private OkHttpClient httpClient; | ||||||
|   protected OkHttpProxyInfo httpProxy; |   private OkHttpProxyInfo httpProxy; | ||||||
|  |  | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public OkHttpClient getRequestHttpClient() { |   public OkHttpClient getRequestHttpClient() { | ||||||
| @ -38,13 +41,13 @@ public class WxCpServiceOkHttpImpl extends BaseWxCpServiceImpl<OkHttpClient, OkH | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     synchronized (this.globalAccessTokenRefreshLock) { |     synchronized (this.globalAccessTokenRefreshLock) { | ||||||
|         String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?" |  | ||||||
|           + "&corpid=" + this.configStorage.getCorpId() |  | ||||||
|           + "&corpsecret=" + this.configStorage.getCorpSecret(); |  | ||||||
|       //得到httpClient |       //得到httpClient | ||||||
|       OkHttpClient client = getRequestHttpClient(); |       OkHttpClient client = getRequestHttpClient(); | ||||||
|       //请求的request |       //请求的request | ||||||
|         Request request = new Request.Builder().url(url).get().build(); |       Request request = new Request.Builder() | ||||||
|  |         .url(String.format(WxCpService.GET_TOKEN, this.configStorage.getCorpId(), this.configStorage.getCorpSecret())) | ||||||
|  |         .get() | ||||||
|  |         .build(); | ||||||
|       String resultContent = null; |       String resultContent = null; | ||||||
|       try { |       try { | ||||||
|         Response response = client.newCall(request).execute(); |         Response response = client.newCall(request).execute(); | ||||||
|  | |||||||
| @ -1,12 +1,6 @@ | |||||||
| package me.chanjar.weixin.cp.api.impl; | package me.chanjar.weixin.cp.api.impl; | ||||||
|  |  | ||||||
| import java.util.List; | import com.google.gson.*; | ||||||
|  |  | ||||||
| import com.google.gson.JsonArray; |  | ||||||
| import com.google.gson.JsonElement; |  | ||||||
| import com.google.gson.JsonObject; |  | ||||||
| import com.google.gson.JsonParser; |  | ||||||
| import com.google.gson.JsonPrimitive; |  | ||||||
| import com.google.gson.reflect.TypeToken; | import com.google.gson.reflect.TypeToken; | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
| import me.chanjar.weixin.cp.api.WxCpService; | import me.chanjar.weixin.cp.api.WxCpService; | ||||||
| @ -17,12 +11,15 @@ import me.chanjar.weixin.cp.bean.WxCpTagGetResult; | |||||||
| import me.chanjar.weixin.cp.bean.WxCpUser; | import me.chanjar.weixin.cp.bean.WxCpUser; | ||||||
| import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * <pre> |  * <pre> | ||||||
|  *  标签管理接口 |  *  标签管理接口. | ||||||
|  * Created by Binary Wang on 2017-6-25. |  * Created by Binary Wang on 2017-6-25. | ||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  | ||||||
|  * </pre> |  * </pre> | ||||||
|  |  * | ||||||
|  |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| public class WxCpTagServiceImpl implements WxCpTagService { | public class WxCpTagServiceImpl implements WxCpTagService { | ||||||
|   private WxCpService mainService; |   private WxCpService mainService; | ||||||
| @ -33,33 +30,29 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public String create(String tagName) throws WxErrorException { |   public String create(String tagName) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/create"; |  | ||||||
|     JsonObject o = new JsonObject(); |     JsonObject o = new JsonObject(); | ||||||
|     o.addProperty("tagname", tagName); |     o.addProperty("tagname", tagName); | ||||||
|     String responseContent = this.mainService.post(url, o.toString()); |     String responseContent = this.mainService.post(WxCpTagService.TAG_CREATE, o.toString()); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return tmpJsonElement.getAsJsonObject().get("tagid").getAsString(); |     return tmpJsonElement.getAsJsonObject().get("tagid").getAsString(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void update(String tagId, String tagName) throws WxErrorException { |   public void update(String tagId, String tagName) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/update"; |  | ||||||
|     JsonObject o = new JsonObject(); |     JsonObject o = new JsonObject(); | ||||||
|     o.addProperty("tagid", tagId); |     o.addProperty("tagid", tagId); | ||||||
|     o.addProperty("tagname", tagName); |     o.addProperty("tagname", tagName); | ||||||
|     this.mainService.post(url, o.toString()); |     this.mainService.post(WxCpTagService.TAG_UPDATE, o.toString()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void delete(String tagId) throws WxErrorException { |   public void delete(String tagId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/delete?tagid=" + tagId; |     this.mainService.get(String.format(WxCpTagService.TAG_DELETE, tagId), null); | ||||||
|     this.mainService.get(url, null); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpTag> listAll() throws WxErrorException { |   public List<WxCpTag> listAll() throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/list"; |     String responseContent = this.mainService.get(WxCpTagService.TAG_LIST, null); | ||||||
|     String responseContent = this.mainService.get(url, null); |  | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return WxCpGsonBuilder.create() |     return WxCpGsonBuilder.create() | ||||||
|       .fromJson( |       .fromJson( | ||||||
| @ -71,8 +64,7 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpUser> listUsersByTagId(String tagId) throws WxErrorException { |   public List<WxCpUser> listUsersByTagId(String tagId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/get?tagid=" + tagId; |     String responseContent = this.mainService.get(String.format(WxCpTagService.TAG_GET, tagId), null); | ||||||
|     String responseContent = this.mainService.get(url, null); |  | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return WxCpGsonBuilder.create() |     return WxCpGsonBuilder.create() | ||||||
|       .fromJson( |       .fromJson( | ||||||
| @ -84,22 +76,20 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxCpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { |   public WxCpTagAddOrRemoveUsersResult addUsers2Tag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers"; |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
|     jsonObject.addProperty("tagid", tagId); |     jsonObject.addProperty("tagid", tagId); | ||||||
|     this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); |     this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); | ||||||
|  |  | ||||||
|     return WxCpTagAddOrRemoveUsersResult.fromJson(this.mainService.post(url, jsonObject.toString())); |     return WxCpTagAddOrRemoveUsersResult.fromJson(this.mainService.post(WxCpTagService.TAG_ADDTAGUSERS, jsonObject.toString())); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { |   public WxCpTagAddOrRemoveUsersResult removeUsersFromTag(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/deltagusers"; |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
|     jsonObject.addProperty("tagid", tagId); |     jsonObject.addProperty("tagid", tagId); | ||||||
|     this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); |     this.addUserIdsAndPartyIdsToJson(userIds, partyIds, jsonObject); | ||||||
|  |  | ||||||
|     return WxCpTagAddOrRemoveUsersResult.fromJson(this.mainService.post(url, jsonObject.toString())); |     return WxCpTagAddOrRemoveUsersResult.fromJson(this.mainService.post(WxCpTagService.TAG_DELTAGUSERS, jsonObject.toString())); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   private void addUserIdsAndPartyIdsToJson(List<String> userIds, List<String> partyIds, JsonObject jsonObject) { |   private void addUserIdsAndPartyIdsToJson(List<String> userIds, List<String> partyIds, JsonObject jsonObject) { | ||||||
| @ -122,15 +112,11 @@ public class WxCpTagServiceImpl implements WxCpTagService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxCpTagGetResult get(String tagId) throws WxErrorException { |   public WxCpTagGetResult get(String tagId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/get"; |     if (tagId == null) { | ||||||
|     if (tagId != null) { |  | ||||||
|       url += "?tagId=" + tagId; |  | ||||||
|     } else { |  | ||||||
|       throw new IllegalArgumentException("缺少tagId参数"); |       throw new IllegalArgumentException("缺少tagId参数"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     String responseContent = this.mainService.get(url, null); |     String responseContent = this.mainService.get(String.format(WxCpTagService.TAG_GET, tagId), null); | ||||||
|  |  | ||||||
|     return WxCpTagGetResult.fromJson(responseContent); |     return WxCpTagGetResult.fromJson(responseContent); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -33,7 +33,6 @@ public class WxCpTaskCardServiceImpl implements WxCpTaskCardService { | |||||||
|     data.put("task_id", taskId); |     data.put("task_id", taskId); | ||||||
|     data.put("clicked_key", clickedKey); |     data.put("clicked_key", clickedKey); | ||||||
|  |  | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/message/update_taskcard"; |     this.mainService.post(MESSAGE_UPDATE_TASKCARD, WxGsonBuilder.create().toJson(data)); | ||||||
|     this.mainService.post(url, WxGsonBuilder.create().toJson(data)); |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,8 +1,16 @@ | |||||||
| package me.chanjar.weixin.cp.api.impl; | package me.chanjar.weixin.cp.api.impl; | ||||||
|  |  | ||||||
|  |  | ||||||
| import java.io.IOException; | import com.google.gson.JsonObject; | ||||||
|  | import com.google.gson.JsonParser; | ||||||
|  | import me.chanjar.weixin.common.WxType; | ||||||
|  | import me.chanjar.weixin.common.error.WxError; | ||||||
|  | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
|  | import me.chanjar.weixin.common.util.http.HttpType; | ||||||
|  | import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | ||||||
|  | import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | ||||||
|  | import me.chanjar.weixin.cp.api.WxCpTpService; | ||||||
|  | import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; | ||||||
| import org.apache.http.Consts; | import org.apache.http.Consts; | ||||||
| import org.apache.http.HttpHost; | import org.apache.http.HttpHost; | ||||||
| import org.apache.http.client.config.RequestConfig; | import org.apache.http.client.config.RequestConfig; | ||||||
| @ -12,20 +20,14 @@ import org.apache.http.entity.StringEntity; | |||||||
| import org.apache.http.impl.client.BasicResponseHandler; | import org.apache.http.impl.client.BasicResponseHandler; | ||||||
| import org.apache.http.impl.client.CloseableHttpClient; | import org.apache.http.impl.client.CloseableHttpClient; | ||||||
|  |  | ||||||
| import com.google.gson.JsonObject; | import java.io.IOException; | ||||||
| import com.google.gson.JsonParser; |  | ||||||
|  |  | ||||||
| import me.chanjar.weixin.common.WxType; |  | ||||||
| import me.chanjar.weixin.common.error.WxError; |  | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; |  | ||||||
| import me.chanjar.weixin.common.util.http.HttpType; |  | ||||||
| import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; |  | ||||||
| import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; |  | ||||||
| import me.chanjar.weixin.cp.config.WxCpTpConfigStorage; |  | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @author someone | ||||||
|  |  */ | ||||||
| public class WxCpTpServiceApacheHttpClientImpl extends BaseWxCpTpServiceImpl<CloseableHttpClient, HttpHost> { | public class WxCpTpServiceApacheHttpClientImpl extends BaseWxCpTpServiceImpl<CloseableHttpClient, HttpHost> { | ||||||
|   protected CloseableHttpClient httpClient; |   private CloseableHttpClient httpClient; | ||||||
|   protected HttpHost httpProxy; |   private HttpHost httpProxy; | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public CloseableHttpClient getRequestHttpClient() { |   public CloseableHttpClient getRequestHttpClient() { | ||||||
| @ -49,9 +51,8 @@ public class WxCpTpServiceApacheHttpClientImpl extends BaseWxCpTpServiceImpl<Clo | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     synchronized (this.globalSuiteAccessTokenRefreshLock) { |     synchronized (this.globalSuiteAccessTokenRefreshLock) { | ||||||
|       String url = "https://qyapi.weixin.qq.com/cgi-bin/service/get_suite_token"; |  | ||||||
|       try { |       try { | ||||||
|     	HttpPost httpPost = new HttpPost(url); |         HttpPost httpPost = new HttpPost(WxCpTpService.GET_SUITE_TOKEN); | ||||||
|         if (this.httpProxy != null) { |         if (this.httpProxy != null) { | ||||||
|           RequestConfig config = RequestConfig.custom() |           RequestConfig config = RequestConfig.custom() | ||||||
|             .setProxy(this.httpProxy).build(); |             .setProxy(this.httpProxy).build(); | ||||||
| @ -88,8 +89,7 @@ public class WxCpTpServiceApacheHttpClientImpl extends BaseWxCpTpServiceImpl<Clo | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void initHttp() { |   public void initHttp() { | ||||||
|     ApacheHttpClientBuilder apacheHttpClientBuilder = this.configStorage |     ApacheHttpClientBuilder apacheHttpClientBuilder = this.configStorage.getApacheHttpClientBuilder(); | ||||||
|       .getApacheHttpClientBuilder(); |  | ||||||
|     if (null == apacheHttpClientBuilder) { |     if (null == apacheHttpClientBuilder) { | ||||||
|       apacheHttpClientBuilder = DefaultApacheHttpClientBuilder.get(); |       apacheHttpClientBuilder = DefaultApacheHttpClientBuilder.get(); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | |||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| public class WxCpUserServiceImpl implements WxCpUserService { | public class WxCpUserServiceImpl implements WxCpUserService { | ||||||
|   private WxCpService mainService; |   private final WxCpService mainService; | ||||||
|  |  | ||||||
|   public WxCpUserServiceImpl(WxCpService mainService) { |   public WxCpUserServiceImpl(WxCpService mainService) { | ||||||
|     this.mainService = mainService; |     this.mainService = mainService; | ||||||
| @ -34,50 +34,44 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void authenticate(String userId) throws WxErrorException { |   public void authenticate(String userId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?userid=" + userId; |     this.mainService.get(WxCpUserService.URL_AUTHENTICATE + userId, null); | ||||||
|     this.mainService.get(url, null); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void create(WxCpUser user) throws WxErrorException { |   public void create(WxCpUser user) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/create"; |     this.mainService.post(WxCpUserService.URL_USER_CREATE, user.toJson()); | ||||||
|     this.mainService.post(url, user.toJson()); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void update(WxCpUser user) throws WxErrorException { |   public void update(WxCpUser user) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/update"; |     this.mainService.post(WxCpUserService.URL_USER_UPDATE, user.toJson()); | ||||||
|     this.mainService.post(url, user.toJson()); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void delete(String... userIds) throws WxErrorException { |   public void delete(String... userIds) throws WxErrorException { | ||||||
|     if (userIds.length == 1) { |     if (userIds.length == 1) { | ||||||
|       String url = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?userid=" + userIds[0]; |       this.mainService.get(WxCpUserService.URL_USER_DELETE + userIds[0], null); | ||||||
|       this.mainService.get(url, null); |  | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete"; |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
|     JsonArray jsonArray = new JsonArray(); |     JsonArray jsonArray = new JsonArray(); | ||||||
|     for (String userid : userIds) { |     for (String userId : userIds) { | ||||||
|       jsonArray.add(new JsonPrimitive(userid)); |       jsonArray.add(new JsonPrimitive(userId)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     jsonObject.add("useridlist", jsonArray); |     jsonObject.add("useridlist", jsonArray); | ||||||
|     this.mainService.post(url, jsonObject.toString()); |     this.mainService.post(WxCpUserService.URL_USER_BATCH_DELETE, jsonObject.toString()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxCpUser getById(String userid) throws WxErrorException { |   public WxCpUser getById(String userid) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?userid=" + userid; |     String responseContent = this.mainService.get(WxCpUserService.URL_USER_GET + userid, null); | ||||||
|     String responseContent = this.mainService.get(url, null); |  | ||||||
|     return WxCpUser.fromJson(responseContent); |     return WxCpUser.fromJson(responseContent); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpUser> listByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException { |   public List<WxCpUser> listByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/list?department_id=" + departId; |  | ||||||
|     String params = ""; |     String params = ""; | ||||||
|     if (fetchChild != null) { |     if (fetchChild != null) { | ||||||
|       params += "&fetch_child=" + (fetchChild ? "1" : "0"); |       params += "&fetch_child=" + (fetchChild ? "1" : "0"); | ||||||
| @ -88,7 +82,7 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||||||
|       params += "&status=0"; |       params += "&status=0"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     String responseContent = this.mainService.get(url, params); |     String responseContent = this.mainService.get(WxCpUserService.URL_USER_LIST + departId, params); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return WxCpGsonBuilder.create() |     return WxCpGsonBuilder.create() | ||||||
|       .fromJson(tmpJsonElement.getAsJsonObject().get("userlist"), |       .fromJson(tmpJsonElement.getAsJsonObject().get("userlist"), | ||||||
| @ -99,7 +93,6 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException { |   public List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?department_id=" + departId; |  | ||||||
|     String params = ""; |     String params = ""; | ||||||
|     if (fetchChild != null) { |     if (fetchChild != null) { | ||||||
|       params += "&fetch_child=" + (fetchChild ? "1" : "0"); |       params += "&fetch_child=" + (fetchChild ? "1" : "0"); | ||||||
| @ -110,7 +103,7 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||||||
|       params += "&status=0"; |       params += "&status=0"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     String responseContent = this.mainService.get(url, params); |     String responseContent = this.mainService.get(WxCpUserService.URL_USER_SIMPLE_LIST + departId, params); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return WxCpGsonBuilder.create() |     return WxCpGsonBuilder.create() | ||||||
|       .fromJson( |       .fromJson( | ||||||
| @ -122,7 +115,6 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds) throws WxErrorException { |   public WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/batch/invite"; |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
|     if (userIds != null) { |     if (userIds != null) { | ||||||
|       JsonArray jsonArray = new JsonArray(); |       JsonArray jsonArray = new JsonArray(); | ||||||
| @ -148,19 +140,18 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||||||
|       jsonObject.add("tag", jsonArray); |       jsonObject.add("tag", jsonArray); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return WxCpInviteResult.fromJson(this.mainService.post(url, jsonObject.toString())); |     return WxCpInviteResult.fromJson(this.mainService.post(WxCpUserService.URL_BATCH_INVITE, jsonObject.toString())); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { |   public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_openid"; |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
|     jsonObject.addProperty("userid", userId); |     jsonObject.addProperty("userid", userId); | ||||||
|     if (agentId != null) { |     if (agentId != null) { | ||||||
|       jsonObject.addProperty("agentid", agentId); |       jsonObject.addProperty("agentid", agentId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); |     String responseContent = this.mainService.post(WxCpUserService.URL_CONVERT_TO_OPENID, jsonObject.toString()); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     Map<String, String> result = Maps.newHashMap(); |     Map<String, String> result = Maps.newHashMap(); | ||||||
|     if (tmpJsonElement.getAsJsonObject().get("openid") != null) { |     if (tmpJsonElement.getAsJsonObject().get("openid") != null) { | ||||||
| @ -176,18 +167,16 @@ public class WxCpUserServiceImpl implements WxCpUserService { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public String openid2UserId(String openid) throws WxErrorException { |   public String openid2UserId(String openid) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid"; |  | ||||||
|     JsonObject jsonObject = new JsonObject(); |     JsonObject jsonObject = new JsonObject(); | ||||||
|     jsonObject.addProperty("openid", openid); |     jsonObject.addProperty("openid", openid); | ||||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); |     String responseContent = this.mainService.post(WxCpUserService.URL_CONVERT_TO_USERID, jsonObject.toString()); | ||||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||||
|     return tmpJsonElement.getAsJsonObject().get("userid").getAsString(); |     return tmpJsonElement.getAsJsonObject().get("userid").getAsString(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException { |   public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException { | ||||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/crm/get_external_contact?external_userid=" + userId; |     String responseContent = this.mainService.get(WxCpUserService.URL_GET_EXTERNAL_CONTACT + userId, null); | ||||||
|     String responseContent = this.mainService.get(url, null); |  | ||||||
|     return WxCpUserExternalContactInfo.fromJson(responseContent); |     return WxCpUserExternalContactInfo.fromJson(responseContent); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -29,19 +29,19 @@ public class WxCpTagGetResult implements Serializable { | |||||||
|   private String errmsg; |   private String errmsg; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 用户列表 |    * 用户列表. | ||||||
|    */ |    */ | ||||||
|   @SerializedName("userlist") |   @SerializedName("userlist") | ||||||
|   private List<WxCpUser> userlist; |   private List<WxCpUser> userlist; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 部门列表 |    * 部门列表. | ||||||
|    */ |    */ | ||||||
|   @SerializedName("partylist") |   @SerializedName("partylist") | ||||||
|   private List<Integer> partylist; |   private List<Integer> partylist; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 标签名称 |    * 标签名称. | ||||||
|    */ |    */ | ||||||
|   @SerializedName("tagname") |   @SerializedName("tagname") | ||||||
|   private String tagname; |   private String tagname; | ||||||
|  | |||||||
| @ -6,7 +6,6 @@ import me.chanjar.weixin.cp.api.ApiTestModule; | |||||||
| import me.chanjar.weixin.cp.api.WxCpAgentService; | import me.chanjar.weixin.cp.api.WxCpAgentService; | ||||||
| import me.chanjar.weixin.cp.api.WxCpService; | import me.chanjar.weixin.cp.api.WxCpService; | ||||||
| import me.chanjar.weixin.cp.bean.WxCpAgent; | import me.chanjar.weixin.cp.bean.WxCpAgent; | ||||||
| import org.testng.Assert; |  | ||||||
| import org.testng.annotations.Guice; | import org.testng.annotations.Guice; | ||||||
| import org.testng.annotations.Test; | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
| @ -71,7 +70,7 @@ public class WxCpAgentServiceImplTest { | |||||||
|     @Test |     @Test | ||||||
|     public void testGet() throws Exception { |     public void testGet() throws Exception { | ||||||
|       String returnJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"agentid\": 9,\"name\": \"测试应用\",\"square_logo_url\": \"http://wx.qlogo.cn/mmhead/alksjf;lasdjf;lasjfuodiuj3rj2o34j/0\",\"description\": \"这是一个企业号应用\",\"allow_userinfos\": {\"user\": [{\"userid\": \"0009854\"}, {\"userid\": \"1723\"}, {\"userid\": \"5625\"}]},\"allow_partys\": {\"partyid\": [42762742]},\"allow_tags\": {\"tagid\": [23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7]},\"close\": 0,\"redirect_domain\": \"weixin.com.cn\",\"report_location_flag\": 0,\"isreportenter\": 0,\"home_url\": \"\"}"; |       String returnJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"agentid\": 9,\"name\": \"测试应用\",\"square_logo_url\": \"http://wx.qlogo.cn/mmhead/alksjf;lasdjf;lasjfuodiuj3rj2o34j/0\",\"description\": \"这是一个企业号应用\",\"allow_userinfos\": {\"user\": [{\"userid\": \"0009854\"}, {\"userid\": \"1723\"}, {\"userid\": \"5625\"}]},\"allow_partys\": {\"partyid\": [42762742]},\"allow_tags\": {\"tagid\": [23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7]},\"close\": 0,\"redirect_domain\": \"weixin.com.cn\",\"report_location_flag\": 0,\"isreportenter\": 0,\"home_url\": \"\"}"; | ||||||
|       when(wxService.get("https://qyapi.weixin.qq.com/cgi-bin/agent/get?agentid=9", null)).thenReturn(returnJson); |       when(wxService.get(String.format(WxCpAgentService.GET_AGENT, 9), null)).thenReturn(returnJson); | ||||||
|       when(wxService.getAgentService()).thenReturn(new WxCpAgentServiceImpl(wxService)); |       when(wxService.getAgentService()).thenReturn(new WxCpAgentServiceImpl(wxService)); | ||||||
|  |  | ||||||
|       WxCpAgentService wxAgentService = this.wxService.getAgentService(); |       WxCpAgentService wxAgentService = this.wxService.getAgentService(); | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat; | |||||||
|  * @date 2019-04-20 13:46 |  * @date 2019-04-20 13:46 | ||||||
|  */ |  */ | ||||||
| @Guice(modules = ApiTestModule.class) | @Guice(modules = ApiTestModule.class) | ||||||
| public class WxCpOAServiceImplTest { | public class WxCpOaServiceImplTest { | ||||||
|   @Inject |   @Inject | ||||||
|   protected WxCpService wxService; |   protected WxCpService wxService; | ||||||
| 
 | 
 | ||||||
| @ -22,10 +22,10 @@ import static org.testng.Assert.assertNotEquals; | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * <pre> |  * <pre> | ||||||
|  * |  | ||||||
|  * Created by Binary Wang on 2017-6-25. |  * Created by Binary Wang on 2017-6-25. | ||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  | ||||||
|  * </pre> |  * </pre> | ||||||
|  |  * | ||||||
|  |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| @Guice(modules = ApiTestModule.class) | @Guice(modules = ApiTestModule.class) | ||||||
| public class WxCpTagServiceImplTest { | public class WxCpTagServiceImplTest { | ||||||
| @ -35,7 +35,7 @@ public class WxCpTagServiceImplTest { | |||||||
|   @Inject |   @Inject | ||||||
|   protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; |   protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; | ||||||
|  |  | ||||||
|   protected String tagId; |   private String tagId; | ||||||
|  |  | ||||||
|   @Test |   @Test | ||||||
|   public void testCreate() throws Exception { |   public void testCreate() throws Exception { | ||||||
| @ -83,7 +83,7 @@ public class WxCpTagServiceImplTest { | |||||||
|   public void testGet() throws WxErrorException { |   public void testGet() throws WxErrorException { | ||||||
|     String apiResultJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"userlist\": [{\"userid\": \"0124035\",\"name\": \"王五\"},{\"userid\": \"0114035\",\"name\": \"梦雪\"}],\"partylist\": [9576,9567,9566],\"tagname\": \"测试标签-001\"}"; |     String apiResultJson = "{\"errcode\": 0,\"errmsg\": \"ok\",\"userlist\": [{\"userid\": \"0124035\",\"name\": \"王五\"},{\"userid\": \"0114035\",\"name\": \"梦雪\"}],\"partylist\": [9576,9567,9566],\"tagname\": \"测试标签-001\"}"; | ||||||
|     WxCpService wxService = mock(WxCpService.class); |     WxCpService wxService = mock(WxCpService.class); | ||||||
|     when(wxService.get("https://qyapi.weixin.qq.com/cgi-bin/tag/get?tagId=150", null)).thenReturn(apiResultJson); |     when(wxService.get(String.format(WxCpTagService.TAG_GET, 150), null)).thenReturn(apiResultJson); | ||||||
|     when(wxService.getTagService()).thenReturn(new WxCpTagServiceImpl(wxService)); |     when(wxService.getTagService()).thenReturn(new WxCpTagServiceImpl(wxService)); | ||||||
|  |  | ||||||
|     WxCpTagService wxCpTagService = wxService.getTagService(); |     WxCpTagService wxCpTagService = wxService.getTagService(); | ||||||
| @ -96,7 +96,6 @@ public class WxCpTagServiceImplTest { | |||||||
|     assertEquals(3, wxCpTagGetResult.getPartylist().size()); |     assertEquals(3, wxCpTagGetResult.getPartylist().size()); | ||||||
|     assertEquals("测试标签-001", wxCpTagGetResult.getTagname()); |     assertEquals("测试标签-001", wxCpTagGetResult.getTagname()); | ||||||
|  |  | ||||||
|  |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ package com.github.binarywang.wxpay.bean.request; | |||||||
| import java.io.Serializable; | import java.io.Serializable; | ||||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||||
|  |  | ||||||
|  | import lombok.experimental.Accessors; | ||||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||||
|  |  | ||||||
| import com.github.binarywang.wxpay.config.WxPayConfig; | import com.github.binarywang.wxpay.config.WxPayConfig; | ||||||
| @ -27,6 +28,7 @@ import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.ALL_S | |||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
|  | @Accessors(chain = true) | ||||||
| public abstract class BaseWxPayRequest implements Serializable { | public abstract class BaseWxPayRequest implements Serializable { | ||||||
|   private static final long serialVersionUID = -4766915659779847060L; |   private static final long serialVersionUID = -4766915659779847060L; | ||||||
|  |  | ||||||
|  | |||||||
| @ -5,6 +5,7 @@ import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType; | |||||||
| import com.github.binarywang.wxpay.exception.WxPayException; | import com.github.binarywang.wxpay.exception.WxPayException; | ||||||
| import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||||
| import lombok.*; | import lombok.*; | ||||||
|  | import lombok.experimental.Accessors; | ||||||
| import me.chanjar.weixin.common.annotation.Required; | import me.chanjar.weixin.common.annotation.Required; | ||||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||||
|  |  | ||||||
| @ -23,6 +24,7 @@ import org.apache.commons.lang3.StringUtils; | |||||||
| @NoArgsConstructor | @NoArgsConstructor | ||||||
| @AllArgsConstructor | @AllArgsConstructor | ||||||
| @XStreamAlias("xml") | @XStreamAlias("xml") | ||||||
|  | @Accessors(chain = true) | ||||||
| public class WxPayUnifiedOrderRequest extends BaseWxPayRequest { | public class WxPayUnifiedOrderRequest extends BaseWxPayRequest { | ||||||
|   private static final long serialVersionUID = 4611350167813931828L; |   private static final long serialVersionUID = 4611350167813931828L; | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang