|
14 | 14 | import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; |
15 | 15 | import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; |
16 | 16 |
|
| 17 | +import java.util.Collections; |
17 | 18 | import java.util.List; |
18 | 19 |
|
19 | 20 | import static me.chanjar.weixin.mp.enums.WxMpApiUrl.TemplateMsg.*; |
@@ -58,23 +59,15 @@ public WxMpTemplateIndustry getIndustry() throws WxErrorException { |
58 | 59 |
|
59 | 60 | @Override |
60 | 61 | 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()); |
70 | 63 | } |
71 | 64 |
|
72 | 65 | @Override |
73 | 66 | public String addTemplate(String shortTemplateId, List<String> keywordNameList) throws WxErrorException { |
74 | 67 | JsonObject jsonObject = new JsonObject(); |
75 | 68 | Gson gson = new Gson(); |
76 | 69 | jsonObject.addProperty("template_id_short", shortTemplateId); |
77 | | - jsonObject.addProperty("keyword_name_list",gson.toJson(keywordNameList)); |
| 70 | + jsonObject.addProperty("keyword_name_list", gson.toJson(keywordNameList)); |
78 | 71 | String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString()); |
79 | 72 | final JsonObject result = GsonParser.parse(responseContent); |
80 | 73 | if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) { |
|
0 commit comments