hubin 7 år sedan
förälder
incheckning
d49cdbe17c

+ 1 - 1
mybatis-plus-generator/src/main/resources/templates/entity.java.ftl

@@ -120,7 +120,7 @@ public class ${entity} implements Serializable {
 <#if keyPropertyName??>
         return this.${keyPropertyName};
 <#else>
-        return this.id;
+        return null;
 </#if>
     }
 

+ 1 - 1
mybatis-plus-generator/src/main/resources/templates/entity.java.vm

@@ -119,7 +119,7 @@ public class ${entity} implements Serializable {
 #if(${keyPropertyName})
         return this.${keyPropertyName};
 #else
-        return this.id;
+        return null;
 #end
     }
 

+ 8 - 4
mybatis-plus-generator/src/main/resources/templates/entity.kt.ftl

@@ -1,7 +1,7 @@
-package ${package.Entity};
+package ${package.Entity}
 
 <#list table.importPackages as pkg>
-import ${pkg};
+import ${pkg}
 </#list>
 
 /**
@@ -62,7 +62,11 @@ class ${entity} : Serializable {
 <#if (logicDeleteFieldName!"") == field.name>
     @TableLogic
 </#if>
+    <#if field.propertyType == "Integer">
+    var ${field.propertyName}: Int? = null
+    <#else>
     var ${field.propertyName}: ${field.propertyType}? = null
+    </#if>
 </#list>
 <#-- ----------  END 字段循环遍历  ---------->
 
@@ -80,9 +84,9 @@ class ${entity} : Serializable {
 <#if activeRecord>
     override fun pkVal(): Serializable {
 <#if keyPropertyName??>
-        return ${keyPropertyName}!!
+        return ${keyPropertyName}
 <#else>
-        return id!!
+        return null
 </#if>
     }