Skip to content

Commit 1b0fc0b

Browse files
🆕 增加开放平台将草稿添加到代码标准模板库的支持
1 parent 577b756 commit 1b0fc0b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,27 @@ public interface WxOpenComponentService {
401401
List<WxOpenMaCodeTemplate> getTemplateList() throws WxErrorException;
402402

403403
/**
404+
* 请参考并使用 {@link #addToTemplate(long,int)}.
404405
* 将草稿箱的草稿选为小程序代码模版.
405406
*
406407
* @param draftId 草稿ID,本字段可通过“获取草稿箱内的所有临时代码草稿”接口获得
407408
* @throws WxErrorException 操作失败时抛出,具体错误码请看此接口的注释文档
408409
* @see #getTemplateDraftList #getTemplateDraftList
409410
*/
411+
@Deprecated
410412
void addToTemplate(long draftId) throws WxErrorException;
411413

414+
/**
415+
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/addtotemplate.html
416+
* 将草稿添加到代码模板库.
417+
*
418+
* @param draftId 草稿ID,本字段可通过“获取草稿箱内的所有临时代码草稿”接口获得
419+
* @param templateType 代码模版类型,【普通模板:0, 标准模板:1】
420+
* @throws WxErrorException 操作失败时抛出,具体错误码请看此接口的注释文档
421+
* @see #getTemplateDraftList #getTemplateDraftList
422+
*/
423+
void addToTemplate(long draftId, int templateType) throws WxErrorException;
424+
412425
/**
413426
* 删除指定小程序代码模版.
414427
*

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,14 @@ public void addToTemplate(long draftId) throws WxErrorException {
484484
post(ADD_TO_TEMPLATE_URL, param.toString(), "access_token");
485485
}
486486

487+
@Override
488+
public void addToTemplate(long draftId,int templateType) throws WxErrorException {
489+
JsonObject param = new JsonObject();
490+
param.addProperty("draft_id", draftId);
491+
param.addProperty("template_type", templateType);
492+
post(ADD_TO_TEMPLATE_URL, param.toString(), "access_token");
493+
}
494+
487495
@Override
488496
public void deleteTemplate(long templateId) throws WxErrorException {
489497
JsonObject param = new JsonObject();

0 commit comments

Comments
 (0)