From 7736097f6b624931450ee34cf6fa527b7e34221a Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 8 Aug 2021 19:12:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E9=80=9A=E7=94=A8=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=88=B0=E5=9F=BA=E7=B1=BB=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysConfigController.java | 5 +- .../controller/system/SysDeptController.java | 5 +- .../system/SysDictDataController.java | 5 +- .../system/SysDictTypeController.java | 5 +- .../controller/system/SysLoginController.java | 7 +- .../controller/system/SysMenuController.java | 22 ++---- .../system/SysNoticeController.java | 5 +- .../controller/system/SysPostController.java | 5 +- .../controller/system/SysRoleController.java | 7 +- .../controller/system/SysUserController.java | 8 +- .../core/controller/BaseController.java | 78 +++++++++++++------ .../common/core/domain/model/LoginUser.java | 38 +++++++++ .../com/ruoyi/common/utils/SecurityUtils.java | 30 +++++++ .../web/service/UserDetailsServiceImpl.java | 2 +- .../quartz/controller/SysJobController.java | 5 +- 15 files changed, 154 insertions(+), 73 deletions(-) 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 8678fd6..dc2532f 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 @@ -19,7 +19,6 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.service.ISysConfigService; @@ -90,7 +89,7 @@ public class SysConfigController extends BaseController { return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); } - config.setCreateBy(SecurityUtils.getUsername()); + config.setCreateBy(getUsername()); return toAjax(configService.insertConfig(config)); } @@ -106,7 +105,7 @@ public class SysConfigController extends BaseController { return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); } - config.setUpdateBy(SecurityUtils.getUsername()); + config.setUpdateBy(getUsername()); return toAjax(configService.updateConfig(config)); } 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 60bd1a5..7dd1870 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 @@ -20,7 +20,6 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.service.ISysDeptService; @@ -113,7 +112,7 @@ public class SysDeptController extends BaseController { return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } - dept.setCreateBy(SecurityUtils.getUsername()); + dept.setCreateBy(getUsername()); return toAjax(deptService.insertDept(dept)); } @@ -138,7 +137,7 @@ public class SysDeptController extends BaseController { return AjaxResult.error("该部门包含未停用的子部门!"); } - dept.setUpdateBy(SecurityUtils.getUsername()); + dept.setUpdateBy(getUsername()); return toAjax(deptService.updateDept(dept)); } 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 c044d25..b9e3dc3 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 @@ -19,7 +19,6 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.service.ISysDictDataService; @@ -91,7 +90,7 @@ public class SysDictDataController extends BaseController @PostMapping public AjaxResult add(@Validated @RequestBody SysDictData dict) { - dict.setCreateBy(SecurityUtils.getUsername()); + dict.setCreateBy(getUsername()); return toAjax(dictDataService.insertDictData(dict)); } @@ -103,7 +102,7 @@ public class SysDictDataController extends BaseController @PutMapping public AjaxResult edit(@Validated @RequestBody SysDictData dict) { - dict.setUpdateBy(SecurityUtils.getUsername()); + dict.setUpdateBy(getUsername()); return toAjax(dictDataService.updateDictData(dict)); } 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 3185f41..acad00e 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 @@ -19,7 +19,6 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDictType; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.service.ISysDictTypeService; @@ -76,7 +75,7 @@ public class SysDictTypeController extends BaseController { return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); } - dict.setCreateBy(SecurityUtils.getUsername()); + dict.setCreateBy(getUsername()); return toAjax(dictTypeService.insertDictType(dict)); } @@ -92,7 +91,7 @@ public class SysDictTypeController extends BaseController { return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); } - dict.setUpdateBy(SecurityUtils.getUsername()); + dict.setUpdateBy(getUsername()); return toAjax(dictTypeService.updateDictType(dict)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index 4ade9f6..a223f0f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -13,6 +13,7 @@ import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginBody; import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.framework.web.service.SysLoginService; import com.ruoyi.framework.web.service.SysPermissionService; @@ -85,10 +86,8 @@ public class SysLoginController @GetMapping("getRouters") public AjaxResult getRouters() { - LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - // 用户信息 - SysUser user = loginUser.getUser(); - List menus = menuService.selectMenuTreeByUserId(user.getUserId()); + Long userId = SecurityUtils.getUserId(); + List menus = menuService.selectMenuTreeByUserId(userId); return AjaxResult.success(menuService.buildMenus(menus)); } } 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 eb66ea3..9ab14d2 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 @@ -17,12 +17,8 @@ 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.entity.SysMenu; -import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.service.ISysMenuService; /** @@ -37,9 +33,6 @@ public class SysMenuController extends BaseController @Autowired private ISysMenuService menuService; - @Autowired - private TokenService tokenService; - /** * 获取菜单列表 */ @@ -47,9 +40,7 @@ public class SysMenuController extends BaseController @GetMapping("/list") public AjaxResult list(SysMenu menu) { - LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - Long userId = loginUser.getUser().getUserId(); - List menus = menuService.selectMenuList(menu, userId); + List menus = menuService.selectMenuList(menu, getUserId()); return AjaxResult.success(menus); } @@ -69,9 +60,7 @@ public class SysMenuController extends BaseController @GetMapping("/treeselect") public AjaxResult treeselect(SysMenu menu) { - LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - Long userId = loginUser.getUser().getUserId(); - List menus = menuService.selectMenuList(menu, userId); + List menus = menuService.selectMenuList(menu, getUserId()); return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); } @@ -81,8 +70,7 @@ public class SysMenuController extends BaseController @GetMapping(value = "/roleMenuTreeselect/{roleId}") public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) { - LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - List menus = menuService.selectMenuList(loginUser.getUser().getUserId()); + List menus = menuService.selectMenuList(getUserId()); AjaxResult ajax = AjaxResult.success(); ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); ajax.put("menus", menuService.buildMenuTreeSelect(menus)); @@ -105,7 +93,7 @@ public class SysMenuController extends BaseController { return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); } - menu.setCreateBy(SecurityUtils.getUsername()); + menu.setCreateBy(getUsername()); return toAjax(menuService.insertMenu(menu)); } @@ -129,7 +117,7 @@ public class SysMenuController extends BaseController { return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); } - menu.setUpdateBy(SecurityUtils.getUsername()); + menu.setUpdateBy(getUsername()); return toAjax(menuService.updateMenu(menu)); } 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 029ee38..2580248 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 @@ -17,7 +17,6 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.system.domain.SysNotice; import com.ruoyi.system.service.ISysNoticeService; @@ -63,7 +62,7 @@ public class SysNoticeController extends BaseController @PostMapping public AjaxResult add(@Validated @RequestBody SysNotice notice) { - notice.setCreateBy(SecurityUtils.getUsername()); + notice.setCreateBy(getUsername()); return toAjax(noticeService.insertNotice(notice)); } @@ -75,7 +74,7 @@ public class SysNoticeController extends BaseController @PutMapping public AjaxResult edit(@Validated @RequestBody SysNotice notice) { - notice.setUpdateBy(SecurityUtils.getUsername()); + notice.setUpdateBy(getUsername()); return toAjax(noticeService.updateNotice(notice)); } 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 67d76ee..30a8761 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 @@ -18,7 +18,6 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.service.ISysPostService; @@ -83,7 +82,7 @@ public class SysPostController extends BaseController { return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); } - post.setCreateBy(SecurityUtils.getUsername()); + post.setCreateBy(getUsername()); return toAjax(postService.insertPost(post)); } @@ -103,7 +102,7 @@ public class SysPostController extends BaseController { return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); } - post.setUpdateBy(SecurityUtils.getUsername()); + post.setUpdateBy(getUsername()); return toAjax(postService.updatePost(post)); } 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 953f336..4680b67 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 @@ -21,7 +21,6 @@ import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; @@ -97,7 +96,7 @@ public class SysRoleController extends BaseController { return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); } - role.setCreateBy(SecurityUtils.getUsername()); + role.setCreateBy(getUsername()); return toAjax(roleService.insertRole(role)); } @@ -119,7 +118,7 @@ public class SysRoleController extends BaseController { return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); } - role.setUpdateBy(SecurityUtils.getUsername()); + role.setUpdateBy(getUsername()); if (roleService.updateRole(role) > 0) { @@ -157,7 +156,7 @@ public class SysRoleController extends BaseController public AjaxResult changeStatus(@RequestBody SysRole role) { roleService.checkRoleAllowed(role); - role.setUpdateBy(SecurityUtils.getUsername()); + role.setUpdateBy(getUsername()); return toAjax(roleService.updateRoleStatus(role)); } 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 692bd5c..10e9e24 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 @@ -137,7 +137,7 @@ public class SysUserController extends BaseController { return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } - user.setCreateBy(SecurityUtils.getUsername()); + user.setCreateBy(getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); return toAjax(userService.insertUser(user)); } @@ -161,7 +161,7 @@ public class SysUserController extends BaseController { return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } - user.setUpdateBy(SecurityUtils.getUsername()); + user.setUpdateBy(getUsername()); return toAjax(userService.updateUser(user)); } @@ -186,7 +186,7 @@ public class SysUserController extends BaseController { userService.checkUserAllowed(user); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - user.setUpdateBy(SecurityUtils.getUsername()); + user.setUpdateBy(getUsername()); return toAjax(userService.resetPwd(user)); } @@ -199,7 +199,7 @@ public class SysUserController extends BaseController public AjaxResult changeStatus(@RequestBody SysUser user) { userService.checkUserAllowed(user); - user.setUpdateBy(SecurityUtils.getUsername()); + user.setUpdateBy(getUsername()); return toAjax(userService.updateUserStatus(user)); } 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 80ac645..3c26de5 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 @@ -11,10 +11,12 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.sql.SqlUtil; @@ -86,28 +88,6 @@ public class BaseController return rspData; } - /** - * 响应返回结果 - * - * @param rows 影响行数 - * @return 操作结果 - */ - protected AjaxResult toAjax(int rows) - { - return rows > 0 ? AjaxResult.success() : AjaxResult.error(); - } - - /** - * 响应返回结果 - * - * @param result 结果 - * @return 操作结果 - */ - protected AjaxResult toAjax(boolean result) - { - return result ? success() : error(); - } - /** * 返回成功 */ @@ -140,6 +120,28 @@ public class BaseController return AjaxResult.error(message); } + /** + * 响应返回结果 + * + * @param rows 影响行数 + * @return 操作结果 + */ + protected AjaxResult toAjax(int rows) + { + return rows > 0 ? AjaxResult.success() : AjaxResult.error(); + } + + /** + * 响应返回结果 + * + * @param result 结果 + * @return 操作结果 + */ + protected AjaxResult toAjax(boolean result) + { + return result ? success() : error(); + } + /** * 页面跳转 */ @@ -147,4 +149,36 @@ public class BaseController { return StringUtils.format("redirect:{}", url); } + + /** + * 获取用户缓存信息 + */ + public LoginUser getLoginUser() + { + return SecurityUtils.getLoginUser(); + } + + /** + * 获取登录用户id + */ + public Long getUserId() + { + return getLoginUser().getUserId(); + } + + /** + * 获取登录部门id + */ + public Long getDeptId() + { + return getLoginUser().getDeptId(); + } + + /** + * 获取登录用户名 + */ + public String getUsername() + { + return getLoginUser().getUsername(); + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java index d389ff8..7b1d896 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java @@ -16,6 +16,16 @@ public class LoginUser implements UserDetails { private static final long serialVersionUID = 1L; + /** + * 用户ID + */ + private Long userId; + + /** + * 部门ID + */ + private Long deptId; + /** * 用户唯一标识 */ @@ -61,6 +71,26 @@ public class LoginUser implements UserDetails */ private SysUser user; + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getDeptId() + { + return deptId; + } + + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + public String getToken() { return token; @@ -81,6 +111,14 @@ public class LoginUser implements UserDetails this.permissions = permissions; } + public LoginUser(Long userId, Long deptId, SysUser user, Set permissions) + { + this.userId = userId; + this.deptId = deptId; + this.user = user; + this.permissions = permissions; + } + @JsonIgnore @Override public String getPassword() diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java index ce7f3b6..479aea6 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java @@ -14,6 +14,36 @@ import com.ruoyi.common.exception.CustomException; */ public class SecurityUtils { + /** + * 用户ID + **/ + public static Long getUserId() + { + try + { + return getLoginUser().getUserId(); + } + catch (Exception e) + { + throw new CustomException("获取用户ID异常", HttpStatus.UNAUTHORIZED); + } + } + + /** + * 获取部门ID + **/ + public static Long getDeptId() + { + try + { + return getLoginUser().getDeptId(); + } + catch (Exception e) + { + throw new CustomException("获取部门ID异常", HttpStatus.UNAUTHORIZED); + } + } + /** * 获取用户账户 **/ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java index a78f2c7..43faf64 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java @@ -55,6 +55,6 @@ public class UserDetailsServiceImpl implements UserDetailsService public UserDetails createLoginUser(SysUser user) { - return new LoginUser(user, permissionService.getMenuPermission(user)); + return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user)); } } 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 4d37ee9..8ce5298 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 @@ -19,7 +19,6 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.quartz.domain.SysJob; @@ -93,7 +92,7 @@ public class SysJobController extends BaseController { return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用"); } - job.setCreateBy(SecurityUtils.getUsername()); + job.setCreateBy(getUsername()); return toAjax(jobService.insertJob(job)); } @@ -117,7 +116,7 @@ public class SysJobController extends BaseController { return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用"); } - job.setUpdateBy(SecurityUtils.getUsername()); + job.setUpdateBy(getUsername()); return toAjax(jobService.updateJob(job)); }