mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-01 03:25:35 +08:00 
			
		
		
		
	🎨 规范化部分代码格式
This commit is contained in:
		| @ -36,34 +36,36 @@ import java.util.Map; | ||||
| import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.*; | ||||
|  | ||||
| /** | ||||
|  * . | ||||
|  * | ||||
|  * @author chanjarster | ||||
|  */ | ||||
| @Slf4j | ||||
| public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestHttp<H, P> { | ||||
|   private WxCpUserService       userService       = new WxCpUserServiceImpl(this); | ||||
|   private WxCpChatService       chatService       = new WxCpChatServiceImpl(this); | ||||
|   private WxCpUserService userService = new WxCpUserServiceImpl(this); | ||||
|   private WxCpChatService chatService = new WxCpChatServiceImpl(this); | ||||
|   private WxCpDepartmentService departmentService = new WxCpDepartmentServiceImpl(this); | ||||
|   private WxCpMediaService      mediaService      = new WxCpMediaServiceImpl(this); | ||||
|   private WxCpMenuService       menuService       = new WxCpMenuServiceImpl(this); | ||||
|   private WxCpOAuth2Service     oauth2Service     = new WxCpOAuth2ServiceImpl(this); | ||||
|   private WxCpTagService        tagService        = new WxCpTagServiceImpl(this); | ||||
|   private WxCpAgentService      agentService      = new WxCpAgentServiceImpl(this); | ||||
|   private WxCpOaService         oaService         = new WxCpOaServiceImpl(this); | ||||
|   private WxCpTaskCardService   taskCardService   = new WxCpTaskCardServiceImpl(this); | ||||
|   private WxCpMediaService mediaService = new WxCpMediaServiceImpl(this); | ||||
|   private WxCpMenuService menuService = new WxCpMenuServiceImpl(this); | ||||
|   private WxCpOAuth2Service oauth2Service = new WxCpOAuth2ServiceImpl(this); | ||||
|   private WxCpTagService tagService = new WxCpTagServiceImpl(this); | ||||
|   private WxCpAgentService agentService = new WxCpAgentServiceImpl(this); | ||||
|   private WxCpOaService oaService = new WxCpOaServiceImpl(this); | ||||
|   private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this); | ||||
|   private WxCpExternalContactService externalContactService = new WxCpExternalContactServiceImpl(this); | ||||
|  | ||||
|   /** | ||||
|    * 全局的是否正在刷新access token的锁 | ||||
|    * 全局的是否正在刷新access token的锁. | ||||
|    */ | ||||
|   protected final Object globalAccessTokenRefreshLock = new Object(); | ||||
|  | ||||
|   /** | ||||
|    * 全局的是否正在刷新jsapi_ticket的锁 | ||||
|    * 全局的是否正在刷新jsapi_ticket的锁. | ||||
|    */ | ||||
|   protected final Object globalJsapiTicketRefreshLock = new Object(); | ||||
|  | ||||
|   /** | ||||
|    * 全局的是否正在刷新agent的jsapi_ticket的锁 | ||||
|    * 全局的是否正在刷新agent的jsapi_ticket的锁. | ||||
|    */ | ||||
|   protected final Object globalAgentJsapiTicketRefreshLock = new Object(); | ||||
|  | ||||
| @ -72,7 +74,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | ||||
|   private WxSessionManager sessionManager = new StandardSessionManager(); | ||||
|  | ||||
|   /** | ||||
|    * 临时文件目录 | ||||
|    * 临时文件目录. | ||||
|    */ | ||||
|   private File tmpDirFile; | ||||
|   private int retrySleepMillis = 1000; | ||||
| @ -183,8 +185,8 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | ||||
|     params.put("js_code", jsCode); | ||||
|     params.put("grant_type", "authorization_code"); | ||||
|  | ||||
|     String result = this.get(this.configStorage.getApiUrl(JSCODE_TO_SESSION), Joiner.on("&").withKeyValueSeparator("=").join(params)); | ||||
|     return WxCpMaJsCode2SessionResult.fromJson(result); | ||||
|     final String url = this.configStorage.getApiUrl(JSCODE_TO_SESSION); | ||||
|     return WxCpMaJsCode2SessionResult.fromJson(this.get(url, Joiner.on("&").withKeyValueSeparator("=").join(params))); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|  | ||||
| @ -26,6 +26,8 @@ import java.util.HashMap; | ||||
| import java.util.Map; | ||||
|  | ||||
| /** | ||||
|  * . | ||||
|  * | ||||
|  * @author zhenjun cai | ||||
|  */ | ||||
| @Slf4j | ||||
| @ -73,7 +75,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | ||||
|  | ||||
|   @Override | ||||
|   public String getSuiteTicket(boolean forceRefresh) throws WxErrorException { | ||||
| //	  suite ticket由微信服务器推送,不能强制刷新 | ||||
| //     suite ticket由微信服务器推送,不能强制刷新 | ||||
| //    if (forceRefresh) { | ||||
| //      this.configStorage.expireSuiteTicket(); | ||||
| //    } | ||||
| @ -93,8 +95,8 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | ||||
|     params.put("js_code", jsCode); | ||||
|     params.put("grant_type", "authorization_code"); | ||||
|  | ||||
|     String result = this.get(configStorage.getApiUrl(WxCpApiPathConsts.Tp.JSCODE_TO_SESSION), Joiner.on("&").withKeyValueSeparator("=").join(params)); | ||||
|     return WxCpMaJsCode2SessionResult.fromJson(result); | ||||
|     final String url = configStorage.getApiUrl(WxCpApiPathConsts.Tp.JSCODE_TO_SESSION); | ||||
|     return WxCpMaJsCode2SessionResult.fromJson(this.get(url, Joiner.on("&").withKeyValueSeparator("=").join(params))); | ||||
|   } | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -36,8 +36,8 @@ public class WxCpAgentServiceImpl implements WxCpAgentService { | ||||
|       throw new IllegalArgumentException("缺少agentid参数"); | ||||
|     } | ||||
|  | ||||
|     String responseContent = this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_GET), agentId), null); | ||||
|     return WxCpAgent.fromJson(responseContent); | ||||
|     final String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_GET), agentId); | ||||
|     return WxCpAgent.fromJson(this.mainService.get(url, null)); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|  | ||||
| @ -43,13 +43,14 @@ public class WxCpChatServiceImpl implements WxCpChatService { | ||||
|     if (StringUtils.isNotBlank(chatId)) { | ||||
|       data.put("chatid", chatId); | ||||
|     } | ||||
|     String result = this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_CREATE), WxGsonBuilder.create().toJson(data)); | ||||
|     final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_CREATE); | ||||
|     String result = this.cpService.post(url, WxGsonBuilder.create().toJson(data)); | ||||
|     return new JsonParser().parse(result).getAsJsonObject().get("chatid").getAsString(); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public String create(String name, String owner, List<String> users, String chatId) throws WxErrorException { | ||||
|     return chatCreate(name, owner, users, chatId); | ||||
|     return this.chatCreate(name, owner, users, chatId); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
| @ -72,24 +73,27 @@ public class WxCpChatServiceImpl implements WxCpChatService { | ||||
|       data.put("del_user_list", usersToDelete); | ||||
|     } | ||||
|  | ||||
|     this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_UPDATE), WxGsonBuilder.create().toJson(data)); | ||||
|     final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_UPDATE); | ||||
|     this.cpService.post(url, WxGsonBuilder.create().toJson(data)); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) throws WxErrorException { | ||||
|   public void update(String chatId, String name, String owner, List<String> usersToAdd, List<String> usersToDelete) | ||||
|     throws WxErrorException { | ||||
|     chatUpdate(chatId, name, owner, usersToAdd, usersToDelete); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public WxCpChat chatGet(String chatId) throws WxErrorException { | ||||
|     String result = this.cpService.get(this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_GET_CHATID + chatId), null); | ||||
|     return WxCpGsonBuilder.create() | ||||
|       .fromJson(JSON_PARSER.parse(result).getAsJsonObject().getAsJsonObject("chat_info").toString(), WxCpChat.class); | ||||
|     final String url = this.cpService.getWxCpConfigStorage().getApiUrl(APPCHAT_GET_CHATID + chatId); | ||||
|     String result = this.cpService.get(url, null); | ||||
|     final String chatInfo = JSON_PARSER.parse(result).getAsJsonObject().getAsJsonObject("chat_info").toString(); | ||||
|     return WxCpGsonBuilder.create().fromJson(chatInfo, WxCpChat.class); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public WxCpChat get(String chatId) throws WxErrorException { | ||||
|     return chatGet(chatId); | ||||
|     return this.chatGet(chatId); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|  | ||||
| @ -20,22 +20,22 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic | ||||
|  | ||||
|   @Override | ||||
|   public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException { | ||||
|     String responseContent = this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId), null); | ||||
|  | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId); | ||||
|     String responseContent = this.mainService.get(url, null); | ||||
|     return WxCpUserExternalContactInfo.fromJson(responseContent); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public List<String> listExternalContacts(String userId) throws WxErrorException { | ||||
|     String responseContent = this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(LIST_EXTERNAL_CONTACT + userId), null); | ||||
|     WxCpUserExternalContactList list = WxCpUserExternalContactList.fromJson(responseContent); | ||||
|     return list.getExternalUserId(); | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_EXTERNAL_CONTACT + userId); | ||||
|     String responseContent = this.mainService.get(url, null); | ||||
|     return WxCpUserExternalContactList.fromJson(responseContent).getExternalUserId(); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public List<String> listFollowUser() throws WxErrorException { | ||||
|     String responseContent = this.mainService.get(this.mainService.getWxCpConfigStorage().getApiUrl(GET_FOLLOW_USER_LIST), null); | ||||
|     WxCpUserWithExternalPermission list = WxCpUserWithExternalPermission.fromJson(responseContent); | ||||
|     return list.getFollowUser(); | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_FOLLOW_USER_LIST); | ||||
|     String responseContent = this.mainService.get(url, null); | ||||
|     return WxCpUserWithExternalPermission.fromJson(responseContent).getFollowUser(); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -6,6 +6,7 @@ import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.common.util.fs.FileUtils; | ||||
| import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; | ||||
| import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; | ||||
| import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
| import me.chanjar.weixin.cp.api.WxCpMediaService; | ||||
| import me.chanjar.weixin.cp.api.WxCpService; | ||||
| import me.chanjar.weixin.cp.constant.WxCpApiPathConsts; | ||||
| @ -59,8 +60,8 @@ public class WxCpMediaServiceImpl implements WxCpMediaService { | ||||
|  | ||||
|   @Override | ||||
|   public String uploadImg(File file) throws WxErrorException { | ||||
|     final WxMediaUploadResult result = this.mainService | ||||
|       .execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), this.mainService.getWxCpConfigStorage().getApiUrl(IMG_UPLOAD), file); | ||||
|     return result.getUrl(); | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(IMG_UPLOAD); | ||||
|     return this.mainService.execute(MediaUploadRequestExecutor.create(this.mainService.getRequestHttp()), url, file) | ||||
|       .getUrl(); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -22,6 +22,8 @@ import java.util.List; | ||||
| import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.*; | ||||
|  | ||||
| /** | ||||
|  * . | ||||
|  * | ||||
|  * @author Element | ||||
|  * @date 2019-04-06 11:20 | ||||
|  */ | ||||
| @ -60,7 +62,8 @@ public class WxCpOaServiceImpl implements WxCpOaService { | ||||
|  | ||||
|     jsonObject.add("useridlist", jsonArray); | ||||
|  | ||||
|     String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_DATA), jsonObject.toString()); | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_DATA); | ||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); | ||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||
|     return WxCpGsonBuilder.create() | ||||
|       .fromJson( | ||||
| @ -89,7 +92,8 @@ public class WxCpOaServiceImpl implements WxCpOaService { | ||||
|     jsonObject.addProperty("datetime", datetime.getTime() / 1000L); | ||||
|     jsonObject.add("useridlist", jsonArray); | ||||
|  | ||||
|     String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_OPTION), jsonObject.toString()); | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CHECKIN_OPTION); | ||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); | ||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||
|  | ||||
|     return WxCpGsonBuilder.create() | ||||
| @ -109,12 +113,14 @@ public class WxCpOaServiceImpl implements WxCpOaService { | ||||
|       jsonObject.addProperty("next_spnum", nextSpnum); | ||||
|     } | ||||
|  | ||||
|     String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DATA), jsonObject.toString()); | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DATA); | ||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); | ||||
|     return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDataResult.class); | ||||
|   } | ||||
|  | ||||
|   @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 { | ||||
|     JsonObject jsonObject = new JsonObject(); | ||||
|  | ||||
|     if (offset == null) { | ||||
| @ -141,14 +147,13 @@ public class WxCpOaServiceImpl implements WxCpOaService { | ||||
|       jsonObject.addProperty("end_time", endtimestamp); | ||||
|     } | ||||
|  | ||||
|     String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(GET_DIAL_RECORD), jsonObject.toString()); | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_DIAL_RECORD); | ||||
|     String responseContent = this.mainService.post(url, jsonObject.toString()); | ||||
|     JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||||
|  | ||||
|     return WxCpGsonBuilder.create() | ||||
|       .fromJson( | ||||
|         tmpJsonElement.getAsJsonObject().get("record"), | ||||
|         new TypeToken<List<WxCpDialRecord>>() { | ||||
|         }.getType() | ||||
|       ); | ||||
|     return WxCpGsonBuilder.create().fromJson(tmpJsonElement.getAsJsonObject().get("record"), | ||||
|       new TypeToken<List<WxCpDialRecord>>() { | ||||
|       }.getType() | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang