🎨 重构代码,抽取公共方法到接口

This commit is contained in:
Binary Wang
2020-04-25 21:53:05 +08:00
parent 6da4b4fca1
commit ebe46822ef
6 changed files with 89 additions and 69 deletions

View File

@@ -3,6 +3,7 @@ package cn.binarywang.wx.miniapp.api;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.service.WxService;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
@@ -10,7 +11,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
/**
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public interface WxMaService {
public interface WxMaService extends WxService {
/**
* 获取access_token.
*/
@@ -99,21 +100,6 @@ public interface WxMaService {
*/
String getPaidUnionId(String openid, String transactionId, String mchId, String outTradeNo) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的GET请求.
*/
String get(String url, String queryParam) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的POST请求.
*/
String post(String url, String postData) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的POST请求.
*/
String post(String url, Object obj) throws WxErrorException;
/**
* <pre>
* Service没有实现某个API的时候可以用这个

View File

@@ -44,23 +44,23 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
private HttpHost httpProxy;
private WxMaConfig wxMaConfig;
private WxMaMsgService kefuService = new WxMaMsgServiceImpl(this);
private WxMaMediaService materialService = new WxMaMediaServiceImpl(this);
private WxMaUserService userService = new WxMaUserServiceImpl(this);
private WxMaQrcodeService qrCodeService = new WxMaQrcodeServiceImpl(this);
private WxMaTemplateService templateService = new WxMaTemplateServiceImpl(this);
private WxMaAnalysisService analysisService = new WxMaAnalysisServiceImpl(this);
private WxMaCodeService codeService = new WxMaCodeServiceImpl(this);
private WxMaSettingService settingService = new WxMaSettingServiceImpl(this);
private WxMaJsapiService jsapiService = new WxMaJsapiServiceImpl(this);
private WxMaShareService shareService = new WxMaShareServiceImpl(this);
private WxMaRunService runService = new WxMaRunServiceImpl(this);
private WxMaSecCheckService secCheckService = new WxMaSecCheckServiceImpl(this);
private WxMaPluginService pluginService = new WxMaPluginServiceImpl(this);
private WxMaExpressService expressService = new WxMaExpressServiceImpl(this);
private WxMaSubscribeService subscribeService = new WxMaSubscribeServiceImpl(this);
private WxMaCloudService cloudService = new WxMaCloudServiceImpl(this);
private WxMaLiveService liveService = new WxMaLiveServiceImpl(this);
private final WxMaMsgService kefuService = new WxMaMsgServiceImpl(this);
private final WxMaMediaService materialService = new WxMaMediaServiceImpl(this);
private final WxMaUserService userService = new WxMaUserServiceImpl(this);
private final WxMaQrcodeService qrCodeService = new WxMaQrcodeServiceImpl(this);
private final WxMaTemplateService templateService = new WxMaTemplateServiceImpl(this);
private final WxMaAnalysisService analysisService = new WxMaAnalysisServiceImpl(this);
private final WxMaCodeService codeService = new WxMaCodeServiceImpl(this);
private final WxMaSettingService settingService = new WxMaSettingServiceImpl(this);
private final WxMaJsapiService jsapiService = new WxMaJsapiServiceImpl(this);
private final WxMaShareService shareService = new WxMaShareServiceImpl(this);
private final WxMaRunService runService = new WxMaRunServiceImpl(this);
private final WxMaSecCheckService secCheckService = new WxMaSecCheckServiceImpl(this);
private final WxMaPluginService pluginService = new WxMaPluginServiceImpl(this);
private final WxMaExpressService expressService = new WxMaExpressServiceImpl(this);
private final WxMaSubscribeService subscribeService = new WxMaSubscribeServiceImpl(this);
private final WxMaCloudService cloudService = new WxMaCloudServiceImpl(this);
private final WxMaLiveService liveService = new WxMaLiveServiceImpl(this);
private int retrySleepMillis = 1000;
private int maxRetryTimes = 5;