将模板消息相关接口代码移到单独的service,并作相应重构调整,增加单元测试 for issue #63

This commit is contained in:
Binary Wang
2016-10-14 19:33:34 +08:00
parent 6682f5ff28
commit 77db3c2dae
9 changed files with 274 additions and 165 deletions

View File

@@ -1,38 +0,0 @@
package me.chanjar.weixin.mp.bean;
import java.io.Serializable;
/**
* @author miller
* 官方文档中,创建和获取的数据结构不一样。所以采用冗余字段的方式,实现相应的接口
*/
public class Industry implements Serializable {
private static final long serialVersionUID = -1707184885588012142L;
private String id;
private String firstClass;
private String secondClass;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstClass() {
return this.firstClass;
}
public void setFirstClass(String firstClass) {
this.firstClass = firstClass;
}
public String getSecondClass() {
return this.secondClass;
}
public void setSecondClass(String secondClass) {
this.secondClass = secondClass;
}
}

View File

@@ -2,6 +2,8 @@ package me.chanjar.weixin.mp.bean;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serializable;
@@ -9,31 +11,97 @@ import java.io.Serializable;
* @author miller
*/
public class WxMpIndustry implements Serializable {
private static final long serialVersionUID = -7700398224795914722L;
private Industry primaryIndustry;
private Industry secondIndustry;
private static final long serialVersionUID = -7700398224795914722L;
private Industry primaryIndustry;
private Industry secondIndustry;
public static WxMpIndustry fromJson(String json) {
return WxMpGsonBuilder.create().fromJson(json, WxMpIndustry.class);
public WxMpIndustry() {
}
public WxMpIndustry(Industry primaryIndustry, Industry secondIndustry) {
this.primaryIndustry = primaryIndustry;
this.secondIndustry = secondIndustry;
}
/**
* @author miller
* 官方文档中,创建和获取的数据结构不一样。所以采用冗余字段的方式,实现相应的接口
*/
public static class Industry implements Serializable {
private static final long serialVersionUID = -1707184885588012142L;
private String id;
private String firstClass;
private String secondClass;
public Industry() {
}
public String toJson() {
return WxMpGsonBuilder.create().toJson(this);
public Industry(String id) {
this.id = id;
}
public Industry getPrimaryIndustry() {
return this.primaryIndustry;
public Industry(String id, String firstClass, String secondClass) {
this.id = id;
this.firstClass = firstClass;
this.secondClass = secondClass;
}
public void setPrimaryIndustry(Industry primaryIndustry) {
this.primaryIndustry = primaryIndustry;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
public Industry getSecondIndustry() {
return this.secondIndustry;
public String getId() {
return this.id;
}
public void setSecondIndustry(Industry secondIndustry) {
this.secondIndustry = secondIndustry;
public void setId(String id) {
this.id = id;
}
public String getFirstClass() {
return this.firstClass;
}
public void setFirstClass(String firstClass) {
this.firstClass = firstClass;
}
public String getSecondClass() {
return this.secondClass;
}
public void setSecondClass(String secondClass) {
this.secondClass = secondClass;
}
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
public static WxMpIndustry fromJson(String json) {
return WxMpGsonBuilder.create().fromJson(json, WxMpIndustry.class);
}
public String toJson() {
return WxMpGsonBuilder.create().toJson(this);
}
public Industry getPrimaryIndustry() {
return this.primaryIndustry;
}
public void setPrimaryIndustry(Industry primaryIndustry) {
this.primaryIndustry = primaryIndustry;
}
public Industry getSecondIndustry() {
return this.secondIndustry;
}
public void setSecondIndustry(Industry secondIndustry) {
this.secondIndustry = secondIndustry;
}
}