| | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.utils.MapstructUtils; |
| | | import com.ruoyi.common.core.utils.StreamUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | @GetMapping("/getInfo") |
| | | public R<UserInfoVo> getInfo() { |
| | | UserInfoVo userInfoVo = new UserInfoVo(); |
| | | LoginUser loginUser = LoginHelper.getLoginUser(); |
| | | if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) { |
| | | // 超级管理员 如果重新加载用户信息需清除动态租户 |
| | | TenantHelper.clearDynamic(); |
| | | } |
| | | SysUserVo user = userService.selectUserById(loginUser.getUserId()); |
| | | userInfoVo.setUser(user); |
| | | userInfoVo.setPermissions(loginUser.getMenuPermission()); |
| | | userInfoVo.setRoles(loginUser.getRolePermission()); |
| | | return R.ok(userInfoVo); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户编号获取详细信息 |
| | | * |
| | | * @param userId 用户ID |
| | |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysUserBo user) { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserAllowed(user.getUserId()); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | if (!userService.checkUserNameUnique(user)) { |
| | | return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPwd") |
| | | public R<Void> resetPwd(@RequestBody SysUserBo user) { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserAllowed(user.getUserId()); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | user.setPassword(BCrypt.hashpw(user.getPassword())); |
| | | return toAjax(userService.resetUserPwd(user.getUserId(),user.getPassword())); |
| | | return toAjax(userService.resetUserPwd(user.getUserId(), user.getPassword())); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysUserBo user) { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserAllowed(user.getUserId()); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | return toAjax(userService.updateUserStatus(user)); |
| | | return toAjax(userService.updateUserStatus(user.getUserId(), user.getStatus())); |
| | | } |
| | | |
| | | /** |