🎨 精简代码,移除无用过期接口代码

This commit is contained in:
Binary Wang
2020-08-23 17:22:35 +08:00
parent 6d996f20b9
commit b5956fb298
28 changed files with 113 additions and 827 deletions

View File

@@ -32,20 +32,6 @@ public interface WxMaMsgService {
*/
boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException;
/**
* <pre>
* 发送模板消息
* 详情请见: <a href="https://developers.weixin.qq.com/miniprogram/dev/api-backend/templateMessage.send.html">发送模板消息</a>
* 接口url格式https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
* 小程序模板消息接口将于2020年1月10日下线开发者可使用订阅消息功能
* </pre>
*
* @param templateMessage 模版消息
* @throws WxErrorException .
*/
@Deprecated
void sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException;
/**
* <pre>
* 发送订阅消息

View File

@@ -229,13 +229,6 @@ public interface WxMaService extends WxService {
*/
WxMaQrcodeService getQrcodeService();
/**
* 返回模板配置相关接口方法的实现类对象, 以方便调用其各个接口.
*
* @return WxMaTemplateService
*/
WxMaTemplateService getTemplateService();
/**
* 返回订阅消息配置相关接口方法的实现类对象, 以方便调用其各个接口.
*

View File

@@ -1,90 +0,0 @@
package cn.binarywang.wx.miniapp.api;
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateAddResult;
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryGetResult;
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult;
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult;
import me.chanjar.weixin.common.error.WxErrorException;
import java.util.List;
/**
* @author IOManlewis.lynn1006@gmail.com
*/
@Deprecated
public interface WxMaTemplateService {
/**
* 获取小程序模板库标题列表.
*/
String TEMPLATE_LIBRARY_LIST_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list";
/**
* 获取模板库某个模板标题下关键词库.
*/
String TEMPLATE_LIBRARY_KEYWORD_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get";
/**
* 组合模板并添加至帐号下的个人模板库.
*/
String TEMPLATE_ADD_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/add";
/**
* 获取帐号下已存在的模板列表.
*/
String TEMPLATE_LIST_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/list";
/**
* 删除帐号下的某个模板.
*/
String TEMPLATE_DEL_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/template/del";
/**
* <pre>
* 获取小程序模板库标题列表
*
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a>
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list?access_token=ACCESS_TOKEN
* </pre>
*/
WxMaTemplateLibraryListResult findTemplateLibraryList(int offset, int count) throws WxErrorException;
/**
* <pre>
* 获取模板库某个模板标题下关键词库
*
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a>
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token=ACCESS_TOKEN
* </pre>
*/
WxMaTemplateLibraryGetResult findTemplateLibraryKeywordList(String id) throws WxErrorException;
/**
* <pre>
* 组合模板并添加至帐号下的个人模板库
*
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a>
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/add?access_token=ACCESS_TOKEN
* </pre>
*/
WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException;
/**
* <pre>
* 获取帐号下已存在的模板列表
*
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a>
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/list?access_token=ACCESS_TOKEN
* </pre>
*/
WxMaTemplateListResult findTemplateList(int offset, int count) throws WxErrorException;
/**
* <pre>
* 删除帐号下的某个模板
*
* 详情请见: <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500465446_j4CgR&token=&lang=zh_CN">获取小程序模板库标题列表</a>
* 接口url格式: https://api.weixin.qq.com/cgi-bin/wxopen/template/list?access_token=ACCESS_TOKEN
* </pre>
*/
boolean delTemplate(String templateId) throws WxErrorException;
}

View File

@@ -40,13 +40,11 @@ import java.util.concurrent.locks.Lock;
@Slf4j
public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestHttp<H, P> {
private Map<String, WxMaConfig> configMap;
private WxMaConfig wxMaConfig;
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);
@@ -275,9 +273,9 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
/**
* 设置当前的AccessToken
*
* @param resultContent
* @return
* @throws WxErrorException
* @param resultContent 响应内容
* @return access token
* @throws WxErrorException 异常
*/
protected String extractAccessToken(String resultContent) throws WxErrorException {
WxMaConfig config = this.getWxMaConfig();
@@ -399,11 +397,6 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
return this.qrCodeService;
}
@Override
public WxMaTemplateService getTemplateService() {
return this.templateService;
}
@Override
public WxMaSubscribeService getSubscribeService() {
return this.subscribeService;

View File

@@ -17,8 +17,7 @@ import me.chanjar.weixin.common.util.json.GsonParser;
*/
@AllArgsConstructor
public class WxMaMsgServiceImpl implements WxMaMsgService {
private WxMaService wxMaService;
private final WxMaService wxMaService;
@Override
public boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException {
@@ -26,15 +25,6 @@ public class WxMaMsgServiceImpl implements WxMaMsgService {
return responseContent != null;
}
@Override
public void sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException {
String responseContent = this.wxMaService.post(TEMPLATE_MSG_SEND_URL, templateMessage.toJson());
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
}
@Override
public void sendSubscribeMsg(WxMaSubscribeMessage subscribeMessage) throws WxErrorException {
String responseContent = this.wxMaService.post(SUBSCRIBE_MSG_SEND_URL, subscribeMessage.toJson());

View File

@@ -1,58 +0,0 @@
package cn.binarywang.wx.miniapp.api.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.WxMaTemplateService;
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateAddResult;
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryGetResult;
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult;
import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult;
import com.google.common.collect.ImmutableMap;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.util.List;
import java.util.Map;
/**
* @author Binary
*/
@AllArgsConstructor
public class WxMaTemplateServiceImpl implements WxMaTemplateService {
private WxMaService wxMaService;
@Override
public WxMaTemplateLibraryListResult findTemplateLibraryList(int offset, int count) throws WxErrorException {
Map<String, Integer> params = ImmutableMap.of("offset", offset, "count", count);
String responseText = this.wxMaService.post(TEMPLATE_LIBRARY_LIST_URL, WxGsonBuilder.create().toJson(params));
return WxMaTemplateLibraryListResult.fromJson(responseText);
}
@Override
public WxMaTemplateLibraryGetResult findTemplateLibraryKeywordList(String id) throws WxErrorException {
String responseText = this.wxMaService.post(TEMPLATE_LIBRARY_KEYWORD_URL,
WxGsonBuilder.create().toJson(ImmutableMap.of("id", id)));
return WxMaTemplateLibraryGetResult.fromJson(responseText);
}
@Override
public WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException {
String responseText = this.wxMaService.post(TEMPLATE_ADD_URL,
WxGsonBuilder.create().toJson(ImmutableMap.of("id", id, "keyword_id_list", keywordIdList.toArray())));
return WxMaTemplateAddResult.fromJson(responseText);
}
@Override
public WxMaTemplateListResult findTemplateList(int offset, int count) throws WxErrorException {
Map<String, Integer> params = ImmutableMap.of("offset", offset, "count", count);
String responseText = this.wxMaService.post(TEMPLATE_LIST_URL, WxGsonBuilder.create().toJson(params));
return WxMaTemplateListResult.fromJson(responseText);
}
@Override
public boolean delTemplate(String templateId) throws WxErrorException {
Map<String, String> params = ImmutableMap.of("template_id", templateId);
this.wxMaService.post(TEMPLATE_DEL_URL, WxGsonBuilder.create().toJson(params));
return true;
}
}