From 25cf266e99714ac5d428e66b40ce272325c91dd8 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期六, 14 六月 2025 15:01:11 +0800 Subject: [PATCH] 修改管理后台账号和共享session等 屏蔽除出租车外的其他模块 --- ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java | 107 +++++++++++++++++++++-------------------------------- 1 files changed, 43 insertions(+), 64 deletions(-) diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java index 2ea5442..b5b3515 100644 --- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java +++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java @@ -5,6 +5,7 @@ import com.stylefeng.guns.config.properties.GunsProperties; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.core.base.tips.Tip; +import com.stylefeng.guns.core.beetl.ShiroExtUtil; import com.stylefeng.guns.core.common.annotion.BussinessLog; import com.stylefeng.guns.core.common.annotion.Permission; import com.stylefeng.guns.core.common.constant.Const; @@ -13,7 +14,6 @@ import com.stylefeng.guns.core.common.constant.factory.PageFactory; import com.stylefeng.guns.core.common.constant.state.ManagerStatus; import com.stylefeng.guns.core.common.exception.BizExceptionEnum; -import com.stylefeng.guns.core.datascope.DataScope; import com.stylefeng.guns.core.db.Db; import com.stylefeng.guns.core.exception.GunsException; import com.stylefeng.guns.core.log.LogObjectHolder; @@ -29,6 +29,8 @@ import com.stylefeng.guns.modular.system.service.ITDriverService; import com.stylefeng.guns.modular.system.service.IUserService; import com.stylefeng.guns.modular.system.transfer.UserDto; +import com.stylefeng.guns.modular.system.util.qianyuntong.EmployeeUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.GetStaffNodeRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -40,7 +42,6 @@ import javax.validation.Valid; import java.io.File; import java.util.Date; -import java.util.List; import java.util.Map; import java.util.UUID; @@ -107,7 +108,6 @@ if (ToolUtil.isEmpty(userId)) { throw new GunsException(BizExceptionEnum.REQUEST_NULL); } - assertAuth(userId); User user = this.userService.selectById(userId); model.addAttribute(user); model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid())); @@ -121,7 +121,7 @@ */ @RequestMapping("/user_info") public String userInfo(Model model) { - Integer userId = ShiroKit.getUser().getId(); + Integer userId = ShiroExtUtil.getUser().getId(); if (ToolUtil.isEmpty(userId)) { throw new GunsException(BizExceptionEnum.REQUEST_NULL); } @@ -150,8 +150,8 @@ if (!newPwd.equals(rePwd)) { throw new GunsException(BizExceptionEnum.TWO_PWD_NOT_MATCH); } - Integer userId = ShiroKit.getUser().getId(); - User user = userService.selectById(userId); + Integer userId = ShiroExtUtil.getUser().getId(); + User user = userService.selectById(userId); String oldMd5 = ShiroKit.md5(oldPwd, user.getSalt()); if (user.getPassword().equals(oldMd5)) { String newMd5 = ShiroKit.md5(newPwd, user.getSalt()); @@ -173,21 +173,20 @@ //创建日期 String beginTime = null; String endTime = null; - if (SinataUtil.isNotEmpty(createTime)){ - String[] timeArray = createTime.split(" - "); - beginTime = timeArray[0]; - endTime = timeArray[1]; - } - if (ShiroKit.isAdmin()) { - Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); - page.setRecords(userService.getUserListPage(page,null, name, beginTime, endTime, deptid)); - return super.packForBT(page); - } else { - DataScope dataScope = new DataScope(ShiroKit.getDeptDataScope()); - Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); - page.setRecords(userService.getUserListPage(page,dataScope, name, beginTime, endTime, deptid)); - return super.packForBT(page); - } + if (SinataUtil.isNotEmpty(createTime)) { + String[] timeArray = createTime.split(" - "); + beginTime = timeArray[0]; + endTime = timeArray[1]; + } + if (ShiroExtUtil.getUser().isAdmin()) { + Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); + page.setRecords(userService.getUserListPage(page, null, name, beginTime, endTime, deptid)); + return super.packForBT(page); + } else { + Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); + page.setRecords(userService.getUserListPage(page, null, name, beginTime, endTime, deptid)); + return super.packForBT(page); + } } /** @@ -234,25 +233,27 @@ @BussinessLog(value = "修改管理员", key = "account", dict = UserDict.class) @ResponseBody public Tip edit(@Valid UserDto user, BindingResult result) throws NoPermissionException { - if (result.hasErrors()) { - throw new GunsException(BizExceptionEnum.REQUEST_NULL); - } - - - User oldUser = userService.selectById(user.getId()); - - if (ShiroKit.hasRole(Const.ADMIN_NAME)) { - this.userService.updateById(UserFactory.editUser(user, oldUser)); - return SUCCESS_TIP; - } else { - assertAuth(user.getId()); - ShiroUser shiroUser = ShiroKit.getUser(); - if (shiroUser.getId().equals(user.getId())) { - this.userService.updateById(UserFactory.editUser(user, oldUser)); - return SUCCESS_TIP; - } else { - throw new GunsException(BizExceptionEnum.NO_PERMITION); - } + if (result.hasErrors()) { + throw new GunsException(BizExceptionEnum.REQUEST_NULL); + } + User oldUser = userService.selectById(user.getId()); + //调用中台接口 + GetStaffNodeRequest request = new GetStaffNodeRequest(); + + EmployeeUtil.getStaffNode(request); + + + if (ShiroExtUtil.getUser().isAdmin) { + this.userService.updateById(UserFactory.editUser(user, oldUser)); + return SUCCESS_TIP; + } else { + ShiroUser shiroUser = ShiroExtUtil.getUser(); + if (shiroUser.getId().equals(user.getId())) { + this.userService.updateById(UserFactory.editUser(user, oldUser)); + return SUCCESS_TIP; + } else { + throw new GunsException(BizExceptionEnum.NO_PERMITION); + } } } @@ -273,7 +274,6 @@ } - assertAuth(userId); this.userService.setStatus(userId, ManagerStatus.DELETED.getCode()); return SUCCESS_TIP; } @@ -287,7 +287,6 @@ if (ToolUtil.isEmpty(userId)) { throw new GunsException(BizExceptionEnum.REQUEST_NULL); } - assertAuth(userId); return this.userService.selectById(userId); } @@ -302,7 +301,6 @@ if (ToolUtil.isEmpty(userId)) { throw new GunsException(BizExceptionEnum.REQUEST_NULL); } - assertAuth(userId); User user = this.userService.selectById(userId); user.setSalt(ShiroKit.getRandomSalt(5)); user.setPassword(ShiroKit.md5(Const.DEFAULT_PWD, user.getSalt())); @@ -329,7 +327,6 @@ if (userId.equals(Const.ADMIN_ID)) { throw new GunsException(BizExceptionEnum.CANT_FREEZE_ADMIN); } - assertAuth(userId); this.userService.setStatus(userId, ManagerStatus.FREEZED.getCode()); User user = userService.selectById(userId); @@ -365,7 +362,6 @@ if (ToolUtil.isEmpty(userId)) { throw new GunsException(BizExceptionEnum.REQUEST_NULL); } - assertAuth(userId); this.userService.setStatus(userId, ManagerStatus.OK.getCode()); User user = userService.selectById(userId); @@ -405,7 +401,6 @@ if (userId.equals(Const.ADMIN_ID)) { throw new GunsException(BizExceptionEnum.CANT_CHANGE_ADMIN); } - assertAuth(userId); this.userService.setRoles(userId, roleIds); @@ -428,22 +423,6 @@ } return pictureName; } - - /** - * 判断当前登录的用户是否有操作这个用户的权限 - */ - private void assertAuth(Integer userId) { - if (ShiroKit.isAdmin()) { - return; - } - List<Integer> deptDataScope = ShiroKit.getDeptDataScope(); - User user = this.userService.selectById(userId); - Integer deptid = user.getDeptid(); - if (deptDataScope.contains(deptid)) { - return; - } else { - throw new GunsException(BizExceptionEnum.NO_PERMITION); - } - - } + + } -- Gitblit v1.7.1