From efb585cfe77cca15215f0ad5ebc14b61b116da1f Mon Sep 17 00:00:00 2001 From: smallchill Date: Tue, 7 Jan 2020 23:42:34 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=20=E4=BC=98=E5=8C=96=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/TenantController.java | 6 +++--- .../system/user/service/impl/UserServiceImpl.java | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java index 6994c0cd..a7411eaa 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java @@ -65,7 +65,7 @@ public class TenantController extends BladeController { @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入tenant") - @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R detail(Tenant tenant) { Tenant detail = tenantService.getOne(Condition.getQueryWrapper(tenant)); return R.data(detail); @@ -82,7 +82,7 @@ public class TenantController extends BladeController { }) @ApiOperationSupport(order = 2) @ApiOperation(value = "分页", notes = "传入tenant") - @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R> list(@ApiIgnore @RequestParam Map tenant, Query query, BladeUser bladeUser) { QueryWrapper queryWrapper = Condition.getQueryWrapper(tenant, Tenant.class); IPage pages = tenantService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Tenant::getTenantId, bladeUser.getTenantId()) : queryWrapper); @@ -108,7 +108,7 @@ public class TenantController extends BladeController { @GetMapping("/page") @ApiOperationSupport(order = 4) @ApiOperation(value = "分页", notes = "传入tenant") - @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R> page(Tenant tenant, Query query) { IPage pages = tenantService.selectTenantPage(Condition.getPage(query), tenant); return R.data(pages); diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java index 84e504c5..8acbdf9d 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java @@ -62,15 +62,17 @@ public class UserServiceImpl extends BaseServiceImpl implement } String tenantId = user.getTenantId(); Tenant tenant = SysCache.getTenant(tenantId); - Integer accountNumber = tenant.getAccountNumber(); - Integer tenantCount = baseMapper.selectCount(Wrappers.query().lambda().eq(User::getTenantId, Func.toStr(tenantId, BladeConstant.ADMIN_TENANT_ID))); - if (accountNumber != null && accountNumber > 0 && accountNumber < tenantCount) { - throw new ServiceException("当前租户已到最大账号额度"); + if (Func.isNotEmpty(tenant)) { + Integer accountNumber = tenant.getAccountNumber(); + Integer tenantCount = baseMapper.selectCount(Wrappers.query().lambda().eq(User::getTenantId, tenantId)); + if (accountNumber != null && accountNumber > 0 && accountNumber < tenantCount) { + throw new ServiceException("当前租户已到最大账号额度"); + } } if (Func.isNotEmpty(user.getPassword())) { user.setPassword(DigestUtil.encrypt(user.getPassword())); } - Integer userCount = baseMapper.selectCount(Wrappers.query().lambda().eq(User::getTenantId, Func.toStr(tenantId, BladeConstant.ADMIN_TENANT_ID)).eq(User::getAccount, user.getAccount())); + Integer userCount = baseMapper.selectCount(Wrappers.query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount())); if (userCount > 0 && Func.isEmpty(user.getId())) { throw new ServiceException("当前用户已存在!"); }