From 1fa9c0ce081cc53794f3ad20ffddb9fb0f21d4b9 Mon Sep 17 00:00:00 2001 From: wuwentao Date: Wed, 25 Jan 2017 15:27:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E2=80=9C=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=B7=B2=E6=B7=BB=E5=8A=A0=E8=87=B3=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E4=B8=8B=E6=89=80=E6=9C=89=E6=A8=A1=E6=9D=BF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E2=80=9D=E7=9A=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fastweixin/api/TemplateMsgAPI.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java index f468ea9..d901763 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java @@ -1,19 +1,21 @@ package com.github.sd4324530.fastweixin.api; +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.config.ApiConfig; import com.github.sd4324530.fastweixin.api.entity.Industry; import com.github.sd4324530.fastweixin.api.entity.TemplateMsg; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.AddTemplateResponse; import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.PrivateTemplate; import com.github.sd4324530.fastweixin.api.response.SendTemplateResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; /** * 模版消息 api @@ -78,5 +80,16 @@ public class TemplateMsgAPI extends BaseAPI { return result; } - + /** + * 获取已添加至帐号下所有模板列表 + * @return + */ + public PrivateTemplate[] getAllPrivateTemplate(){ + String url = BASE_API_URL + "cgi-bin/template/get_all_private_template?access_token=#"; + BaseResponse r = executePost(url, null); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + PrivateTemplate[] templates = JSONUtil.toBean(JSONUtil.toJson(JSONUtil.getJSONFromString(resultJson).get("template_list")), PrivateTemplate[].class); + return templates; + } + } -- Gitee From 937361cb9856c61c813aa47692a63d8d7c132aff Mon Sep 17 00:00:00 2001 From: wuwentao Date: Sat, 4 Feb 2017 09:19:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=B1=BB=EF=BC=9A?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=B7=B2=E6=B7=BB=E5=8A=A0=E8=87=B3=E5=B8=90?= =?UTF-8?q?=E5=8F=B7=E4=B8=8B=E6=89=80=E6=9C=89=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/response/PrivateTemplate.java | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/PrivateTemplate.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/PrivateTemplate.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/PrivateTemplate.java new file mode 100644 index 0000000..fccaade --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/PrivateTemplate.java @@ -0,0 +1,110 @@ +package com.github.sd4324530.fastweixin.api.response; + +import java.io.Serializable; + +import com.alibaba.fastjson.annotation.JSONField; + +/** + * 获取已添加至帐号下所有模板 + * @author wuwentao + * @date 2017年1月25日 + */ +public class PrivateTemplate implements Serializable { + + private static final long serialVersionUID = -8761076945643537134L; + + /** + * 模板ID + */ + @JSONField(name="template_id") + private String templateId; + + /** + * 模板标题 + */ + private String title; + + /** + * 模板所属行业的一级行业 + */ + @JSONField(name="primary_industry") + private String primaryIndustry; + + /** + * 模板所属行业的二级行业 + */ + @JSONField(name="deputy_industry") + private String deputyIndustry; + + /** + * 模板内容 + */ + private String content; + + /** + * 模板示例 + */ + private String example; + + /** + * 模板备注 + */ + private String remark; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getPrimaryIndustry() { + return primaryIndustry; + } + + public void setPrimaryIndustry(String primaryIndustry) { + this.primaryIndustry = primaryIndustry; + } + + public String getDeputyIndustry() { + return deputyIndustry; + } + + public void setDeputyIndustry(String deputyIndustry) { + this.deputyIndustry = deputyIndustry; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getExample() { + return example; + } + + public void setExample(String example) { + this.example = example; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + +} -- Gitee From 24658e7d9e97736d13b3354aa854bf30ee1c86a1 Mon Sep 17 00:00:00 2001 From: wuwentao Date: Sat, 4 Feb 2017 14:11:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=8F=82=E6=95=B0=E6=9E=84=E9=80=A0=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E6=96=B9=E4=BE=BF=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fastweixin/api/entity/TemplateParam.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/TemplateParam.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/TemplateParam.java index 96619ea..c2ab38e 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/entity/TemplateParam.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/TemplateParam.java @@ -14,7 +14,22 @@ public class TemplateParam extends BaseModel { */ private String color; - public String getValue() { + public TemplateParam() { + super(); + } + + public TemplateParam(String value) { + super(); + this.value = value; + } + + public TemplateParam(String value, String color) { + super(); + this.value = value; + this.color = color; + } + + public String getValue() { return value; } -- Gitee