entity.kt.vm 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package ${package.Entity}
  2. #foreach($pkg in ${table.importPackages})
  3. import ${pkg}
  4. #end
  5. /**
  6. * <p>
  7. * $!{table.comment}
  8. * </p>
  9. *
  10. * @author ${author}
  11. * @since ${date}
  12. */
  13. #if(${table.convert})
  14. @TableName("${table.name}")
  15. #end
  16. data class ${entity}(
  17. ## ---------- BEGIN 字段循环遍历 ----------
  18. #foreach($field in ${table.fields})
  19. #if(${field.keyFlag})
  20. #set($keyPropertyName=${field.propertyName})
  21. #end
  22. #if("$!field.comment" != "")
  23. /**
  24. * ${field.comment}
  25. */
  26. #end
  27. #if(${field.keyFlag})
  28. ## 主键
  29. #if(${field.keyIdentityFlag})
  30. @TableId(value = "${field.name}", type = IdType.AUTO)
  31. #elseif(!$null.isNull(${idType}) && "$!idType" != "")
  32. @TableId(value = "${field.name}", type = IdType.${idType})
  33. #elseif(${field.convert})
  34. @TableId("${field.name}")
  35. #end
  36. ## 普通字段
  37. #elseif(${field.fill})
  38. ## ----- 存在字段填充设置 -----
  39. #if(${field.convert})
  40. @TableField(value = "${field.name}", fill = FieldFill.${field.fill})
  41. #else
  42. @TableField(fill = FieldFill.${field.fill})
  43. #end
  44. #elseif(${field.convert})
  45. @TableField("${field.name}")
  46. #end
  47. ## 乐观锁注解
  48. #if(${versionFieldName}==${field.name})
  49. @Version
  50. #end
  51. ## 逻辑删除注解
  52. #if(${logicDeleteFieldName}==${field.name})
  53. @TableLogic
  54. #end
  55. var ${field.propertyName}: ${field.propertyType}? = null#if($foreach.count!=${table.fields.size()}),#end
  56. #end
  57. ## ---------- END 字段循环遍历 ----------
  58. ) : #if(${superEntityClass})${superEntityClass}#if(${activeRecord})<${entity}>#end() {
  59. #elseif(${activeRecord}) Model<${entity}>() {
  60. #else Serializable {
  61. #end
  62. #if(${entityColumnConstant})
  63. companion object {
  64. #foreach($field in ${table.fields})
  65. const val ${field.name.toUpperCase()} : String = "${field.name}"
  66. #end
  67. }
  68. #end
  69. #if(${activeRecord})
  70. override fun pkVal(): Serializable {
  71. #if(${keyPropertyName})
  72. return ${keyPropertyName} !
  73. #else
  74. return id!!
  75. #end
  76. }
  77. #end
  78. ## override fun toString(): String {
  79. ## return "${entity}{" +
  80. ###foreach($field in ${table.fields})
  81. ###if($!{velocityCount}==1)
  82. ## "${field.propertyName}=" + ${field.propertyName} +
  83. ###else
  84. ## ", ${field.propertyName}=" + ${field.propertyName} +
  85. ###end
  86. ###end
  87. ## "}"
  88. ## }
  89. }