| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.cache.CacheNames; |
| | | import org.springblade.common.cache.ParamCache; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.modules.auth.granter.PasswordTokenGranter; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.excel.UserExcel; |
| | | import org.springblade.modules.system.excel.UserImporter; |
| | |
| | | @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())); |
| | | return R.data(UserWrapper.build().pageVO(pages)); |
| | | IPage<UserVO> userVOIPage = UserWrapper.build().pageVO(pages); |
| | | userVOIPage.getRecords().forEach(userVO -> { |
| | | int cnt = Func.toInt(bladeRedis.get(CacheNames.tenantKey(userVO.getTenantId(), CacheNames.USER_FAIL_KEY, userVO.getAccount())), 0); |
| | | int failCount = Func.toInt(ParamCache.getValue(PasswordTokenGranter.FAIL_COUNT_VALUE), PasswordTokenGranter.FAIL_COUNT); |
| | | //设置封禁状态,1为已封禁,0为未封禁 |
| | | if (cnt >= failCount) { |
| | | userVO.setBannedState("1"); |
| | | }else { |
| | | userVO.setBannedState("0"); |
| | | } |
| | | }); |
| | | return R.data(userVOIPage); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "新增或修改", notes = "传入User") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R submit(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | // CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.submit(user)); |
| | | } |
| | | |
| | |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入User") |
| | | public R update(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | // CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.updateUser(user)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "删除", notes = "传入id集合") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R remove(@RequestParam String ids) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | // CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.removeUser(ids)); |
| | | } |
| | | |
| | |
| | | @ApiOperationSupport(order = 10) |
| | | @ApiOperation(value = "修改基本信息", notes = "传入User") |
| | | public R updateInfo(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | // CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.updateUserInfo(user)); |
| | | } |
| | | |