model.ftl 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <#import "function.ftl" as func>
  2. <#assign package=model.variables.package>
  3. <#assign class=model.variables.class>
  4. <#assign system=vars.system>
  5. <#assign subtables=model.subTableList>
  6. package ${vars.packagePre}.${system}.model.${package};
  7. import java.util.ArrayList;
  8. import java.util.List;
  9. import java.util.Date;
  10. <#if func.supportFlow(model)>
  11. import ${vars.packagePre}.core.model.WfBaseModel;
  12. <#else>
  13. import ${vars.packagePre}.core.model.BaseModel;
  14. </#if>
  15. import org.apache.commons.lang.builder.HashCodeBuilder;
  16. import org.apache.commons.lang.builder.ToStringBuilder;
  17. import org.apache.commons.lang.builder.EqualsBuilder;
  18. <#if subtables?size!=0>
  19. <#list subtables as subtable>
  20. <#assign subVars=subtable.variables>
  21. import ${vars.packagePre}.${system}.model.${subVars.package}.${subVars.class};
  22. </#list>
  23. </#if>
  24. /**
  25. * 对象功能:${model.tabComment} Model对象
  26. <#if vars.company?exists>
  27. * 开发公司:${vars.company}
  28. </#if>
  29. <#if vars.developer?exists>
  30. * 开发人员:${vars.developer}
  31. </#if>
  32. * 创建时间:${date?string("yyyy-MM-dd HH:mm:ss")}
  33. */
  34. public class ${class} extends <#if func.supportFlow(model)>WfBaseModel<#else>BaseModel</#if>{
  35. <#list model.columnList as col>
  36. // ${col.comment}
  37. protected ${func.getColType(col.colType)} ${func.convertUnderLine(col.columnName)};
  38. </#list>
  39. <#if func.isSubTableExist( subtables)>
  40. <#list subtables as table>
  41. <#assign vars=table.variables>
  42. //${table.tabComment}列表
  43. protected List<${vars.class}> ${vars.classVar}List=new ArrayList<${vars.class}>();
  44. </#list>
  45. </#if>
  46. <#list model.columnList as col>
  47. <#assign colName=func.convertUnderLine(col.columnName)>
  48. public void set${colName?cap_first}(${func.getColType(col.colType)} ${colName}){
  49. this.${colName} = ${colName};
  50. }
  51. /**
  52. * 返回 ${col.comment}
  53. * @return
  54. */
  55. public ${func.getColType(col.colType)} get${colName?cap_first}() {
  56. return this.${colName};
  57. }
  58. </#list>
  59. <#if func.isSubTableExist( subtables)>
  60. <#list subtables as table>
  61. <#assign vars=table.variables>
  62. public void set${vars.class}List(List<${vars.class}> ${vars.classVar}List){
  63. this.${vars.classVar}List = ${vars.classVar}List;
  64. }
  65. /**
  66. * 返回 ${table.tabComment}列表
  67. * @return
  68. */
  69. public List<${vars.class}> get${vars.class}List(){
  70. return this.${vars.classVar}List;
  71. }
  72. </#list>
  73. </#if>
  74. /**
  75. * @see java.lang.Object#equals(Object)
  76. */
  77. public boolean equals(Object object)
  78. {
  79. if (!(object instanceof ${class}))
  80. {
  81. return false;
  82. }
  83. ${class} rhs = (${class}) object;
  84. return new EqualsBuilder()
  85. <#list model.columnList as col>
  86. <#assign colName=func.convertUnderLine(col.columnName)>
  87. .append(this.${colName}, rhs.${colName})
  88. </#list>
  89. .isEquals();
  90. }
  91. /**
  92. * @see java.lang.Object#hashCode()
  93. */
  94. public int hashCode()
  95. {
  96. return new HashCodeBuilder(-82280557, -700257973)
  97. <#list model.columnList as col>
  98. <#assign colName=func.convertUnderLine(col.columnName)>
  99. .append(this.${colName})
  100. </#list>
  101. .toHashCode();
  102. }
  103. /**
  104. * @see java.lang.Object#toString()
  105. */
  106. public String toString()
  107. {
  108. return new ToStringBuilder(this)
  109. <#list model.columnList as col>
  110. <#assign colName=func.convertUnderLine(col.columnName)>
  111. .append("${colName}", this.${colName})
  112. </#list>
  113. .toString();
  114. }
  115. }