feat;增加角色模块

This commit is contained in:
曾文豪
2024-06-25 18:46:13 +08:00
parent d2229e0028
commit a10b57f6fc
3 changed files with 38 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ tiesheng:
test-map:
"1111":
id: "1111"
role-id: "student_bks"
global:
version: 2
host: http://localhost:8100

View File

@@ -25,6 +25,7 @@ import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/role")
@@ -243,10 +244,15 @@ public class RoleController {
* @return
*/
@GetMapping("/owner/server")
public ApiResp<List<CoreRoleAuthority>> ownerServer() {
public ApiResp<List<CoreRoleServer>> ownerServer() {
TokenBean tokenBean = TsTokenConfig.get();
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getAllOwnerMenus(tokenBean.getId(), tokenBean.getRoleId());
return ApiResp.respOK(allOwnerMenus);
List<CoreRoleServer> roleServerList = coreServerService.list(new QueryWrapper<CoreRoleServer>()
.in("id", allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList()))
);
return ApiResp.respOK(roleServerList);
}
@@ -259,6 +265,7 @@ public class RoleController {
public ApiResp<String> ownerMenu(@Valid ServiceDTO dto) {
return ApiResp.respOK("");
}
@@ -268,10 +275,23 @@ public class RoleController {
* @return
*/
@GetMapping("/owner/point")
public ApiResp<String> ownerPoint(@Valid OwerPointDTO dto) {
public ApiResp<List<CoreRoleAuthority>> ownerPoint(@Valid OwerPointDTO dto) {
TokenBean tokenBean = TsTokenConfig.get();
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getAllOwnerMenus(tokenBean.getId(), tokenBean.getRoleId());
return ApiResp.respOK("");
List<CoreRoleAuthority> collect = allOwnerMenus.stream()
.filter(it -> Objects.equals(it.getType(), "point"))
.filter(it -> it.getService().equals(dto.getService()))
.filter(it -> it.getPlatform().equals(dto.getPlatform()))
.filter(it -> {
if (StrUtil.isNotEmpty(dto.getParent())) {
return dto.getParent().equals(it.getParent());
}
return true;
}).collect(Collectors.toList());
return ApiResp.respOK(collect);
}
}

View File

@@ -1,9 +1,14 @@
package com.tiesheng.role.pojos.dto;
import javax.validation.constraints.NotEmpty;
public class OwerPointDTO extends ServiceDTO {
private String parent;
@NotEmpty(message = "请选择一个平台")
private String platform;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
@@ -15,4 +20,12 @@ public class OwerPointDTO extends ServiceDTO {
public void setParent(String parent) {
this.parent = parent;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
}