From ace080f67f3469866c5a3276af100f32f99b37d9 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Tue, 8 Mar 2022 21:06:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=90=E8=A1=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=A8=A1=E6=9D=BF=E7=9A=84=E5=90=8E=E7=AB=AF=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/modules/gen/crud/entity.xml | 17 +++++++++++------ .../templates/modules/gen/crud_cloud/entity.xml | 14 ++++++++------ .../templates/modules/gen/include/viewForm.html | 3 ++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/modules/core/src/main/resources/templates/modules/gen/crud/entity.xml b/modules/core/src/main/resources/templates/modules/gen/crud/entity.xml index 60596c6d..4ae504b3 100644 --- a/modules/core/src/main/resources/templates/modules/gen/crud/entity.xml +++ b/modules/core/src/main/resources/templates/modules/gen/crud/entity.xml @@ -8,6 +8,9 @@ 0){ %> +import javax.validation.Valid; +<% } %> <% for(i in table.importList){ %> import ${i}; <% } %> @@ -210,15 +213,16 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab public ${ClassName}() { this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>); } - <% // 生成带主键参数的构造 if (!table.parentExists){ if (table.pkList.~size == 1){ %> + public ${ClassName}(String id){ super(id); } <% }else{ %> + public ${ClassName}(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType} ${pk.simpleAttrName}<% } %>){ <% for(pk in table.pkList){ %> this.${pk.simpleAttrName} = ${pk.simpleAttrName}; @@ -281,11 +285,6 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab %> <% - for(a in c.simpleAnnotationList){ - %> - @${a} - <% - } // 父类对象 if(table.parentExists && table.parentTableFkName == c.columnName){ %> @@ -299,6 +298,11 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab <% // 其它字段 }else{ + for(a in c.simpleAnnotationList){ + %> + @${a} + <% + } %> public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}() { return ${c.simpleAttrName}; @@ -340,6 +344,7 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab for(child in table.childList){ %> + @Valid public List<${@StringUtils.cap(child.className)}> get${@StringUtils.cap(child.className)}List() { return ${@StringUtils.uncap(child.className)}List; } diff --git a/modules/core/src/main/resources/templates/modules/gen/crud_cloud/entity.xml b/modules/core/src/main/resources/templates/modules/gen/crud_cloud/entity.xml index a29a5f3a..d33e3668 100644 --- a/modules/core/src/main/resources/templates/modules/gen/crud_cloud/entity.xml +++ b/modules/core/src/main/resources/templates/modules/gen/crud_cloud/entity.xml @@ -210,15 +210,16 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab public ${ClassName}() { this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>); } - <% // 生成带主键参数的构造 if (!table.parentExists){ if (table.pkList.~size == 1){ %> + public ${ClassName}(String id){ super(id); } <% }else{ %> + public ${ClassName}(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType} ${pk.simpleAttrName}<% } %>){ <% for(pk in table.pkList){ %> this.${pk.simpleAttrName} = ${pk.simpleAttrName}; @@ -281,11 +282,6 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab %> <% - for(a in c.simpleAnnotationList){ - %> - @${a} - <% - } // 父类对象 if(table.parentExists && table.parentTableFkName == c.columnName){ %> @@ -299,6 +295,11 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab <% // 其它字段 }else{ + for(a in c.simpleAnnotationList){ + %> + @${a} + <% + } %> public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}() { return ${c.simpleAttrName}; @@ -340,6 +341,7 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab for(child in table.childList){ %> + @Valid public List<${@StringUtils.cap(child.className)}> get${@StringUtils.cap(child.className)}List() { return ${@StringUtils.uncap(child.className)}List; } diff --git a/modules/core/src/main/resources/templates/modules/gen/include/viewForm.html b/modules/core/src/main/resources/templates/modules/gen/include/viewForm.html index 7b0e08bd..99ad3b8c 100644 --- a/modules/core/src/main/resources/templates/modules/gen/include/viewForm.html +++ b/modules/core/src/main/resources/templates/modules/gen/include/viewForm.html @@ -128,4 +128,5 @@ function treeselectCallback(id, act, index, layero){ }); } } -<% } %> \ No newline at end of file +<% } %> + \ No newline at end of file