-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] 添加角色授权、角色授权主体、角色授权范围三个管理相关功能及单元测试
Signed-off-by: Alan Yeh <[email protected]>
- Loading branch information
Showing
11 changed files
with
973 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...c/main/java/central/studio/dashboard/controller/authority/param/RolePermissionParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2022-present Alan Yeh <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package central.studio.dashboard.controller.authority.param; | ||
|
||
import central.data.authority.RolePermissionInput; | ||
import central.util.Listx; | ||
import central.validation.Label; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Role Permission Relation Params | ||
* <p> | ||
* 角色与权限关联关系入参 | ||
* | ||
* @author Alan Yeh | ||
* @since 2024/12/16 | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class RolePermissionParams { | ||
|
||
@Label("应用主键") | ||
@NotBlank | ||
@Size(min = 1, max = 32) | ||
private String applicationId; | ||
|
||
@Label("角色主键") | ||
@NotBlank | ||
@Size(min = 1, max = 32) | ||
private String roleId; | ||
|
||
@Label("权限主键") | ||
@NotEmpty | ||
private List<String> permissionIds; | ||
|
||
public List<RolePermissionInput> toInputs() { | ||
return Listx.asStream(this.getPermissionIds()) | ||
.map(permissionId -> RolePermissionInput.builder() | ||
.applicationId(this.getApplicationId()) | ||
.roleId(this.getRoleId()) | ||
.permissionId(permissionId) | ||
.build()) | ||
.toList(); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...rc/main/java/central/studio/dashboard/controller/authority/param/RolePrincipalParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2022-present Alan Yeh <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package central.studio.dashboard.controller.authority.param; | ||
|
||
import central.data.authority.RolePrincipalInput; | ||
import central.data.authority.option.PrincipalType; | ||
import central.util.Listx; | ||
import central.validation.Enums; | ||
import central.validation.Label; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Role Principal Relation Params | ||
* <p> | ||
* 角色与主体关联关系入参 | ||
* | ||
* @author Alan Yeh | ||
* @since 2024/12/16 | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class RolePrincipalParams { | ||
|
||
@Label("应用主键") | ||
@NotBlank | ||
@Size(min = 1, max = 32) | ||
private String applicationId; | ||
|
||
@Label("角色") | ||
@NotBlank | ||
@Size(min = 1, max = 32) | ||
private String roleId; | ||
|
||
@Label("授权主体主键") | ||
@NotEmpty | ||
private List<String> principalIds; | ||
|
||
@Label("主体类型") | ||
@NotBlank | ||
@Enums(PrincipalType.class) | ||
private String type; | ||
|
||
public List<RolePrincipalInput> toInputs() { | ||
return Listx.asStream(this.getPrincipalIds()) | ||
.map(principalId -> RolePrincipalInput.builder() | ||
.applicationId(this.getApplicationId()) | ||
.roleId(this.getRoleId()) | ||
.type(this.getType()) | ||
.principalId(principalId) | ||
.build()) | ||
.toList(); | ||
} | ||
} |
Oops, something went wrong.