🎨 标记过期方法

This commit is contained in:
Binary Wang 2023-07-13 11:35:37 +08:00
parent a054560087
commit 4423b3d638
2 changed files with 5 additions and 10 deletions

View File

@ -63,7 +63,9 @@ public interface WxMpTemplateMsgService {
* @param shortTemplateId 模板库中模板的编号TM**OPENTMTM**等形式 * @param shortTemplateId 模板库中模板的编号TM**OPENTMTM**等形式
* @return templateId 模板Id * @return templateId 模板Id
* @throws WxErrorException . * @throws WxErrorException .
* @deprecated 请使用 addTemplate(java.lang.String, java.util.List)
*/ */
@Deprecated
String addTemplate(String shortTemplateId) throws WxErrorException; String addTemplate(String shortTemplateId) throws WxErrorException;
/** /**

View File

@ -14,6 +14,7 @@ import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import java.util.Collections;
import java.util.List; import java.util.List;
import static me.chanjar.weixin.mp.enums.WxMpApiUrl.TemplateMsg.*; import static me.chanjar.weixin.mp.enums.WxMpApiUrl.TemplateMsg.*;
@ -58,15 +59,7 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
@Override @Override
public String addTemplate(String shortTemplateId) throws WxErrorException { public String addTemplate(String shortTemplateId) throws WxErrorException {
JsonObject jsonObject = new JsonObject(); return this.addTemplate(shortTemplateId, Collections.emptyList());
jsonObject.addProperty("template_id_short", shortTemplateId);
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
@ -74,7 +67,7 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
Gson gson = new Gson(); Gson gson = new Gson();
jsonObject.addProperty("template_id_short", shortTemplateId); jsonObject.addProperty("template_id_short", shortTemplateId);
jsonObject.addProperty("keyword_name_list",gson.toJson(keywordNameList)); jsonObject.addProperty("keyword_name_list", gson.toJson(keywordNameList));
String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString()); String responseContent = this.wxMpService.post(TEMPLATE_API_ADD_TEMPLATE, jsonObject.toString());
final JsonObject result = GsonParser.parse(responseContent); final JsonObject result = GsonParser.parse(responseContent);
if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) { if (result.get(WxConsts.ERR_CODE).getAsInt() == 0) {