entity.kt.vm 2.3 KB

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