feat(任务中心): 新增组织&项目任务中心权限

This commit is contained in:
WangXu10 2024-10-09 15:36:06 +08:00 committed by Craftsman
parent 79ae95ec07
commit ad9be10fca
9 changed files with 100 additions and 10 deletions

View File

@ -338,5 +338,23 @@ public class PermissionConstants {
/*------ start: ORGANIZATION_TASK_CENTER_READ ------*/
public static final String ORGANIZATION_TASK_CENTER_READ = "ORGANIZATION_TASK_CENTER:READ";
public static final String ORGANIZATION_TASK_CENTER_READ_STOP = "ORGANIZATION_TASK_CENTER:READ+STOP";
public static final String ORGANIZATION_CASE_TASK_CENTER_READ = "ORGANIZATION_CASE_TASK_CENTER:READ";
public static final String ORGANIZATION_CASE_TASK_CENTER_EXEC_STOP = "ORGANIZATION_CASE_TASK_CENTER:EXEC+STOP";
public static final String ORGANIZATION_CASE_TASK_CENTER_DELETE = "ORGANIZATION_CASE_TASK_CENTER:READ+DELETE";
//后台任务
public static final String ORGANIZATION_SCHEDULE_TASK_CENTER_READ = "ORGANIZATION_SCHEDULE_TASK_CENTER:READ";
public static final String ORGANIZATION_SCHEDULE_TASK_CENTER_READ_UPDATE = "ORGANIZATION_SCHEDULE_TASK_CENTER:READ+UPDATE";
public static final String ORGANIZATION_SCHEDULE_TASK_CENTER_READ_DELETE = "ORGANIZATION_SCHEDULE_TASK_CENTER:READ+DELETE";
/*------ end: ORGANIZATION_TASK_CENTER_READ ------*/
/*------ start: PROJECT_TASK_CENTER_READ ------*/
public static final String PROJECT_CASE_TASK_CENTER_READ = "PROJECT_CASE_TASK_CENTER:READ";
public static final String PROJECT_CASE_TASK_CENTER_EXEC_STOP = "PROJECT_CASE_TASK_CENTER:EXEC+STOP";
public static final String PROJECT_CASE_TASK_CENTER_DELETE = "PROJECT_CASE_TASK_CENTER:READ+DELETE";
public static final String PROJECT_SCHEDULE_TASK_CENTER_READ = "PROJECT_SCHEDULE_TASK_CENTER:READ";
public static final String PROJECT_SCHEDULE_TASK_CENTER_READ_UPDATE = "PROJECT_SCHEDULE_TASK_CENTER:READ+UPDATE";
public static final String PROJECT_SCHEDULE_TASK_CENTER_READ_DELETE = "PROJECT_SCHEDULE_TASK_CENTER:READ+DELETE";
/*------ end: PROJECT_TASK_CENTER_READ ------*/
}

View File

@ -601,3 +601,9 @@ permission.project_custom_function.name=Common script
permission.project_custom_function.execute=Test
message.domain.report.name=Report name
permission.project_task_center.name=Task center
permission.project_case_task_center.name=Case task
permission.project_schedule_task_center.name=Schedule task
permission.project_case_task_center.exec=exec/stop

View File

@ -600,3 +600,8 @@ permission.project_custom_function.name=公共脚本
permission.project_custom_function.execute=测试
message.domain.report.name=报告名称
permission.project_task_center.name=任务中心
permission.project_case_task_center.name=用例执行任务
permission.project_schedule_task_center.name=系统后台任务
permission.project_case_task_center.exec=执行/停止

View File

@ -600,3 +600,8 @@ permission.project_custom_function.name=公共腳本
permission.project_custom_function.execute=測試
message.domain.report.name=報告名稱
permission.project_task_center.name=任務中心
permission.project_case_task_center.name=用例執行任務
permission.project_schedule_task_center.name=系統後臺任務
permission.project_case_task_center.exec=執行/停止

View File

@ -30,13 +30,14 @@ public class ProjectTaskHubController {
@PostMapping("/exec-task/page")
@Operation(summary = "项目-任务中心-执行任务列表")
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_READ)
public Pager<List<TaskHubDTO>> projectList(@Validated @RequestBody BasePageRequest request) {
return baseTaskHubService.getTaskList(request, null, SessionUtils.getCurrentProjectId());
}
@PostMapping("/schedule/page")
@Operation(summary = "项目-任务中心-后台执行任务列表")
@RequiresPermissions(PermissionConstants.SYSTEM_SCHEDULE_TASK_CENTER_READ)
@RequiresPermissions(PermissionConstants.PROJECT_SCHEDULE_TASK_CENTER_READ)
public Pager<List<TaskHubScheduleDTO>> scheduleList(@Validated @RequestBody BasePageRequest request) {
return baseTaskHubService.getScheduleTaskList(request, List.of(SessionUtils.getCurrentProjectId()));
}

View File

@ -205,5 +205,43 @@
]
}
]
},
{
"id": "PROJECT_TASK_CENTER",
"name": "permission.project_task_center.name",
"type": "PROJECT",
"children": [
{
"id": "PROJECT_CASE_TASK_CENTER",
"name": "permission.project_case_task_center.name",
"permissions": [
{
"id": "PROJECT_CASE_TASK_CENTER:READ"
},
{
"id": "PROJECT_CASE_TASK_CENTER:EXEC+STOP",
"name": "permission.project_case_task_center.exec"
},
{
"id": "PROJECT_CASE_TASK_CENTER:READ+DELETE"
}
]
},
{
"id": "PROJECT_SCHEDULE_TASK_CENTER",
"name": "permission.project_schedule_task_center.name",
"permissions": [
{
"id": "PROJECT_SCHEDULE_TASK_CENTER:READ"
},
{
"id": "PROJECT_SCHEDULE_TASK_CENTER:READ+UPDATE"
},
{
"id": "PROJECT_SCHEDULE_TASK_CENTER:READ+DELETE"
}
]
}
]
}
]

View File

@ -235,7 +235,7 @@ public class ProjectUserRoleControllerTests extends BaseTest {
// 返回请求正常
Assertions.assertNotNull(resultHolder);
// 返回总条数是否为init_project_user_role.sql中的数据总数
Assertions.assertEquals(1, JSON.parseArray(JSON.toJSONString(resultHolder.getData())).size());
Assertions.assertEquals(2, JSON.parseArray(JSON.toJSONString(resultHolder.getData())).size());
// 权限校验
requestGetPermissionTest(PermissionConstants.PROJECT_GROUP_READ, PROJECT_USER_ROLE_PERMISSION_SETTING + "/default-pro-role-id-3");
}

View File

@ -33,7 +33,7 @@ public class OrganizationTaskHubController {
@PostMapping("/exec-task/page")
@Operation(summary = "组织-任务中心-执行任务列表")
@RequiresPermissions(PermissionConstants.ORGANIZATION_TASK_CENTER_READ)
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_READ)
public Pager<List<TaskHubDTO>> projectList(@Validated @RequestBody BasePageRequest request) {
return baseTaskHubService.getTaskList(request, SessionUtils.getCurrentOrganizationId(), null);
}
@ -41,7 +41,7 @@ public class OrganizationTaskHubController {
@PostMapping("/schedule/page")
@Operation(summary = "组织-任务中心-后台执行任务列表")
@RequiresPermissions(PermissionConstants.SYSTEM_SCHEDULE_TASK_CENTER_READ)
@RequiresPermissions(PermissionConstants.ORGANIZATION_SCHEDULE_TASK_CENTER_READ)
public Pager<List<TaskHubScheduleDTO>> scheduleList(@Validated @RequestBody BasePageRequest request) {
List<OptionDTO> projectList = baseProjectMapper.getProjectOptionsByOrgId(SessionUtils.getCurrentOrganizationId());
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();

View File

@ -370,11 +370,28 @@
"name": "permission.organization_task_center.name",
"permissions": [
{
"id": "ORGANIZATION_TASK_CENTER:READ"
"id": "ORGANIZATION_CASE_TASK_CENTER:READ",
"name": "permission.case_task_center.read"
},
{
"id": "ORGANIZATION_TASK_CENTER:READ+STOP",
"name": "permission.organization_task_center.stop"
"id": "ORGANIZATION_CASE_TASK_CENTER:EXEC+STOP",
"name": "permission.case_task_center.exec"
},
{
"id": "ORGANIZATION_CASE_TASK_CENTER:READ+DELETE",
"name": "permission.case_task_center.delete"
},
{
"id": "ORGANIZATION_SCHEDULE_TASK_CENTER:READ",
"name": "permission.schedule_task_center.read"
},
{
"id": "ORGANIZATION_SCHEDULE_TASK_CENTER:READ+UPDATE",
"name": "permission.schedule_task_center.update"
},
{
"id": "ORGANIZATION_SCHEDULE_TASK_CENTER:READ+DELETE",
"name": "permission.schedule_task_center.delete"
}
]
}