mirror of https://gitee.com/y_project/RuoYi.git
新增自定义数据校验
parent
3fc965e0e7
commit
bf6c66a77b
|
@ -5,12 +5,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
@ -81,8 +83,12 @@ public class SysConfigController extends BaseController
|
|||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysConfig config)
|
||||
public AjaxResult addSave(@Validated SysConfig config)
|
||||
{
|
||||
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||
{
|
||||
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
config.setCreateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(configService.insertConfig(config));
|
||||
}
|
||||
|
@ -104,8 +110,12 @@ public class SysConfigController extends BaseController
|
|||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysConfig config)
|
||||
public AjaxResult editSave(@Validated SysConfig config)
|
||||
{
|
||||
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||
{
|
||||
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
config.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(configService.updateConfig(config));
|
||||
}
|
||||
|
|
|
@ -5,12 +5,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.Ztree;
|
||||
|
@ -43,7 +45,7 @@ public class SysDeptController extends BaseController
|
|||
}
|
||||
|
||||
@RequiresPermissions("system:dept:list")
|
||||
@GetMapping("/list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public List<SysDept> list(SysDept dept)
|
||||
{
|
||||
|
@ -68,8 +70,12 @@ public class SysDeptController extends BaseController
|
|||
@RequiresPermissions("system:dept:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysDept dept)
|
||||
public AjaxResult addSave(@Validated SysDept dept)
|
||||
{
|
||||
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||
{
|
||||
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
dept.setCreateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(deptService.insertDept(dept));
|
||||
}
|
||||
|
@ -96,8 +102,12 @@ public class SysDeptController extends BaseController
|
|||
@RequiresPermissions("system:dept:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysDept dept)
|
||||
public AjaxResult editSave(@Validated SysDept dept)
|
||||
{
|
||||
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||
{
|
||||
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
dept.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(deptService.updateDept(dept));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -79,7 +80,7 @@ public class SysDictDataController extends BaseController
|
|||
@RequiresPermissions("system:dict:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysDictData dict)
|
||||
public AjaxResult addSave(@Validated SysDictData dict)
|
||||
{
|
||||
dict.setCreateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
|
@ -102,7 +103,7 @@ public class SysDictDataController extends BaseController
|
|||
@RequiresPermissions("system:dict:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysDictData dict)
|
||||
public AjaxResult editSave(@Validated SysDictData dict)
|
||||
{
|
||||
dict.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
|
|
|
@ -5,12 +5,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
@ -79,8 +81,12 @@ public class SysDictTypeController extends BaseController
|
|||
@RequiresPermissions("system:dict:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysDictType dict)
|
||||
public AjaxResult addSave(@Validated SysDictType dict)
|
||||
{
|
||||
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setCreateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
}
|
||||
|
@ -102,8 +108,12 @@ public class SysDictTypeController extends BaseController
|
|||
@RequiresPermissions("system:dict:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysDictType dict)
|
||||
public AjaxResult editSave(@Validated SysDictType dict)
|
||||
{
|
||||
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(dictTypeService.updateDictType(dict));
|
||||
}
|
||||
|
|
|
@ -5,12 +5,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.Ztree;
|
||||
|
@ -42,7 +44,7 @@ public class SysMenuController extends BaseController
|
|||
}
|
||||
|
||||
@RequiresPermissions("system:menu:list")
|
||||
@GetMapping("/list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public List<SysMenu> list(SysMenu menu)
|
||||
{
|
||||
|
@ -100,8 +102,12 @@ public class SysMenuController extends BaseController
|
|||
@RequiresPermissions("system:menu:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysMenu menu)
|
||||
public AjaxResult addSave(@Validated SysMenu menu)
|
||||
{
|
||||
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||
{
|
||||
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
}
|
||||
menu.setCreateBy(ShiroUtils.getLoginName());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return toAjax(menuService.insertMenu(menu));
|
||||
|
@ -124,8 +130,12 @@ public class SysMenuController extends BaseController
|
|||
@RequiresPermissions("system:menu:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysMenu menu)
|
||||
public AjaxResult editSave(@Validated SysMenu menu)
|
||||
{
|
||||
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||
{
|
||||
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
}
|
||||
menu.setUpdateBy(ShiroUtils.getLoginName());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return toAjax(menuService.updateMenu(menu));
|
||||
|
|
|
@ -5,12 +5,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
@ -94,8 +96,16 @@ public class SysPostController extends BaseController
|
|||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysPost post)
|
||||
public AjaxResult addSave(@Validated SysPost post)
|
||||
{
|
||||
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||
{
|
||||
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
}
|
||||
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||
{
|
||||
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setCreateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(postService.insertPost(post));
|
||||
}
|
||||
|
@ -117,8 +127,16 @@ public class SysPostController extends BaseController
|
|||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysPost post)
|
||||
public AjaxResult editSave(@Validated SysPost post)
|
||||
{
|
||||
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||
{
|
||||
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
}
|
||||
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||
{
|
||||
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(postService.updatePost(post));
|
||||
}
|
||||
|
|
|
@ -5,12 +5,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
@ -84,8 +86,16 @@ public class SysRoleController extends BaseController
|
|||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysRole role)
|
||||
public AjaxResult addSave(@Validated SysRole role)
|
||||
{
|
||||
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||
{
|
||||
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
}
|
||||
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||
{
|
||||
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setCreateBy(ShiroUtils.getLoginName());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return toAjax(roleService.insertRole(role));
|
||||
|
@ -109,8 +119,16 @@ public class SysRoleController extends BaseController
|
|||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysRole role)
|
||||
public AjaxResult editSave(@Validated SysRole role)
|
||||
{
|
||||
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||
{
|
||||
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
}
|
||||
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||
{
|
||||
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setUpdateBy(ShiroUtils.getLoginName());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return toAjax(roleService.updateRole(role));
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -117,23 +118,19 @@ public class SysUserController extends BaseController
|
|||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysUser user)
|
||||
public AjaxResult addSave(@Validated SysUser user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId()))
|
||||
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
|
||||
{
|
||||
return error("不允许修改超级管理员用户");
|
||||
}
|
||||
else if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
|
||||
{
|
||||
return error("保存用户'" + user.getLoginName() + "'失败,登录账号已存在");
|
||||
return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
|
||||
}
|
||||
else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
{
|
||||
return error("保存用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
||||
return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
return error("保存用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
||||
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setSalt(ShiroUtils.randomSalt());
|
||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
||||
|
@ -160,7 +157,7 @@ public class SysUserController extends BaseController
|
|||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysUser user)
|
||||
public AjaxResult editSave(@Validated SysUser user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId()))
|
||||
{
|
||||
|
@ -168,11 +165,11 @@ public class SysUserController extends BaseController
|
|||
}
|
||||
else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
{
|
||||
return error("保存用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
||||
return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
return error("保存用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
||||
return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return toAjax(userService.updateUser(user));
|
||||
|
|
|
@ -429,7 +429,7 @@
|
|||
$.bttTable = $('#' + options.id).bootstrapTreeTable({
|
||||
code: options.code, // 用于设置父子关系
|
||||
parentCode: options.parentCode, // 用于设置父子关系
|
||||
type: 'get', // 请求方式(*)
|
||||
type: 'post', // 请求方式(*)
|
||||
url: options.url, // 请求后台的URL(*)
|
||||
ajaxParams: options.ajaxParams, // 请求数据的ajax的data属性
|
||||
rootIdValue: options.rootIdValue, // 设置指定根节点id值
|
||||
|
@ -845,7 +845,7 @@
|
|||
},
|
||||
// 添加访问地址
|
||||
addUrl: function(id) {
|
||||
var url = $.common.isEmpty(id) ? $.table._option.createUrl : $.table._option.createUrl.replace("{id}", id);
|
||||
var url = $.common.isEmpty(id) ? $.table._option.createUrl.replace("{id}", "") : $.table._option.createUrl.replace("{id}", id);
|
||||
return url;
|
||||
},
|
||||
// 修改信息
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 自定义验证注解 -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--常用工具类 -->
|
||||
<dependency>
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package com.ruoyi.framework.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import com.ruoyi.common.config.Global;
|
||||
import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
|
||||
|
||||
/**
|
||||
* 通用配置
|
||||
|
@ -21,6 +25,9 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|||
@Value("${shiro.user.indexUrl}")
|
||||
private String indexUrl;
|
||||
|
||||
@Autowired
|
||||
private RepeatSubmitInterceptor repeatSubmitInterceptor;
|
||||
|
||||
/**
|
||||
* 默认首页的设置,当输入域名是可以自动跳转到默认指定的网页
|
||||
*/
|
||||
|
@ -40,4 +47,13 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|||
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义拦截规则
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry)
|
||||
{
|
||||
registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
@ -93,6 +94,17 @@ public class GlobalExceptionHandler
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public AjaxResult validatedBindException(BindException e)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 演示模式异常
|
||||
*/
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.quartz.SchedulerException;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -125,7 +126,7 @@ public class SysJobController extends BaseController
|
|||
@RequiresPermissions("monitor:job:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysJob job) throws SchedulerException, TaskException
|
||||
public AjaxResult addSave(@Validated SysJob job) throws SchedulerException, TaskException
|
||||
{
|
||||
return toAjax(jobService.insertJob(job));
|
||||
}
|
||||
|
@ -147,7 +148,7 @@ public class SysJobController extends BaseController
|
|||
@RequiresPermissions("monitor:job:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysJob job) throws SchedulerException, TaskException
|
||||
public AjaxResult editSave(@Validated SysJob job) throws SchedulerException, TaskException
|
||||
{
|
||||
return toAjax(jobService.updateJob(job));
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.quartz.domain;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
@ -61,6 +62,8 @@ public class SysJob extends BaseEntity implements Serializable
|
|||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "任务名称不能为空")
|
||||
@Size(min = 0, max = 64, message = "任务名称不能超过64个字符")
|
||||
public String getJobName()
|
||||
{
|
||||
return jobName;
|
||||
|
@ -81,6 +84,8 @@ public class SysJob extends BaseEntity implements Serializable
|
|||
this.jobGroup = jobGroup;
|
||||
}
|
||||
|
||||
@NotBlank(message = "调用目标字符串不能为空")
|
||||
@Size(min = 0, max = 1000, message = "调用目标字符串长度不能超过500个字符")
|
||||
public String getInvokeTarget()
|
||||
{
|
||||
return invokeTarget;
|
||||
|
@ -91,6 +96,8 @@ public class SysJob extends BaseEntity implements Serializable
|
|||
this.invokeTarget = invokeTarget;
|
||||
}
|
||||
|
||||
@NotBlank(message = "Cron执行表达式不能为空")
|
||||
@Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符")
|
||||
public String getCronExpression()
|
||||
{
|
||||
return cronExpression;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
@ -44,6 +45,8 @@ public class SysConfig extends BaseEntity
|
|||
this.configId = configId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
@Size(min = 0, max = 100, message = "参数名称不能超过100个字符")
|
||||
public String getConfigName()
|
||||
{
|
||||
return configName;
|
||||
|
@ -54,6 +57,8 @@ public class SysConfig extends BaseEntity
|
|||
this.configName = configName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "参数键名长度不能为空")
|
||||
@Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符")
|
||||
public String getConfigKey()
|
||||
{
|
||||
return configKey;
|
||||
|
@ -64,6 +69,8 @@ public class SysConfig extends BaseEntity
|
|||
this.configKey = configKey;
|
||||
}
|
||||
|
||||
@NotBlank(message = "参数键值不能为空")
|
||||
@Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符")
|
||||
public String getConfigValue()
|
||||
{
|
||||
return configValue;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
@ -33,7 +34,7 @@ public class SysDept extends BaseEntity
|
|||
|
||||
/** 联系电话 */
|
||||
private String phone;
|
||||
|
||||
|
||||
/** 邮箱 */
|
||||
private String email;
|
||||
|
||||
|
@ -76,6 +77,8 @@ public class SysDept extends BaseEntity
|
|||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||
public String getDeptName()
|
||||
{
|
||||
return deptName;
|
||||
|
@ -86,6 +89,7 @@ public class SysDept extends BaseEntity
|
|||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
public String getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
|
@ -106,6 +110,7 @@ public class SysDept extends BaseEntity
|
|||
this.leader = leader;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
||||
public String getPhone()
|
||||
{
|
||||
return phone;
|
||||
|
@ -116,6 +121,8 @@ public class SysDept extends BaseEntity
|
|||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
@ -70,6 +71,8 @@ public class SysDictData extends BaseEntity
|
|||
this.dictSort = dictSort;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
||||
public String getDictLabel()
|
||||
{
|
||||
return dictLabel;
|
||||
|
@ -80,6 +83,8 @@ public class SysDictData extends BaseEntity
|
|||
this.dictLabel = dictLabel;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
||||
public String getDictValue()
|
||||
{
|
||||
return dictValue;
|
||||
|
@ -90,6 +95,8 @@ public class SysDictData extends BaseEntity
|
|||
this.dictValue = dictValue;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
||||
public String getDictType()
|
||||
{
|
||||
return dictType;
|
||||
|
@ -100,6 +107,7 @@ public class SysDictData extends BaseEntity
|
|||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
||||
public String getCssClass()
|
||||
{
|
||||
return cssClass;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
@ -40,6 +41,8 @@ public class SysDictType extends BaseEntity
|
|||
this.dictId = dictId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典名称不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||
public String getDictName()
|
||||
{
|
||||
return dictName;
|
||||
|
@ -50,6 +53,8 @@ public class SysDictType extends BaseEntity
|
|||
this.dictName = dictName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
public String getDictType()
|
||||
{
|
||||
return dictType;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单权限表 sys_menu
|
||||
|
@ -61,6 +62,8 @@ public class SysMenu extends BaseEntity
|
|||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
||||
public String getMenuName()
|
||||
{
|
||||
return menuName;
|
||||
|
@ -91,6 +94,7 @@ public class SysMenu extends BaseEntity
|
|||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
public String getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
|
@ -101,6 +105,7 @@ public class SysMenu extends BaseEntity
|
|||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "请求地址不能超过200个字符")
|
||||
public String getUrl()
|
||||
{
|
||||
return url;
|
||||
|
@ -121,6 +126,7 @@ public class SysMenu extends BaseEntity
|
|||
this.target = target;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单类型不能为空")
|
||||
public String getMenuType()
|
||||
{
|
||||
return menuType;
|
||||
|
@ -141,6 +147,7 @@ public class SysMenu extends BaseEntity
|
|||
this.visible = visible;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
||||
public String getPerms()
|
||||
{
|
||||
return perms;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
@ -15,16 +16,16 @@ public class SysNotice extends BaseEntity
|
|||
|
||||
/** 公告ID */
|
||||
private Long noticeId;
|
||||
|
||||
|
||||
/** 公告标题 */
|
||||
private String noticeTitle;
|
||||
|
||||
|
||||
/** 公告类型(1通知 2公告) */
|
||||
private String noticeType;
|
||||
|
||||
|
||||
/** 公告内容 */
|
||||
private String noticeContent;
|
||||
|
||||
|
||||
/** 公告状态(0正常 1关闭) */
|
||||
private String status;
|
||||
|
||||
|
@ -43,6 +44,8 @@ public class SysNotice extends BaseEntity
|
|||
this.noticeTitle = noticeTitle;
|
||||
}
|
||||
|
||||
@NotBlank(message = "公告标题不能为空")
|
||||
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
|
||||
public String getNoticeTitle()
|
||||
{
|
||||
return noticeTitle;
|
||||
|
@ -77,7 +80,7 @@ public class SysNotice extends BaseEntity
|
|||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
@ -47,6 +48,8 @@ public class SysPost extends BaseEntity
|
|||
this.postId = postId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "岗位编码不能为空")
|
||||
@Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符")
|
||||
public String getPostCode()
|
||||
{
|
||||
return postCode;
|
||||
|
@ -57,6 +60,8 @@ public class SysPost extends BaseEntity
|
|||
this.postCode = postCode;
|
||||
}
|
||||
|
||||
@NotBlank(message = "岗位名称不能为空")
|
||||
@Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符")
|
||||
public String getPostName()
|
||||
{
|
||||
return postName;
|
||||
|
@ -67,6 +72,7 @@ public class SysPost extends BaseEntity
|
|||
this.postName = postName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
public String getPostSort()
|
||||
{
|
||||
return postSort;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
@ -70,6 +71,8 @@ public class SysRole extends BaseEntity
|
|||
this.dataScope = dataScope;
|
||||
}
|
||||
|
||||
@NotBlank(message = "角色名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
||||
public String getRoleName()
|
||||
{
|
||||
return roleName;
|
||||
|
@ -80,6 +83,8 @@ public class SysRole extends BaseEntity
|
|||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "权限字符不能为空")
|
||||
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
||||
public String getRoleKey()
|
||||
{
|
||||
return roleKey;
|
||||
|
@ -90,6 +95,7 @@ public class SysRole extends BaseEntity
|
|||
this.roleKey = roleKey;
|
||||
}
|
||||
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
public String getRoleSort()
|
||||
{
|
||||
return roleSort;
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.system.domain;
|
|||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
@ -28,7 +29,7 @@ public class SysUser extends BaseEntity
|
|||
|
||||
/** 部门父ID */
|
||||
private Long parentId;
|
||||
|
||||
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
|
@ -141,6 +142,8 @@ public class SysUser extends BaseEntity
|
|||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "登录账号不能为空")
|
||||
@Size(min = 0, max = 30, message = "登录账号长度不能超过30个字符")
|
||||
public String getLoginName()
|
||||
{
|
||||
return loginName;
|
||||
|
@ -151,6 +154,7 @@ public class SysUser extends BaseEntity
|
|||
this.loginName = loginName;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
public String getUserName()
|
||||
{
|
||||
return userName;
|
||||
|
@ -161,6 +165,8 @@ public class SysUser extends BaseEntity
|
|||
this.userName = userName;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
|
@ -171,6 +177,7 @@ public class SysUser extends BaseEntity
|
|||
this.email = email;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
|
||||
public String getPhonenumber()
|
||||
{
|
||||
return phonenumber;
|
||||
|
|
|
@ -512,7 +512,7 @@ create table sys_config (
|
|||
config_id int(5) not null auto_increment comment '参数主键',
|
||||
config_name varchar(100) default '' comment '参数名称',
|
||||
config_key varchar(100) default '' comment '参数键名',
|
||||
config_value varchar(100) default '' comment '参数键值',
|
||||
config_value varchar(500) default '' comment '参数键值',
|
||||
config_type char(1) default 'N' comment '系统内置(Y是 N否)',
|
||||
create_by varchar(64) default '' comment '创建者',
|
||||
create_time datetime comment '创建时间',
|
Loading…
Reference in New Issue