判空修改
This commit is contained in:
parent
6f08e9e37f
commit
bb859aa36a
|
|
@ -3,7 +3,7 @@ import request from '@/utils/request'
|
|||
// 查询校验规则列表
|
||||
export function listRegular(query) {
|
||||
return request({
|
||||
url: '/tool/regular/list',
|
||||
url: '/tool/regular/option',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
|
|
|
|||
|
|
@ -84,9 +84,11 @@
|
|||
<el-table-column label="是否正则" min-width="10%">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.isRegular">
|
||||
<el-option v-for="item in regularOptions" :key="item.id"
|
||||
<el-option v-for="item in regularOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id" />
|
||||
<span></span>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -169,6 +171,7 @@ export default {
|
|||
};
|
||||
},
|
||||
created() {
|
||||
this.getRegularList()
|
||||
const tableId = this.$route.params && this.$route.params.tableId;
|
||||
if (tableId) {
|
||||
// 获取表详细信息
|
||||
|
|
@ -185,7 +188,6 @@ export default {
|
|||
getMenuTreeselect().then(response => {
|
||||
this.menus = this.handleTree(response.data, "menuId");
|
||||
});
|
||||
this.getRegularList()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ spring:
|
|||
redis:
|
||||
# 地址
|
||||
# host: 114.215.82.135
|
||||
host: 127.0.0.1
|
||||
# host: 13.70.28.14
|
||||
# host: 127.0.0.1
|
||||
host: 13.70.28.14
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 密码
|
||||
|
|
|
|||
|
|
@ -61,6 +61,27 @@ public class RegularController extends GenBaseController {
|
|||
return AjaxResult.error(GenReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 查询校验规则列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ebts.hasPermi('tool:regular:option')")
|
||||
@GetMapping("/option")
|
||||
public Serializable option() {
|
||||
try {
|
||||
startPage();
|
||||
GenServerResult<List<Regular>> genServerResult = regularService.selectRegularOption();
|
||||
if (genServerResult.isStart()) {
|
||||
return getDataTable(genServerResult.getData());
|
||||
} else {
|
||||
return AjaxResult.info(genServerResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(GenReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出校验规则列表
|
||||
|
|
|
|||
|
|
@ -26,6 +26,12 @@ public interface RegularDao {
|
|||
* @return 校验规则集合
|
||||
*/
|
||||
List<Regular> selectRegularList(Regular regular);
|
||||
/**
|
||||
* 查询校验规则下拉框列表
|
||||
*
|
||||
* @return 校验规则集合
|
||||
*/
|
||||
List<Regular> selectRegularOption();
|
||||
|
||||
/**
|
||||
* 新增校验规则
|
||||
|
|
|
|||
|
|
@ -27,6 +27,12 @@ public interface RegularService {
|
|||
* @return 校验规则集合
|
||||
*/
|
||||
GenServerResult<List<Regular>> selectRegularList(Regular regular);
|
||||
/**
|
||||
* 查询校验规则下拉框列表
|
||||
*
|
||||
* @return 校验规则集合
|
||||
*/
|
||||
GenServerResult<List<Regular>> selectRegularOption();
|
||||
|
||||
/**
|
||||
* 新增校验规则
|
||||
|
|
|
|||
|
|
@ -68,6 +68,25 @@ public class RegularServiceImpl implements RegularService {
|
|||
return new GenServerResult<>(false, GenReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 查询校验规则下拉框列表
|
||||
*
|
||||
* @return 校验规则
|
||||
*/
|
||||
@Override
|
||||
public GenServerResult<List<Regular>> selectRegularOption() {
|
||||
try {
|
||||
List<Regular> regulars = regularDao.selectRegularOption();
|
||||
if (regulars.size() > 0) {
|
||||
return new GenServerResult<>(true, regulars);
|
||||
} else {
|
||||
return new GenServerResult<>(false, GenReturnConstants.RESULT_EMPTY);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return new GenServerResult<>(false, GenReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增校验规则
|
||||
|
|
|
|||
|
|
@ -23,13 +23,16 @@
|
|||
<select id="selectRegularList" parameterType="Regular" resultMap="RegularResult">
|
||||
<include refid="selectRegularVo"/>
|
||||
<where>
|
||||
and id != 1
|
||||
<if test="1=1">and id != 1</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="regular != null and regular != ''"> and regular like concat('%', #{regular}, '%')</if>
|
||||
<if test="validation != null and validation != ''"> and validation like concat('%', #{validation}, '%')</if>
|
||||
<if test="enable != null "> and enable = #{enable}</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectRegularOption" parameterType="Regular" resultMap="RegularResult">
|
||||
select id ,name from gen_regular where enable = 1
|
||||
</select>
|
||||
|
||||
<select id="selectRegularById" parameterType="Long" resultMap="RegularResult">
|
||||
<include refid="selectRegularVo"/>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
|
@ -128,28 +129,7 @@ public class ${ClassName}Controller extends EBTSController {
|
|||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:add')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ${ClassName} ${className}) {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isRequired == 1)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
#if($column.javaType.equals("String"))
|
||||
if (${className}.get${AttrName}() == null || ${className}.get${AttrName}().equals("")) {
|
||||
#elseif($column.javaType.equals("Integer")||$column.javaType.equals("Long"))
|
||||
if (${className}.get${AttrName}() == null || ${className}.get${AttrName}()<0) {
|
||||
#end
|
||||
return AjaxResult.error("${column.columnComment}不能为空!");
|
||||
}
|
||||
#end
|
||||
#if($column.isRegular != 1)
|
||||
if (!Pattern.matches("${column.regular}",${className}.get${AttrName}())){
|
||||
return AjaxResult.error("${column.columnComment}格式错误!");
|
||||
}
|
||||
#end
|
||||
#end
|
||||
public AjaxResult add(@Validated @RequestBody ${ClassName} ${className}) {
|
||||
try {
|
||||
ServerResult<Integer> genServerResult = ${className}Service.insert${ClassName}(${className});
|
||||
if (genServerResult.isStart()) {
|
||||
|
|
@ -171,30 +151,8 @@ public class ${ClassName}Controller extends EBTSController {
|
|||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:edit')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ${ClassName} ${className}) {
|
||||
public AjaxResult edit(@Validated @RequestBody ${ClassName} ${className}) {
|
||||
try {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isRequired == 1)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
#if($column.javaType.equals("String"))
|
||||
if (${className}.get${AttrName}() == null || ${className}.get${AttrName}().equals("")) {
|
||||
#elseif($column.javaType.equals("Integer")||$column.javaType.equals("Long"))
|
||||
if (${className}.get${AttrName}() == null || ${className}.get${AttrName}()<0) {
|
||||
#end
|
||||
return AjaxResult.error("${column.columnComment}不能为空!");
|
||||
}
|
||||
#end
|
||||
#if($column.isRegular != 1)
|
||||
if (!Pattern.matches("${column.regular}",${className}.get${AttrName}())){
|
||||
return AjaxResult.error("${column.columnComment}格式错误!");
|
||||
}
|
||||
#end
|
||||
#end
|
||||
ServerResult<Integer> genServerResult = ${className}Service.update${ClassName}(${className});
|
||||
if (genServerResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import ${packageName}.entity.${subClassName};
|
|||
#end
|
||||
import com.ebts.common.core.entity.${Entity};
|
||||
import com.ebts.common.annotation.Excel;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
|
@ -52,6 +54,12 @@ public class ${ClassName} extends ${Entity}{
|
|||
#else
|
||||
@Excel(name = "${comment}")
|
||||
#end
|
||||
#end
|
||||
#if($column.isRequired == 1)
|
||||
@NotNull(message = "${column.columnComment}不能为空!")
|
||||
#end
|
||||
#if($column.isRegular != 1)
|
||||
@Pattern(regexp = "${column.regular}",message = "${column.columnComment}格式错误!")
|
||||
#end
|
||||
@ApiModelProperty("${column.columnComment}")
|
||||
private $column.javaType $column.javaField;
|
||||
|
|
|
|||
Loading…
Reference in New Issue