| | |
| | | private static final String SITE_OWNER_ROLE_KEY = "site_owner"; |
| | | private static final String SERVICE_PROVIDER_ROLE_NAME = "服务商"; |
| | | private static final String SERVICE_PROVIDER_ROLE_KEY = "service_provider"; |
| | | private static final String COMPANY_ROLE_NAME = "公司"; |
| | | private static final String COMPANY_ROLE_KEY = "company"; |
| | | private static final String OWN_SITE_NAME = "自有电站"; |
| | | private static final String SYSTEM_ROLE_REMARK = "系统内置角色"; |
| | | |
| | |
| | | ensureSystemRole(INDEPENDENT_PARTNER_ROLE_NAME, INDEPENDENT_PARTNER_ROLE_KEY, getIndependentPartnerMenuIds()); |
| | | ensureSystemRole(SITE_OWNER_ROLE_NAME, SITE_OWNER_ROLE_KEY, new HashSet<>()); |
| | | ensureSystemRole(SERVICE_PROVIDER_ROLE_NAME, SERVICE_PROVIDER_ROLE_KEY, new HashSet<>()); |
| | | ensureSystemRole(COMPANY_ROLE_NAME, COMPANY_ROLE_KEY, new HashSet<>()); |
| | | } |
| | | |
| | | private void ensureSystemRole(String roleName, String roleKey, Set<Long> menuIds) { |
| | |
| | | || SERVICE_PROVIDER_ROLE_NAME.equals(role.getRoleName())); |
| | | } |
| | | |
| | | private boolean isCompanyBuiltinRole(SysRole role) { |
| | | return role != null && (COMPANY_ROLE_KEY.equals(role.getRoleKey()) |
| | | || COMPANY_ROLE_NAME.equals(role.getRoleName())); |
| | | } |
| | | |
| | | private boolean isSystemBuiltinRole(SysRole role) { |
| | | return role != null && (role.isAdmin() || isPartnerBuiltinRole(role)); |
| | | return role != null && (role.isAdmin() || isPartnerBuiltinRole(role) || isCompanyBuiltinRole(role)); |
| | | } |
| | | |
| | | private void fillRoleV2Info(SysRole role) { |
| | |
| | | List<SysRole> sysRoleByIds = roleService.getSysRoleByIds(ids.getIds()); |
| | | return R.ok(sysRoleByIds); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色标识查询启用且未删除的角色ID(远程接口,公司账号分配默认角色使用) |
| | | * |
| | | * @param roleKey 角色标识 |
| | | * @return 角色ID;不存在时返回 null |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping(value = "/getRoleIdByRoleKey") |
| | | public R<Long> getRoleIdByRoleKey(@RequestBody String roleKey) { |
| | | SysRole role = roleService.getOne(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleKey, roleKey) |
| | | .eq(SysRole::getDelFlag, 0) |
| | | .eq(SysRole::getStatus, 0) |
| | | .orderByAsc(SysRole::getRoleId) |
| | | .last("LIMIT 1")); |
| | | return R.ok(role == null ? null : role.getRoleId()); |
| | | } |
| | | } |