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 f468ea95e392fa14c6c48eaf11b01f323828ea3c..d90176364a7fc00418e12484dda7aa0ac5c2e5a9 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; + } + } 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 96619eac408d983a2d50a25b05c34badc7585847..c2ab38e3cfb210c6e45ec8e2becd1b3b1da4ace7 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; } 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 0000000000000000000000000000000000000000..fccaade6463b04a133c7cf3081c5d3c9d5bb7cb5 --- /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; + } + +}