| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import com.vci.ubcs.system.user.excel.UserExcel; |
| | | import com.vci.ubcs.system.user.excel.UserImporter; |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import com.vci.ubcs.common.cache.CacheNames; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.hibernate.validator.internal.util.logging.Log; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | |
| | | |
| | | private final IUserService userService; |
| | | private final BladeRedis bladeRedis; |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | /** |
| | | * 查询单条 |
| | |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<UserVO>> list(@ApiIgnore @RequestParam Map<String, Object> user, Query query, BladeUser bladeUser) { |
| | | QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user, User.class); |
| | | IPage<User> pages = userService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | IPage<User> pages = userService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())) ? queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(UserWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "列表", notes = "传入account和realName") |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<UserVO>> page(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) { |
| | | IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : bladeUser.getTenantId())); |
| | | IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? StringPool.EMPTY : bladeUser.getTenantId())); |
| | | return R.data(UserWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PostMapping("/grant") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合") |
| | | @ApiOperation(value = "权限设置", notes = "传入userIds集合以及roleIds集合") |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R grant(@ApiParam(value = "userId集合", required = true) @RequestParam String userIds, |
| | | @ApiParam(value = "roleId集合", required = true) @RequestParam String roleIds) { |
| | | boolean temp = userService.grant(userIds, roleIds); |
| | | boolean temp = false; |
| | | try { |
| | | temp = userService.grant(userIds, roleIds); |
| | | // 插入授权日志 |
| | | userService.grantLog(UserWrapper.build().entityVO(userService.getById(userIds)).toString(),false); |
| | | }catch (Exception e){ |
| | | // 插入授权日志 |
| | | userService.grantLog(e.getMessage(),true); |
| | | throw e; |
| | | } |
| | | return R.status(temp); |
| | | } |
| | | |
| | |
| | | ExcelUtil.export(response, "用户数据模板", "用户数据表", list, UserExcel.class); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 第三方注册用户 |
| | | */ |
| | |
| | | public R registerGuest(User user, Long oauthId) { |
| | | return R.status(userService.registerGuest(user, oauthId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 配置用户平台信息 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 用户解锁 |
| | | * 检查用户是否到了提醒用户修改密码或者密码过期的时间 |
| | | */ |
| | | @PostMapping("/check-renexpr") |
| | | @ApiOperationSupport(order = 20) |
| | |
| | | return R.data(res); |
| | | } |
| | | |
| | | /** |
| | | * 获取到指定身份权限的用户列表 |
| | | * @param user 用户查询的用户信息,如租户信息,通常为自动注入,前端可选择不传 |
| | | * @param roleName 要查询的角色身份 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getByRoleUserList") |
| | | @ApiOperationSupport(order = 21) |
| | | @ApiOperation(value = "获取到指定身份权限的用户列表", notes = "传入roleName") |
| | | public R<List<Map<String,String>>> getByRoleUserList(BladeUser user,@Valid @RequestParam String roleName){ |
| | | return R.data(userService.getByRoleUserList(user,roleName)); |
| | | } |
| | | |
| | | /** |
| | | * 修改用户状态 停用/启用 |
| | | * @param userIds userId集合 |
| | | * @param status 停用/启用; true:启用,false:停用 |
| | | * @return |
| | | */ |
| | | @PostMapping("/updateUserStatus") |
| | | @ApiOperationSupport(order = 21) |
| | | @ApiOperation(value = "获取到指定身份权限的用户列表", notes = "传入userId集合") |
| | | public R<Boolean> updateUserStatus(@Valid @RequestParam("userIds") String userIds,boolean status){ |
| | | if (StringUtil.isBlank(userIds)) { |
| | | return R.fail("请至少选择一个用户"); |
| | | } |
| | | return R.status(userService.updateUserStatus(userIds,status)); |
| | | } |
| | | |
| | | } |