mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-07-17 10:41:58 +08:00
🎨 修复错误代码
This commit is contained in:
parent
a472ae6c1e
commit
f468653ac4
@ -1,6 +1,7 @@
|
|||||||
package me.chanjar.weixin.mp.api.impl;
|
package me.chanjar.weixin.mp.api.impl;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.chanjar.weixin.common.api.WxConsts;
|
import me.chanjar.weixin.common.api.WxConsts;
|
||||||
@ -77,6 +78,24 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
|
|||||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
|
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);
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
return result.get("template_id").getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WxMpTemplate> getAllPrivateTemplate() throws WxErrorException {
|
public List<WxMpTemplate> getAllPrivateTemplate() throws WxErrorException {
|
||||||
return WxMpTemplate.fromJson(this.wxMpService.get(TEMPLATE_GET_ALL_PRIVATE_TEMPLATE, null));
|
return WxMpTemplate.fromJson(this.wxMpService.get(TEMPLATE_GET_ALL_PRIVATE_TEMPLATE, null));
|
||||||
|
Loading…
Reference in New Issue
Block a user