refactor(接口管理): 优化接口管理权限

This commit is contained in:
wxg0103 2023-11-09 11:36:49 +08:00 committed by wxg0103
parent 22ad3f3a85
commit 03b1f8c7b4
3 changed files with 15 additions and 15 deletions

View File

@ -238,11 +238,11 @@ public class PermissionConstants {
/*------ start: API_MANAGEMENT ------*/
public static final String PROJECT_API_DEFINITION_READ = "PROJECT_API_DEFINITION:READ";
public static final String PROJECT_API_DEFINITION_READ_ADD = "PROJECT_API_DEFINITION:READ+ADD";
public static final String PROJECT_API_DEFINITION_READ_UPDATE = "PROJECT_API_DEFINITION:READ+UPDATE";
public static final String PROJECT_API_DEFINITION_READ_DELETE = "PROJECT_API_DEFINITION:READ+DELETE";
public static final String PROJECT_API_DEFINITION_READ_IMPORT = "PROJECT_API_DEFINITION:READ+IMPORT";
public static final String PROJECT_API_DEFINITION_READ_EXPORT = "PROJECT_API_DEFINITION:READ+EXPORT";
public static final String PROJECT_API_DEFINITION_READ_EXECUTE = "PROJECT_API_DEFINITION:READ+EXECUTE";
/*------ end: API_DEBUG ------*/
public static final String PROJECT_API_DEFINITION_ADD = "PROJECT_API_DEFINITION:READ+ADD";
public static final String PROJECT_API_DEFINITION_UPDATE = "PROJECT_API_DEFINITION:READ+UPDATE";
public static final String PROJECT_API_DEFINITION_DELETE = "PROJECT_API_DEFINITION:READ+DELETE";
public static final String PROJECT_API_DEFINITION_IMPORT = "PROJECT_API_DEFINITION:READ+IMPORT";
public static final String PROJECT_API_DEFINITION_EXPORT = "PROJECT_API_DEFINITION:READ+EXPORT";
public static final String PROJECT_API_DEFINITION_EXECUTE = "PROJECT_API_DEFINITION:READ+EXECUTE";
/*------ end: API_MANAGEMENT ------*/
}

View File

@ -35,14 +35,14 @@ public class ApiDefinitionModuleController {
@PostMapping("/add")
@Operation(summary = "接口测试-接口管理-模块-添加模块")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_ADD)
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_ADD)
public String add(@RequestBody @Validated ModuleCreateRequest request) {
return apiDefinitionModuleService.add(request, SessionUtils.getUserId());
}
@PostMapping("/update")
@Operation(summary = "接口测试-接口管理-模块-修改模块")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_UPDATE)
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_UPDATE)
public boolean list(@RequestBody @Validated ModuleUpdateRequest request) {
apiDefinitionModuleService.update(request, SessionUtils.getUserId());
return true;
@ -50,14 +50,14 @@ public class ApiDefinitionModuleController {
@GetMapping("/delete/{deleteId}")
@Operation(summary = "接口测试-接口管理-模块-删除模块")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE)
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_DELETE)
public void deleteNode(@PathVariable String deleteId) {
apiDefinitionModuleService.deleteModule(deleteId, SessionUtils.getUserId());
}
@PostMapping("/move")
@Operation(summary = "接口测试-接口管理-模块-移动模块")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_UPDATE)
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_UPDATE)
public void moveNode(@Validated @RequestBody NodeMoveRequest request) {
apiDefinitionModuleService.moveNode(request, SessionUtils.getUserId());
}

View File

@ -288,7 +288,7 @@ public class ApiDefinitionModuleControllerTests extends BaseTest {
request = new ModuleCreateRequest();
request.setProjectId(DEFAULT_PROJECT_ID);
request.setName("defaultProject");
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_READ_ADD, URL_MODULE_ADD, request);
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_ADD, URL_MODULE_ADD, request);
}
@Test
@ -386,7 +386,7 @@ public class ApiDefinitionModuleControllerTests extends BaseTest {
updateRequest = new ModuleUpdateRequest();
updateRequest.setId(apiDebugModules.get(0).getId());
updateRequest.setName("default-update-Project");
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_READ_UPDATE, URL_MODULE_UPDATE, updateRequest);
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_UPDATE, URL_MODULE_UPDATE, updateRequest);
}
@Test
@ -659,7 +659,7 @@ public class ApiDefinitionModuleControllerTests extends BaseTest {
checkLog(a1Node.getId(), OperationLogType.UPDATE, URL_MODULE_MOVE);
checkLog(a3Node.getId(), OperationLogType.UPDATE, URL_MODULE_MOVE);
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_READ_UPDATE, URL_MODULE_MOVE, request);
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_UPDATE, URL_MODULE_MOVE, request);
}
@Test
@ -773,7 +773,7 @@ public class ApiDefinitionModuleControllerTests extends BaseTest {
//service层判断测试删除空集合
apiDefinitionModuleService.deleteModule(new ArrayList<>(), "admin", DEFAULT_PROJECT_ID);
//校验权限
requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE, String.format(URL_MODULE_DELETE, IDGenerator.nextNum()));
requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_DELETE, String.format(URL_MODULE_DELETE, IDGenerator.nextNum()));
}