From ebb9f15a75562963afd2bce8c089006d686fe7f8 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 30 Oct 2022 12:02:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BF=94=E5=9B=9E=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitor/SysOperlogController.java | 2 +- .../monitor/SysUserOnlineController.java | 2 +- .../system/SysConfigController.java | 10 ++++---- .../controller/system/SysDeptController.java | 18 +++++++-------- .../system/SysDictDataController.java | 4 ++-- .../system/SysDictTypeController.java | 10 ++++---- .../controller/system/SysMenuController.java | 20 ++++++++-------- .../system/SysNoticeController.java | 2 +- .../controller/system/SysPostController.java | 12 +++++----- .../system/SysProfileController.java | 18 +++++++-------- .../controller/system/SysRoleController.java | 16 ++++++------- .../controller/system/SysUserController.java | 16 ++++++------- .../com/ruoyi/common/constant/HttpStatus.java | 5 ++++ .../core/controller/BaseController.java | 16 +++++++++++++ .../ruoyi/common/core/domain/AjaxResult.java | 23 +++++++++++++++++++ .../generator/controller/GenController.java | 14 +++++------ .../main/resources/vm/java/controller.java.vm | 4 ++-- .../quartz/controller/SysJobController.java | 2 +- .../controller/SysJobLogController.java | 4 ++-- ruoyi-ui/src/utils/request.js | 6 +++++ 20 files changed, 127 insertions(+), 77 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java index 4ce126a..5378424 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java @@ -64,6 +64,6 @@ public class SysOperlogController extends BaseController public AjaxResult clean() { operLogService.cleanOperLog(); - return AjaxResult.success(); + return success(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java index 6c2b3be..22e3962 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java @@ -87,6 +87,6 @@ public class SysUserOnlineController extends BaseController public AjaxResult forceLogout(@PathVariable String tokenId) { redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); - return AjaxResult.success(); + return success(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java index 04f7162..93275e9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java @@ -64,7 +64,7 @@ public class SysConfigController extends BaseController @GetMapping(value = "/{configId}") public AjaxResult getInfo(@PathVariable Long configId) { - return AjaxResult.success(configService.selectConfigById(configId)); + return success(configService.selectConfigById(configId)); } /** @@ -73,7 +73,7 @@ public class SysConfigController extends BaseController @GetMapping(value = "/configKey/{configKey}") public AjaxResult getConfigKey(@PathVariable String configKey) { - return AjaxResult.success(configService.selectConfigByKey(configKey)); + return success(configService.selectConfigByKey(configKey)); } /** @@ -86,7 +86,7 @@ public class SysConfigController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) { - return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); + return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); } config.setCreateBy(getUsername()); return toAjax(configService.insertConfig(config)); @@ -102,7 +102,7 @@ public class SysConfigController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) { - return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); + return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); } config.setUpdateBy(getUsername()); return toAjax(configService.updateConfig(config)); @@ -129,6 +129,6 @@ public class SysConfigController extends BaseController public AjaxResult refreshCache() { configService.resetConfigCache(); - return AjaxResult.success(); + return success(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index 6dd1756..a873066 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -42,7 +42,7 @@ public class SysDeptController extends BaseController public AjaxResult list(SysDept dept) { List depts = deptService.selectDeptList(dept); - return AjaxResult.success(depts); + return success(depts); } /** @@ -54,7 +54,7 @@ public class SysDeptController extends BaseController { List depts = deptService.selectDeptList(new SysDept()); depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); - return AjaxResult.success(depts); + return success(depts); } /** @@ -65,7 +65,7 @@ public class SysDeptController extends BaseController public AjaxResult getInfo(@PathVariable Long deptId) { deptService.checkDeptDataScope(deptId); - return AjaxResult.success(deptService.selectDeptById(deptId)); + return success(deptService.selectDeptById(deptId)); } /** @@ -78,7 +78,7 @@ public class SysDeptController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { - return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } dept.setCreateBy(getUsername()); return toAjax(deptService.insertDept(dept)); @@ -96,15 +96,15 @@ public class SysDeptController extends BaseController deptService.checkDeptDataScope(deptId); if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { - return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } else if (dept.getParentId().equals(deptId)) { - return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); + return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) { - return AjaxResult.error("该部门包含未停用的子部门!"); + return error("该部门包含未停用的子部门!"); } dept.setUpdateBy(getUsername()); return toAjax(deptService.updateDept(dept)); @@ -120,11 +120,11 @@ public class SysDeptController extends BaseController { if (deptService.hasChildByDeptId(deptId)) { - return AjaxResult.error("存在下级部门,不允许删除"); + return warn("存在下级部门,不允许删除"); } if (deptService.checkDeptExistUser(deptId)) { - return AjaxResult.error("部门存在用户,不允许删除"); + return warn("部门存在用户,不允许删除"); } deptService.checkDeptDataScope(deptId); return toAjax(deptService.deleteDeptById(deptId)); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java index eea89fd..1914b99 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -66,7 +66,7 @@ public class SysDictDataController extends BaseController @GetMapping(value = "/{dictCode}") public AjaxResult getInfo(@PathVariable Long dictCode) { - return AjaxResult.success(dictDataService.selectDictDataById(dictCode)); + return success(dictDataService.selectDictDataById(dictCode)); } /** @@ -80,7 +80,7 @@ public class SysDictDataController extends BaseController { data = new ArrayList(); } - return AjaxResult.success(data); + return success(data); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java index 0dd3474..bfd467e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java @@ -61,7 +61,7 @@ public class SysDictTypeController extends BaseController @GetMapping(value = "/{dictId}") public AjaxResult getInfo(@PathVariable Long dictId) { - return AjaxResult.success(dictTypeService.selectDictTypeById(dictId)); + return success(dictTypeService.selectDictTypeById(dictId)); } /** @@ -74,7 +74,7 @@ public class SysDictTypeController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) { - return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); + return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); } dict.setCreateBy(getUsername()); return toAjax(dictTypeService.insertDictType(dict)); @@ -90,7 +90,7 @@ public class SysDictTypeController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) { - return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); + return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); } dict.setUpdateBy(getUsername()); return toAjax(dictTypeService.updateDictType(dict)); @@ -117,7 +117,7 @@ public class SysDictTypeController extends BaseController public AjaxResult refreshCache() { dictTypeService.resetDictCache(); - return AjaxResult.success(); + return success(); } /** @@ -127,6 +127,6 @@ public class SysDictTypeController extends BaseController public AjaxResult optionselect() { List dictTypes = dictTypeService.selectDictTypeAll(); - return AjaxResult.success(dictTypes); + return success(dictTypes); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java index 9ab14d2..a360512 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java @@ -41,7 +41,7 @@ public class SysMenuController extends BaseController public AjaxResult list(SysMenu menu) { List menus = menuService.selectMenuList(menu, getUserId()); - return AjaxResult.success(menus); + return success(menus); } /** @@ -51,7 +51,7 @@ public class SysMenuController extends BaseController @GetMapping(value = "/{menuId}") public AjaxResult getInfo(@PathVariable Long menuId) { - return AjaxResult.success(menuService.selectMenuById(menuId)); + return success(menuService.selectMenuById(menuId)); } /** @@ -61,7 +61,7 @@ public class SysMenuController extends BaseController public AjaxResult treeselect(SysMenu menu) { List menus = menuService.selectMenuList(menu, getUserId()); - return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); + return success(menuService.buildMenuTreeSelect(menus)); } /** @@ -87,11 +87,11 @@ public class SysMenuController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { - return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); + return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { - return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); + return error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); } menu.setCreateBy(getUsername()); return toAjax(menuService.insertMenu(menu)); @@ -107,15 +107,15 @@ public class SysMenuController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { - return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); + return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { - return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); + return error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); } else if (menu.getMenuId().equals(menu.getParentId())) { - return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); + return error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); } menu.setUpdateBy(getUsername()); return toAjax(menuService.updateMenu(menu)); @@ -131,11 +131,11 @@ public class SysMenuController extends BaseController { if (menuService.hasChildByMenuId(menuId)) { - return AjaxResult.error("存在子菜单,不允许删除"); + return warn("存在子菜单,不允许删除"); } if (menuService.checkMenuExistRole(menuId)) { - return AjaxResult.error("菜单已分配,不允许删除"); + return warn("菜单已分配,不允许删除"); } return toAjax(menuService.deleteMenuById(menuId)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java index 2580248..36c62b9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java @@ -51,7 +51,7 @@ public class SysNoticeController extends BaseController @GetMapping(value = "/{noticeId}") public AjaxResult getInfo(@PathVariable Long noticeId) { - return AjaxResult.success(noticeService.selectNoticeById(noticeId)); + return success(noticeService.selectNoticeById(noticeId)); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java index 1a2b408..6a206cc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java @@ -64,7 +64,7 @@ public class SysPostController extends BaseController @GetMapping(value = "/{postId}") public AjaxResult getInfo(@PathVariable Long postId) { - return AjaxResult.success(postService.selectPostById(postId)); + return success(postService.selectPostById(postId)); } /** @@ -77,11 +77,11 @@ public class SysPostController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { - return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { - return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); } post.setCreateBy(getUsername()); return toAjax(postService.insertPost(post)); @@ -97,11 +97,11 @@ public class SysPostController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { - return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { - return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); } post.setUpdateBy(getUsername()); return toAjax(postService.updatePost(post)); @@ -125,6 +125,6 @@ public class SysPostController extends BaseController public AjaxResult optionselect() { List posts = postService.selectPostAll(); - return AjaxResult.success(posts); + return success(posts); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java index 715ad32..784768b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -66,12 +66,12 @@ public class SysProfileController extends BaseController if (StringUtils.isNotEmpty(user.getPhonenumber()) && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { - return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); + return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); } if (StringUtils.isNotEmpty(user.getEmail()) && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { - return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } user.setUserId(sysUser.getUserId()); user.setPassword(null); @@ -85,9 +85,9 @@ public class SysProfileController extends BaseController sysUser.setEmail(user.getEmail()); sysUser.setSex(user.getSex()); tokenService.setLoginUser(loginUser); - return AjaxResult.success(); + return success(); } - return AjaxResult.error("修改个人信息异常,请联系管理员"); + return error("修改个人信息异常,请联系管理员"); } /** @@ -102,20 +102,20 @@ public class SysProfileController extends BaseController String password = loginUser.getPassword(); if (!SecurityUtils.matchesPassword(oldPassword, password)) { - return AjaxResult.error("修改密码失败,旧密码错误"); + return error("修改密码失败,旧密码错误"); } if (SecurityUtils.matchesPassword(newPassword, password)) { - return AjaxResult.error("新密码不能与旧密码相同"); + return error("新密码不能与旧密码相同"); } if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) { // 更新缓存用户密码 loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword)); tokenService.setLoginUser(loginUser); - return AjaxResult.success(); + return success(); } - return AjaxResult.error("修改密码异常,请联系管理员"); + return error("修改密码异常,请联系管理员"); } /** @@ -139,6 +139,6 @@ public class SysProfileController extends BaseController return ajax; } } - return AjaxResult.error("上传图片异常,请联系管理员"); + return error("上传图片异常,请联系管理员"); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java index a2c8d4d..7aaf805 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java @@ -83,7 +83,7 @@ public class SysRoleController extends BaseController public AjaxResult getInfo(@PathVariable Long roleId) { roleService.checkRoleDataScope(roleId); - return AjaxResult.success(roleService.selectRoleById(roleId)); + return success(roleService.selectRoleById(roleId)); } /** @@ -96,11 +96,11 @@ public class SysRoleController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { - return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); + return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { - return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); + return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setCreateBy(getUsername()); return toAjax(roleService.insertRole(role)); @@ -119,11 +119,11 @@ public class SysRoleController extends BaseController roleService.checkRoleDataScope(role.getRoleId()); if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { - return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); + return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { - return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); + return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setUpdateBy(getUsername()); @@ -137,9 +137,9 @@ public class SysRoleController extends BaseController loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); tokenService.setLoginUser(loginUser); } - return AjaxResult.success(); + return success(); } - return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); + return error("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); } /** @@ -187,7 +187,7 @@ public class SysRoleController extends BaseController @GetMapping("/optionselect") public AjaxResult optionselect() { - return AjaxResult.success(roleService.selectRoleAll()); + return success(roleService.selectRoleAll()); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index e4bcf78..f40f8b2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -85,7 +85,7 @@ public class SysUserController extends BaseController List userList = util.importExcel(file.getInputStream()); String operName = getUsername(); String message = userService.importUser(userList, updateSupport, operName); - return AjaxResult.success(message); + return success(message); } @PostMapping("/importTemplate") @@ -127,17 +127,17 @@ public class SysUserController extends BaseController { if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) { - return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); + return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { - return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); + return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); } else if (StringUtils.isNotEmpty(user.getEmail()) && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { - return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } user.setCreateBy(getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); @@ -156,17 +156,17 @@ public class SysUserController extends BaseController userService.checkUserDataScope(user.getUserId()); if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) { - return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); + return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { - return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); + return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); } else if (StringUtils.isNotEmpty(user.getEmail()) && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { - return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } user.setUpdateBy(getUsername()); return toAjax(userService.updateUser(user)); @@ -251,6 +251,6 @@ public class SysUserController extends BaseController @GetMapping("/deptTree") public AjaxResult deptTree(SysDept dept) { - return AjaxResult.success(deptService.selectDeptTreeList(dept)); + return success(deptService.selectDeptTreeList(dept)); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java index 77a479b..db839c5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java @@ -86,4 +86,9 @@ public class HttpStatus * 接口未实现 */ public static final int NOT_IMPLEMENTED = 501; + + /** + * 系统警告消息 + */ + public static final int WARN = 601; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index b96d93c..c131bc4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -113,6 +113,14 @@ public class BaseController { return AjaxResult.success(message); } + + /** + * 返回成功消息 + */ + public AjaxResult success(Object data) + { + return AjaxResult.success(data); + } /** * 返回失败消息 @@ -122,6 +130,14 @@ public class BaseController return AjaxResult.error(message); } + /** + * 返回警告消息 + */ + public AjaxResult warn(String message) + { + return AjaxResult.warn(message); + } + /** * 响应返回结果 * diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java index 8ca1b9b..ad9d96b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java @@ -101,6 +101,29 @@ public class AjaxResult extends HashMap return new AjaxResult(HttpStatus.SUCCESS, msg, data); } + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult warn(String msg) + { + return AjaxResult.warn(msg, null); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult warn(String msg, Object data) + { + return new AjaxResult(HttpStatus.WARN, msg, data); + } + /** * 返回错误消息 * diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java index 2e9e760..af9f4ee 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java @@ -69,7 +69,7 @@ public class GenController extends BaseController map.put("info", table); map.put("rows", list); map.put("tables", tables); - return AjaxResult.success(map); + return success(map); } /** @@ -110,7 +110,7 @@ public class GenController extends BaseController // 查询表信息 List tableList = genTableService.selectDbTableListByNames(tableNames); genTableService.importGenTable(tableList); - return AjaxResult.success(); + return success(); } /** @@ -123,7 +123,7 @@ public class GenController extends BaseController { genTableService.validateEdit(genTable); genTableService.updateGenTable(genTable); - return AjaxResult.success(); + return success(); } /** @@ -135,7 +135,7 @@ public class GenController extends BaseController public AjaxResult remove(@PathVariable Long[] tableIds) { genTableService.deleteGenTableByIds(tableIds); - return AjaxResult.success(); + return success(); } /** @@ -146,7 +146,7 @@ public class GenController extends BaseController public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException { Map dataMap = genTableService.previewCode(tableId); - return AjaxResult.success(dataMap); + return success(dataMap); } /** @@ -170,7 +170,7 @@ public class GenController extends BaseController public AjaxResult genCode(@PathVariable("tableName") String tableName) { genTableService.generatorCode(tableName); - return AjaxResult.success(); + return success(); } /** @@ -182,7 +182,7 @@ public class GenController extends BaseController public AjaxResult synchDb(@PathVariable("tableName") String tableName) { genTableService.synchDb(tableName); - return AjaxResult.success(); + return success(); } /** diff --git a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm index ab19cf5..bf88988 100644 --- a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -53,7 +53,7 @@ public class ${ClassName}Controller extends BaseController public AjaxResult list(${ClassName} ${className}) { List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); - return AjaxResult.success(list); + return success(list); } #end @@ -77,7 +77,7 @@ public class ${ClassName}Controller extends BaseController @GetMapping(value = "/{${pkColumn.javaField}}") public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { - return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); + return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); } /** diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java index 3cd7ced..f8189ba 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java @@ -71,7 +71,7 @@ public class SysJobController extends BaseController @GetMapping(value = "/{jobId}") public AjaxResult getInfo(@PathVariable("jobId") Long jobId) { - return AjaxResult.success(jobService.selectJobById(jobId)); + return success(jobService.selectJobById(jobId)); } /** diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java index fff959a..95f2e82 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java @@ -63,7 +63,7 @@ public class SysJobLogController extends BaseController @GetMapping(value = "/{configId}") public AjaxResult getInfo(@PathVariable Long jobLogId) { - return AjaxResult.success(jobLogService.selectJobLogById(jobLogId)); + return success(jobLogService.selectJobLogById(jobLogId)); } @@ -87,6 +87,6 @@ public class SysJobLogController extends BaseController public AjaxResult clean() { jobLogService.cleanJobLog(); - return AjaxResult.success(); + return success(); } } diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index 1080f52..80ee3c3 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -99,6 +99,12 @@ service.interceptors.response.use(res => { type: 'error' }) return Promise.reject(new Error(msg)) + } else if (code === 601) { + Message({ + message: msg, + type: 'warning' + }) + return Promise.reject('error') } else if (code !== 200) { Notification.error({ title: msg