package com.qxueyou.scc.base.model;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* ΢ÐÅÄ£°åÏûÏ¢
|
* @author µÂ»¢
|
*/
|
public class WxTemplateMsg extends BaseVO {
|
|
private static final String DEFAULT_COLOR = "#173177";
|
|
private String toUser;
|
|
private String templateId;
|
|
private String url;
|
|
private Map<String,Pair> data = new HashMap<String,Pair>(3);
|
|
public WxTemplateMsg(){};
|
|
public String getToUser() {
|
return toUser;
|
}
|
|
public void setToUser(String toUser) {
|
this.toUser = toUser;
|
}
|
|
public String getTemplateId() {
|
return templateId;
|
}
|
|
public void setTemplateId(String templateId) {
|
this.templateId = templateId;
|
}
|
|
public String getUrl() {
|
return url;
|
}
|
|
public void setUrl(String url) {
|
this.url = url;
|
}
|
|
public String toJSON(){
|
|
StringBuilder bd = new StringBuilder(300);
|
|
bd.append('{');
|
|
bd.append("\"touser\":\"").append(this.toUser).append("\",");
|
bd.append("\"template_id\":\"").append(this.templateId).append("\",");
|
bd.append("\"url\":\"").append(this.url).append("\",");
|
|
bd.append("\"data\":{");
|
|
for(String key:data.keySet()){
|
bd.append("\"").append(key).append("\":{");
|
bd.append("\"value\":\"").append(data.get(key).getValue()).append("\",");
|
bd.append("\"color\":\"").append(data.get(key).getColor()).append("\"");
|
bd.append("},");
|
}
|
|
bd.deleteCharAt(bd.length()-1);
|
|
bd.append("}");
|
bd.append("}");
|
return bd.toString();
|
}
|
|
|
class Pair{
|
String value;
|
String color;
|
|
Pair(String value,String color){
|
this.value=value;
|
this.color=color;
|
}
|
|
public String getValue() {
|
return value;
|
}
|
|
public void setValue(String value) {
|
this.value = value;
|
}
|
|
public String getColor() {
|
return color;
|
}
|
|
public void setColor(String color) {
|
this.color = color;
|
}
|
|
}
|
|
public void addData(String name,String value){
|
addData(name,value,DEFAULT_COLOR);
|
}
|
|
public void addData(String name,String value,String color){
|
data.put(name, new Pair(value,color));
|
}
|
|
}
|