From 4b25d1a1b2c57a7a0b02edcde81845e995518721 Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Tue, 25 Feb 2020 17:10:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=9D=99=E6=80=81=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/DynamicConfigFormController.java | 41 +++++ .../impl/DynamicConfigTableServiceImpl.java | 3 - .../default/controller/apis/ApiController.ftl | 11 ++ .../codetemplate/default/mapper/mapper.ftl | 4 +- .../codetemplate/default/pojo/dto.ftl | 2 - .../codetemplate/default/pojo/vo.ftl | 51 +++++- .../codetemplate/default/route/list.ftl | 2 +- .../codetemplate/default/route/save.ftl | 126 +++++++++++---- .../codetemplate/default/route/update.ftl | 139 ++++++++++++----- .../codetemplate/default/sql/sql.ftl | 1 + .../templates/dynamic/config/form/save.html | 81 +++++----- .../templates/dynamic/config/form/update.html | 94 ++++++----- .../annotation/CheckEmptyAnnotation.java | 4 + .../common/component/SecurityComponent.java | 31 +++- .../pojo/dtos/CurrentUserIdInfoDTO.java | 146 ++++++++++++++++++ .../utils/annotation/AnnotationUtil.java | 55 +++++++ 16 files changed, 636 insertions(+), 155 deletions(-) create mode 100644 cloud-common/src/main/java/com/cm/common/pojo/dtos/CurrentUserIdInfoDTO.java diff --git a/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/controller/apis/dynamic/config/form/DynamicConfigFormController.java b/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/controller/apis/dynamic/config/form/DynamicConfigFormController.java index 05ea219..af1f68e 100644 --- a/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/controller/apis/dynamic/config/form/DynamicConfigFormController.java +++ b/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/controller/apis/dynamic/config/form/DynamicConfigFormController.java @@ -4,6 +4,8 @@ import com.cm.common.annotation.CheckRequestBodyAnnotation; import com.cm.common.base.AbstractController; import com.cm.common.constants.ISystemConstant; import com.cm.common.exception.SearchException; +import com.cm.common.plugin.enums.dynamic.FieldRequireTypeEnum; +import com.cm.common.plugin.enums.dynamic.FieldTypeEnum; import com.cm.common.plugin.pojo.dtos.dynamic.config.form.DynamicConfigFormDTO; import com.cm.common.plugin.pojo.vos.dynamic.config.form.DynamicConfigFormVO; import com.cm.common.plugin.pojo.vos.dynamic.config.form.FieldShowVO; @@ -13,6 +15,7 @@ import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultList; import io.swagger.annotations.*; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -41,6 +44,8 @@ public class DynamicConfigFormController extends AbstractController { @PostMapping("saveform") @CheckRequestBodyAnnotation public SuccessResult saveForm(@RequestBody DynamicConfigFormVO dynamicConfigFormVO) throws Exception { + restVerifyConfig(dynamicConfigFormVO); + restJoinTableConfig(dynamicConfigFormVO); return dynamicConfigFormService.saveForm(dynamicConfigFormVO); } @@ -62,9 +67,45 @@ public class DynamicConfigFormController extends AbstractController { @PutMapping("updateform/{id}") @CheckRequestBodyAnnotation public SuccessResult updateForm(@PathVariable("id") String id, @RequestBody DynamicConfigFormVO dynamicConfigFormVO) throws Exception { + restVerifyConfig(dynamicConfigFormVO); + restJoinTableConfig(dynamicConfigFormVO); return dynamicConfigFormService.updateForm(id, dynamicConfigFormVO); } + /** + * 初始化验证字段 + * + * @param dynamicConfigFormVO + */ + private void restVerifyConfig(DynamicConfigFormVO dynamicConfigFormVO) { + if (!StringUtils.equals(FieldTypeEnum.STRING.getValue(), dynamicConfigFormVO.getFieldType())) { + dynamicConfigFormVO.setVerifyType(null); + dynamicConfigFormVO.setVerifyRegular(null); + return; + } + if (!StringUtils.equals(FieldRequireTypeEnum.CUSTOM.getValue(), dynamicConfigFormVO.getVerifyType())) { + dynamicConfigFormVO.setVerifyRegular(null); + } + } + + /** + * 初始化联表字段 + * + * @param dynamicConfigFormVO + */ + private void restJoinTableConfig(DynamicConfigFormVO dynamicConfigFormVO) { + boolean isJoin = StringUtils.equals(FieldTypeEnum.INNER_JOIN.getValue(), dynamicConfigFormVO.getFieldType()) + || StringUtils.equals(FieldTypeEnum.LEFT_JOIN.getValue(), dynamicConfigFormVO.getFieldType()) + || StringUtils.equals(FieldTypeEnum.RIGHT_JOIN.getValue(), dynamicConfigFormVO.getFieldType()); + if (!isJoin) { + dynamicConfigFormVO.setJoinTable(null); + dynamicConfigFormVO.setJoinTableField(null); + dynamicConfigFormVO.setJoinTableListShow(null); + dynamicConfigFormVO.setJoinTableFormShow(null); + dynamicConfigFormVO.setJoinTableSort(1); + } + } + @ApiOperation(value = "字段列表显示修改", notes = "字段列表显示修改接口") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "表单ID", paramType = "path") diff --git a/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/service/dynamic/config/impl/DynamicConfigTableServiceImpl.java b/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/service/dynamic/config/impl/DynamicConfigTableServiceImpl.java index f15fa1b..1b1a916 100644 --- a/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/service/dynamic/config/impl/DynamicConfigTableServiceImpl.java +++ b/cloud-common-plugin-dynamic/src/main/java/com/cm/common/plugin/service/dynamic/config/impl/DynamicConfigTableServiceImpl.java @@ -10,8 +10,6 @@ import com.cm.common.exception.UpdateException; import com.cm.common.plugin.dao.dynamic.config.IDynamicConfigTableDao; import com.cm.common.plugin.enums.dynamic.FieldTypeEnum; import com.cm.common.plugin.pojo.dtos.database.table.TableDTO; -import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormDTO; -import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO; import com.cm.common.plugin.pojo.dtos.dynamic.config.DynamicConfigTableDTO; import com.cm.common.plugin.pojo.dtos.dynamic.config.form.DynamicConfigFormDTO; import com.cm.common.plugin.pojo.vos.dynamic.DynamicFormFieldVO; @@ -34,7 +32,6 @@ import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; -import sun.jvm.hotspot.oops.FieldType; import javax.servlet.http.HttpServletResponse; import java.io.*; diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/apis/ApiController.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/apis/ApiController.ftl index 969c583..88179f9 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/apis/ApiController.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/controller/apis/ApiController.ftl @@ -2,10 +2,12 @@ package ${basePackage}.controller.apis.${lowerTableName}; import com.cm.common.annotation.CheckRequestBodyAnnotation; import com.cm.common.base.AbstractController; +import com.cm.common.component.SecurityComponent; import com.cm.common.constants.ISystemConstant; import com.cm.common.exception.RemoveException; import com.cm.common.exception.SearchException; import com.cm.common.pojo.ListPage; +import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO; import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultList; @@ -34,6 +36,8 @@ public class ${firstUpperTableName}Controller extends AbstractController { @Autowired private I${firstUpperTableName}Service ${firstLowerTableName}Service; + @Autowired + private SecurityComponent securityComponent; @ApiOperation(value = "新增${tableExplain}", notes = "新增${tableExplain}接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @@ -98,4 +102,11 @@ public class ${firstUpperTableName}Controller extends AbstractController { return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page); } + @ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("getcurrentuseridinfo") + public CurrentUserIdInfoDTO getCurrentUserIdInfo() { + return securityComponent.getCurrentUserIdInfo(); + } + } \ No newline at end of file diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/mapper/mapper.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/mapper/mapper.ftl index b1bb7bd..8227f5d 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/mapper/mapper.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/mapper/mapper.ftl @@ -74,7 +74,7 @@ ${field.underLineFieldName} = ${r"#{"}${field.fieldName}${r"}"}, <#else> - + ${field.underLineFieldName} = ${r"#{"}${field.fieldName}${r"}"}, @@ -112,7 +112,7 @@ t1.${field.underLineFieldName}, <#-- 字典 start --> <#if field.fieldType == "radio" || field.fieldType == "checkbox" || field.fieldType == "select"> - GROUP_CONCAT(dt${field.dictionaryIndex}.dictionary_name) ${field.underLineFieldName}_dictionary_name, + GROUP_CONCAT(DISTINCT dt${field.dictionaryIndex}.dictionary_name) ${field.underLineFieldName}_dictionary_name, <#-- 字典 end --> diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/dto.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/dto.ftl index 2a34c21..0c97d11 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/dto.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/dto.ftl @@ -1,7 +1,5 @@ package ${basePackage}.pojo.dtos.${lowerTableName}; -import com.cm.common.annotation.CheckEmptyAnnotation; -import com.cm.common.annotation.CheckNumberAnnotation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/vo.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/vo.ftl index e9ac9cf..3f0914a 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/vo.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/pojo/vo.ftl @@ -18,17 +18,55 @@ public class ${firstUpperTableName}VO { <#list fieldList! as field> @ApiModelProperty(name = "${field.fieldName}", value = "${field.fieldExplain}") - <#if field.fieldType == "number"> + <#if field.fieldType == "join"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}") + private String ${field.fieldName}; + <#elseif field.fieldType == "number"> + @CheckNumberAnnotation(name = "${field.fieldExplain}") private Integer ${field.fieldName}; <#elseif field.fieldType == "double"> + @CheckNumberAnnotation(name = "${field.fieldExplain}") private Double ${field.fieldName}; + <#elseif field.fieldType == "date" || field.fieldType == "datetime"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "date") + private String ${field.fieldName}; <#else> + <#if field.fieldType == "string"> + <#if field.verifyType?? && field.verifyType != "none"> + <#if field.verifyType == "phone"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "phone") + <#elseif field.verifyType == "email"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "email") + <#elseif field.verifyType == "url"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "url") + <#elseif field.verifyType == "number"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "number") + <#elseif field.verifyType == "date"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "date") + <#elseif field.verifyType == "identity"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "identity") + <#elseif field.verifyType == "custom"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "custom", regex = "${field.verifyType}") + <#elseif field.verifyType == "required"> + @CheckEmptyAnnotation(name = "${field.fieldExplain}") + + + private String ${field.fieldName}; <#list fieldList! as field> - <#if field.fieldType == "number"> + <#if field.fieldType == "join"> + public String get${field.firstUpperFieldName}() { + return ${field.fieldName} == null ? "" : ${field.fieldName}; + } + + public void set${field.firstUpperFieldName}(String ${field.fieldName}) { + this.${field.fieldName} = ${field.fieldName}; + } + + <#elseif field.fieldType == "number"> public Integer get${field.firstUpperFieldName}() { return ${field.fieldName} == null ? 0 : ${field.fieldName}; } @@ -42,6 +80,15 @@ public class ${firstUpperTableName}VO { return ${field.fieldName} == null ? 0D : ${field.fieldName}; } + public void set${field.firstUpperFieldName}(String ${field.fieldName}) { + this.${field.fieldName} = ${field.fieldName}; + } + + <#elseif field.fieldType == "date" || field.fieldType == "datetime"> + public String get${field.firstUpperFieldName}() { + return ${field.fieldName} == null ? "" : ${field.fieldName}; + } + public void set${field.firstUpperFieldName}(String ${field.fieldName}) { this.${field.fieldName} = ${field.fieldName}; } diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/list.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/list.ftl index c022c5f..6fa0faa 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/list.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/list.ftl @@ -52,7 +52,7 @@ - - <#else> + <#elseif field.fieldType == "string">
- + lay-verify="<#if field.verifyType == "phone">phone<#elseif field.verifyType == "email">email<#elseif field.verifyType == "url">url<#elseif field.verifyType == "number">number<#elseif field.verifyType == "date">date<#elseif field.verifyType == "identity">identity<#elseif field.verifyType == "custom">${field.fieldName}CustomVerify<#elseif field.verifyType == "required">required">
@@ -216,7 +206,7 @@ - diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/update.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/update.ftl index 855c834..42d9754 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/update.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/route/update.ftl @@ -36,14 +36,14 @@
- +
<#elseif field.fieldType == "double">
- +
<#elseif field.fieldType == "textarea"> @@ -55,7 +55,7 @@ <#elseif field.fieldType == "richText">
- +
@@ -63,7 +63,7 @@ <#elseif field.fieldType == "select">
-
+
@@ -136,7 +136,7 @@
- +
<#elseif field.fieldType == "currentDepartment"> @@ -144,15 +144,7 @@
- -
- - <#elseif field.fieldType == "currentDepartment"> -
- -
- - +
<#elseif field.fieldType == "currentRole"> @@ -160,7 +152,7 @@
- +
<#elseif field.fieldType == "currentGroup"> @@ -168,7 +160,7 @@
- +
<#elseif field.fieldType == "currentPosition"> @@ -176,7 +168,7 @@
- +
<#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin"> @@ -192,11 +184,11 @@ - <#else> + <#elseif field.fieldType == "string">
- + lay-verify="<#if field.verifyType == "phone">phone<#elseif field.verifyType == "email">email<#elseif field.verifyType == "url">url<#elseif field.verifyType == "number">number<#elseif field.verifyType == "date">date<#elseif field.verifyType == "identity">identity<#elseif field.verifyType == "custom">${field.fieldName}CustomVerify<#elseif field.verifyType == "required">required">
@@ -227,6 +219,7 @@ var laytpl = layui.laytpl; var laydate = layui.laydate; var ${firstLowerTableName}Id = top.restAjax.params(window.location.href).${firstLowerTableName}Id; + var wangEditor = window.wangEditor; var wangEditorObj = {}; @@ -249,21 +242,7 @@ <#list fieldList! as field> <#if field.formShow == 1> - <#if field.fieldType == "checkbox"> - // 初始化${field.fieldExplain}复选框 - function init${field.firstUpperFieldName}CheckBox(checkboxValue) { - if(!checkboxValue) { - return; - } - var checkboxValue = checkboxValue.split(','); - var checkboxObj = {}; - for(var j = 0, checkbox = checkboxValue[j]; checkbox = checkboxValue[j++];) { - checkboxObj['${field.fieldName}['+ checkbox +']'] = true; - form.val('dataForm', checkboxObj); - } - } - - <#elseif field.fieldType == "date"> + <#if field.fieldType == "date"> // 初始化${field.fieldExplain}日期 function init${field.firstUpperFieldName}Date() { laydate.render({ @@ -309,6 +288,7 @@ editor.txt.html(value); wangEditorObj['${field.fieldName}'] = editor; } + <#elseif field.fieldType == "select"> // 初始化${field.fieldExplain}下拉选择 function init${field.firstUpperFieldName}Select(selectValue) { @@ -333,7 +313,7 @@ laytpl(document.getElementById('${field.fieldName}CheckboxTemplate').innerHTML).render(data, function(html) { document.getElementById('${field.fieldName}CheckboxTemplateBox').innerHTML = html; }); - form.render('checkbox'); + form.render('checkbox', '${field.fieldName}CheckboxTemplateBox'); var checkboxValue = selectValues.split(','); var checkboxObj = {}; @@ -353,7 +333,7 @@ laytpl(document.getElementById('${field.fieldName}RadioTemplate').innerHTML).render(data, function(html) { document.getElementById('${field.fieldName}RadioTemplateBox').innerHTML = html; }); - form.render('radio'); + form.render('radio', '${field.fieldName}RadioTemplateBox'); var radioObj = {}; radioObj['${field.fieldName}'] = selectValue; @@ -541,6 +521,56 @@ }); } + <#elseif field.fieldType == "currentUser"> + // 初始化${field.fieldExplain}当前用户 + function init${field.firstUpperFieldName}CurrentUser(idAndNameValue) { + var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : ''; + var currentUserObj = {}; + currentUserObj['${field.fieldName}'] = idAndNameValue; + currentUserObj['${field.fieldName}CurrentUser'] = nameValue; + form.val('dataForm', currentUserObj); + } + + <#elseif field.fieldType == "currentDepartment"> + // 初始化${field.fieldExplain}当前部门 + function init${field.firstUpperFieldName}CurrentDepartment(idAndNameValue) { + var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : ''; + var currentUserObj = {}; + currentUserObj['${field.fieldName}'] = idAndNameValue; + currentUserObj['${field.fieldName}CurrentDepartment'] = nameValue; + form.val('dataForm', currentUserObj); + } + + <#elseif field.fieldType == "currentRole"> + // 初始化${field.fieldExplain}当前角色 + function init${field.firstUpperFieldName}CurrentRole(idAndNameValue) { + var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : ''; + var currentUserObj = {}; + currentUserObj['${field.fieldName}'] = idAndNameValue; + currentUserObj['${field.fieldName}CurrentRole'] = nameValue; + form.val('dataForm', currentUserObj); + } + + <#elseif field.fieldType == "currentGroup"> + // 初始化${field.fieldExplain}当前组 + function init${field.firstUpperFieldName}CurrentGroup(idAndNameValue) { + var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : ''; + var currentUserObj = {}; + currentUserObj['${field.fieldName}'] = idAndNameValue; + currentUserObj['${field.fieldName}CurrentGroup'] = nameValue; + form.val('dataForm', currentUserObj); + } + + <#elseif field.fieldType == "currentPosition"> + // 初始化${field.fieldExplain}当前职位 + function init${field.firstUpperFieldName}CurrentPosition(idAndNameValue) { + var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : ''; + var currentUserObj = {}; + currentUserObj['${field.fieldName}'] = idAndNameValue; + currentUserObj['${field.fieldName}CurrentPosition'] = nameValue; + form.val('dataForm', currentUserObj); + } + <#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin"> // 初始化${field.fieldExplain}联表 function init${field.firstUpperFieldName}JoinTable(joinValue){ @@ -575,9 +605,7 @@ form.render(null, 'dataForm'); <#list fieldList! as field> <#if field.formShow == 1> - <#if field.fieldType == "checkbox"> - init${field.firstUpperFieldName}CheckBox(data['${field.fieldName}']); - <#elseif field.fieldType == "date"> + <#if field.fieldType == "date"> init${field.firstUpperFieldName}Date(); <#elseif field.fieldType == "datetime"> init${field.firstUpperFieldName}DateTime(); @@ -595,6 +623,16 @@ init${field.firstUpperFieldName}SelectUser(); <#elseif field.fieldType == "selectDepartment"> init${field.firstUpperFieldName}SelectDepartment(); + <#elseif field.fieldType == "currentUser"> + init${field.firstUpperFieldName}CurrentUser(data['${field.fieldName}']); + <#elseif field.fieldType == "currentDepartment"> + init${field.firstUpperFieldName}CurrentDepartment(data['${field.fieldName}']); + <#elseif field.fieldType == "currentRole"> + init${field.firstUpperFieldName}CurrentRole(data['${field.fieldName}']); + <#elseif field.fieldType == "currentGroup"> + init${field.firstUpperFieldName}CurrentGroup(data['${field.fieldName}']); + <#elseif field.fieldType == "currentPosition"> + init${field.firstUpperFieldName}CurrentPosition(data['${field.fieldName}']); <#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin"> init${field.firstUpperFieldName}JoinTable(data['${field.fieldName}']); @@ -651,6 +689,25 @@ $('.close').on('click', function() { closeBox(); }); + + // 校验 + form.verify({ + <#list fieldList! as field> + <#if field.formShow == 1> + <#if field.fieldType == "string"> + <#if field.verifyType??> + <#if field.verifyType == "custom"> + ${field.fieldName}CustomVerify: function(value, item){ + if(!new RegExp('${field.verifyRegular}').test(value)){ + return '${field.fieldExplain}格式错误'; + } + } + + + + + + }); }); diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/sql/sql.ftl b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/sql/sql.ftl index 32df8d7..07a7310 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/sql/sql.ftl +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/codetemplate/default/sql/sql.ftl @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS `${tablePrefix}${underLineTableName}`; CREATE TABLE `${tablePrefix}${underLineTableName}`( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增主键', `${underLineTableName}_id` CHAR(36) NOT NULL COMMENT '主键', diff --git a/cloud-common-plugin-dynamic/src/main/resources/templates/dynamic/config/form/save.html b/cloud-common-plugin-dynamic/src/main/resources/templates/dynamic/config/form/save.html index 0a3b7b9..6bab1a9 100644 --- a/cloud-common-plugin-dynamic/src/main/resources/templates/dynamic/config/form/save.html +++ b/cloud-common-plugin-dynamic/src/main/resources/templates/dynamic/config/form/save.html @@ -129,7 +129,7 @@
- @@ -142,7 +142,7 @@
-
+