diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java index 52e2cccc..ef63e253 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java @@ -103,10 +103,7 @@ public class RoleController extends BladeController { @ApiOperationSupport(order = 4) @ApiOperation(value = "新增或修改", notes = "传入role") @CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true) - public R submit(@Valid @RequestBody Role role, BladeUser user) { - if (Func.isEmpty(role.getId())) { - role.setTenantId(user.getTenantId()); - } + public R submit(@Valid @RequestBody Role role) { return R.status(roleService.submit(role)); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java index 3c1f856d..c4b20438 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java @@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.SecureUtil; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.constant.RoleConstant; @@ -133,11 +134,14 @@ public class RoleServiceImpl extends ServiceImpl implements IR @Override public boolean submit(Role role) { - if (!SecureUtil.isAdministrator()) { + if (!AuthUtil.isAdministrator()) { if (Func.toStr(role.getRoleAlias()).equals(RoleConstant.ADMINISTRATOR)) { throw new ServiceException("无权限创建超管角色!"); } } + if (Func.isEmpty(role.getId())) { + role.setTenantId(AuthUtil.getTenantId()); + } if (Func.isEmpty(role.getParentId())) { role.setParentId(BladeConstant.TOP_PARENT_ID); }