|
|
|
|
@ -9,11 +9,9 @@ import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
|
import org.springblade.core.cache.utils.CacheUtil; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.core.secure.annotation.PreAuth; |
|
|
|
|
import org.springblade.core.tenant.annotation.NonDS; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.constant.BladeConstant; |
|
|
|
|
import org.springblade.core.tool.constant.RoleConstant; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.system.cache.SysCache; |
|
|
|
|
import org.springblade.system.entity.Role; |
|
|
|
|
@ -25,6 +23,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
@ -69,6 +68,13 @@ public class RoleController extends BladeController { |
|
|
|
|
public R<List<RoleVO>> list(@ApiIgnore @RequestParam Map<String, Object> role, BladeUser bladeUser) { |
|
|
|
|
QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class); |
|
|
|
|
List<Role> list = roleService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
|
|
|
|
if(bladeUser.getRoleName().equals("厂区")){ |
|
|
|
|
List<String> excludes = new ArrayList<>(); |
|
|
|
|
excludes.add("admin"); |
|
|
|
|
excludes.add("政府"); |
|
|
|
|
excludes.add("政府大屏"); |
|
|
|
|
list.removeIf(role1 -> excludes.contains(role1.getRoleAlias())); |
|
|
|
|
} |
|
|
|
|
return R.data(RoleWrapper.build().listNodeVO(list)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -79,7 +85,12 @@ public class RoleController extends BladeController { |
|
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
|
@ApiOperation(value = "树形结构", notes = "树形结构") |
|
|
|
|
public R<List<RoleVO>> tree(String tenantId, BladeUser bladeUser) { |
|
|
|
|
List<RoleVO> tree = roleService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId())); |
|
|
|
|
List<RoleVO> tree = new ArrayList<>(); |
|
|
|
|
if(bladeUser.getRoleName().equals("厂区")){ |
|
|
|
|
tree = roleService.companyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId())); |
|
|
|
|
}else{ |
|
|
|
|
tree = roleService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId())); |
|
|
|
|
} |
|
|
|
|
return R.data(tree); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -91,7 +102,12 @@ public class RoleController extends BladeController { |
|
|
|
|
@ApiOperation(value = "树形结构", notes = "树形结构") |
|
|
|
|
public R<List<RoleVO>> treeById(Long roleId, BladeUser bladeUser) { |
|
|
|
|
Role role = SysCache.getRole(roleId); |
|
|
|
|
List<RoleVO> tree = roleService.tree(Func.notNull(role) ? role.getTenantId() : bladeUser.getTenantId()); |
|
|
|
|
List<RoleVO> tree = new ArrayList<>(); |
|
|
|
|
if(bladeUser.getRoleName().equals("厂区")){ |
|
|
|
|
tree = roleService.companyTree(Func.notNull(role) ? role.getTenantId() : bladeUser.getTenantId()); |
|
|
|
|
}else{ |
|
|
|
|
tree = roleService.tree(Func.notNull(role) ? role.getTenantId() : bladeUser.getTenantId()); |
|
|
|
|
} |
|
|
|
|
return R.data(tree); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|