mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-05 13:17:46 +08:00
🎨 修复合并错误的代码
This commit is contained in:
parent
f468653ac4
commit
e5b0498401
@ -1,6 +1,5 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -66,27 +65,13 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
|
||||
@Override
|
||||
public String addTemplate(String shortTemplateId, List<String> keywordNameList) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
Gson gson = new Gson();
|
||||
jsonObject.addProperty("template_id_short", shortTemplateId);
|
||||
jsonObject.addProperty("keyword_name_list", gson.toJson(keywordNameList));
|
||||
String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString());
|
||||
final JsonObject result = GsonParser.parse(responseContent);
|
||||
if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
return result.get("template_id").getAsString();
|
||||
}
|
||||
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addTemplate(String shortTemplateId, List<String> keywordNameList) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
for(String val: keywordNameList) {
|
||||
jsonArray.add(val);
|
||||
}
|
||||
keywordNameList.forEach(jsonArray::add);
|
||||
|
||||
jsonObject.addProperty("template_id_short", shortTemplateId);
|
||||
jsonObject.add("keyword_name_list", jsonArray);
|
||||
|
||||
String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString());
|
||||
final JsonObject result = GsonParser.parse(responseContent);
|
||||
if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user