Skip to content

Commit 4423b3d

Browse files
committed
🎨 标记过期方法
1 parent a054560 commit 4423b3d

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ public interface WxMpTemplateMsgService {
6363
* @param shortTemplateId 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
6464
* @return templateId 模板Id
6565
* @throws WxErrorException .
66+
* @deprecated 请使用 addTemplate(java.lang.String, java.util.List)
6667
*/
68+
@Deprecated
6769
String addTemplate(String shortTemplateId) throws WxErrorException;
6870

6971
/**

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
1515
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
1616

17+
import java.util.Collections;
1718
import java.util.List;
1819

1920
import static me.chanjar.weixin.mp.enums.WxMpApiUrl.TemplateMsg.*;
@@ -58,23 +59,15 @@ public WxMpTemplateIndustry getIndustry() throws WxErrorException {
5859

5960
@Override
6061
public String addTemplate(String shortTemplateId) throws WxErrorException {
61-
JsonObject jsonObject = new JsonObject();
62-
jsonObject.addProperty("template_id_short", shortTemplateId);
63-
String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString());
64-
final JsonObject result = GsonParser.parse(responseContent);
65-
if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) {
66-
return result.get("template_id").getAsString();
67-
}
68-
69-
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
62+
return this.addTemplate(shortTemplateId, Collections.emptyList());
7063
}
7164

7265
@Override
7366
public String addTemplate(String shortTemplateId, List<String> keywordNameList) throws WxErrorException {
7467
JsonObject jsonObject = new JsonObject();
7568
Gson gson = new Gson();
7669
jsonObject.addProperty("template_id_short", shortTemplateId);
77-
jsonObject.addProperty("keyword_name_list",gson.toJson(keywordNameList));
70+
jsonObject.addProperty("keyword_name_list", gson.toJson(keywordNameList));
7871
String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString());
7972
final JsonObject result = GsonParser.parse(responseContent);
8073
if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) {

0 commit comments

Comments
 (0)