POTemplate.ftl.svn-base
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<#--包名 -->
package ${packages}
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
/**
<#if version?exists>
* @version ${version}
</#if>
*/
public class ${name}PO implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
<#--变量 ,get,set方法-->
<#if tablemodel.columnlist?exists>
<#list tablemodel.columnlist as clist>
private ${clist.columnJAVAType} ${clist.columnName};
<#if clist.columnRemarks?exists>
/**
* ${clist.columnRemarks}
*/
<#else>
</#if>
public ${clist.columnJAVAType} get${clist.columnMethodName}(){
return ${clist.columnName};
}
public void set${clist.columnMethodName}(${clist.columnJAVAType} ${clist.columnName}){
this.${clist.columnName} = ${clist.columnName};
}
<#if clist.columnJAVAType = "Long" || clist.columnJAVAType = "java.math.BigDecimal" || clist.columnJAVAType = "Integer" || clist.columnJAVAType = "Short" || clist.columnJAVAType = "Float" || clist.columnJAVAType = "Double">
<#if clist.columnJAVAType = "Long">
private ${clist.columnJAVAType} variation${clist.columnMethodName} = 0L;
</#if>
<#if clist.columnJAVAType = "java.math.BigDecimal">
private ${clist.columnJAVAType} variation${clist.columnMethodName} = new java.math.BigDecimal(0.0);
</#if>
<#if clist.columnJAVAType = "Integer">
private ${clist.columnJAVAType} variation${clist.columnMethodName} = 0;
</#if>
<#if clist.columnJAVAType = "Short">
private ${clist.columnJAVAType} variation${clist.columnMethodName} = 0;
</#if>
<#if clist.columnJAVAType = "Double">
private ${clist.columnJAVAType} variation${clist.columnMethodName} = 0d;
</#if>
<#if clist.columnJAVAType = "Float">
private ${clist.columnJAVAType} variation${clist.columnMethodName} = 0f;
</#if>
public ${clist.columnJAVAType} getVariation${clist.columnMethodName}(){
return variation${clist.columnMethodName};
}
public void setVariation${clist.columnMethodName}(${clist.columnJAVAType} variation${clist.columnName}){
this.variation${clist.columnMethodName} = variation${clist.columnName};
}
</#if>
</#list>
</#if>
@Override
public String toString() {
return "${name}PO: ${toStringMethodBody};
}
public JSONObject toJson() {
JSONObject json = null;
try {
json = new JSONObject();
<#if tablemodel.columnlist?exists>
<#list tablemodel.columnlist as clist>
json.put("${clist.columnName}", get${clist.columnMethodName}());
</#list>
</#if>
} catch (JSONException e) {
e.printStackTrace();
}
return json;
}
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<String, Object>();
<#if tablemodel.columnlist?exists>
<#list tablemodel.columnlist as clist>
map.put("${clist.columnName}", get${clist.columnMethodName}());
</#list>
</#if>
return map;
}
public ${name}PO JsonToPo(JSONObject json)throws JSONException{
${name}PO po = new ${name}PO();
<#if tablemodel.columnlist?exists>
<#list tablemodel.columnlist as clist>
po.set${clist.columnMethodName}((${clist.columnJAVAType})json.get("${clist.columnName}"));
</#list>
return po;
</#if>
}
}