entity.java.vm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package ${package.Entity};
  2. #foreach($pkg in ${table.importPackages})
  3. import ${pkg};
  4. #end
  5. #if(${entityLombokModel})
  6. import com.baomidou.mybatisplus.annotations.Version;
  7. import lombok.Data;
  8. import lombok.EqualsAndHashCode;
  9. import lombok.experimental.Accessors;
  10. #end
  11. /**
  12. * <p>
  13. * $!{table.comment}
  14. * </p>
  15. *
  16. * @author ${author}
  17. * @since ${date}
  18. */
  19. #if(${entityLombokModel})
  20. @Data
  21. #if(${superEntityClass})
  22. @EqualsAndHashCode(callSuper = true)
  23. #end
  24. @Accessors(chain = true)
  25. #end
  26. ###if(${table.convert})
  27. @TableName("${table.name}")
  28. ###end
  29. #if(${superEntityClass})
  30. public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
  31. #elseif(${activeRecord})
  32. public class ${entity} extends Model<${entity}> {
  33. #else
  34. public class ${entity} implements Serializable {
  35. #end
  36. private static final long serialVersionUID = 1L;
  37. ## ---------- BEGIN 字段循环遍历 ----------
  38. #foreach($field in ${table.fields})
  39. #if(${field.keyFlag})
  40. #set($keyPropertyName=${field.propertyName})
  41. #end
  42. #if("$!field.comment" != "")
  43. /**
  44. * ${field.comment}
  45. */
  46. #end
  47. #if(${field.keyFlag})
  48. ## 主键
  49. #if(${field.keyIdentityFlag})
  50. @TableId(value = "${field.name}", type = IdType.AUTO)
  51. #elseif(!$null.isNull(${idType}) && "$!idType" != "")
  52. @TableId(value = "${field.name}", type = IdType.${idType})
  53. #elseif(${field.convert})
  54. @TableId("${field.name}")
  55. #end
  56. ## 普通字段
  57. #elseif(${field.fill})
  58. ## ----- 存在字段填充设置 -----
  59. #if(${field.convert})
  60. @TableField(value = "${field.name}", fill = FieldFill.${field.fill})
  61. #else
  62. @TableField(fill = FieldFill.${field.fill})
  63. #end
  64. #elseif(${field.convert})
  65. @TableField("${field.name}")
  66. #end
  67. ## 乐观锁注解
  68. #if(${versionFieldName}==${field.name})
  69. @Version
  70. #end
  71. ## 逻辑删除注解
  72. #if(${logicDeleteFieldName}==${field.name})
  73. @TableLogic
  74. #end
  75. private ${field.propertyType} ${field.propertyName};
  76. #end
  77. ## ---------- END 字段循环遍历 ----------
  78. #if(!${entityLombokModel})
  79. #foreach($field in ${table.fields})
  80. #if(${field.propertyType.equals("boolean")})
  81. #set($getprefix="is")
  82. #else
  83. #set($getprefix="get")
  84. #end
  85. public ${field.propertyType} ${getprefix}${field.capitalName}() {
  86. return ${field.propertyName};
  87. }
  88. #if(${entityBuilderModel})
  89. public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
  90. #else
  91. public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
  92. #end
  93. this.${field.propertyName} = ${field.propertyName};
  94. #if(${entityBuilderModel})
  95. return this;
  96. #end
  97. }
  98. #end
  99. #end
  100. #if(${entityColumnConstant})
  101. #foreach($field in ${table.fields})
  102. public static final String ${field.name.toUpperCase()} = "${field.name}";
  103. #end
  104. #end
  105. #if(${activeRecord})
  106. @Override
  107. protected Serializable pkVal() {
  108. #if(${keyPropertyName})
  109. return this.${keyPropertyName};
  110. #else
  111. return this.id;
  112. #end
  113. }
  114. #end
  115. #if(!${entityLombokModel})
  116. @Override
  117. public String toString() {
  118. return "${entity}{" +
  119. #foreach($field in ${table.fields})
  120. #if($!{velocityCount}==1)
  121. "${field.propertyName}=" + ${field.propertyName} +
  122. #else
  123. ", ${field.propertyName}=" + ${field.propertyName} +
  124. #end
  125. #end
  126. "}";
  127. }
  128. #end
  129. }