refactor(权限管理): 使用常量

This commit is contained in:
Captain.B 2021-05-23 09:25:52 +08:00 committed by 刘瑞斌
parent 350071c03d
commit 281853d4f7
11 changed files with 73 additions and 63 deletions

View File

@ -12,6 +12,7 @@ import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -76,7 +77,7 @@ public class ApiAutomationController {
@PostMapping(value = "/create")
@MsAuditLog(module = "api_automation", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
@RequiresPermissions("PROJECT_API_SCENARIO:READ+CREATE")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_CREATE)
public ApiScenario create(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles,
@RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) {
return apiAutomationService.create(request, bodyFiles, scenarioFiles);
@ -84,7 +85,7 @@ public class ApiAutomationController {
@PostMapping(value = "/update")
@MsAuditLog(module = "api_automation", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_EDIT)
public void update(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles,
@RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) {
apiAutomationService.update(request, bodyFiles, scenarioFiles);
@ -92,7 +93,7 @@ public class ApiAutomationController {
@GetMapping("/delete/{id}")
@MsAuditLog(module = "api_automation", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiAutomationService.class)
@RequiresPermissions("PROJECT_API_SCENARIO:READ+delete")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_DELETE)
public void delete(@PathVariable String id) {
apiAutomationService.delete(id);
}
@ -188,14 +189,14 @@ public class ApiAutomationController {
}
@PostMapping("/batch/edit")
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_EDIT)
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public void bathEdit(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.bathEdit(request);
}
@PostMapping("/batch/update/env")
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_EDIT)
@MsAuditLog(module = "api_automation", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public void batchUpdateEnv(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.batchUpdateEnv(request);
@ -248,21 +249,21 @@ public class ApiAutomationController {
}
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
@RequiresPermissions("PROJECT_API_SCENARIO:READ+IMPORT_SCENARIO")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_IMPORT_SCENARIO)
@MsAuditLog(module = "api_automation", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public ScenarioImport scenarioImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
return apiAutomationService.scenarioImport(file, request);
}
@PostMapping(value = "/export")
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_EXPORT_SCENARIO)
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public ApiScenrioExportResult export(@RequestBody ApiScenarioBatchRequest request) {
return apiAutomationService.export(request);
}
@PostMapping(value = "/export/jmx")
@RequiresPermissions("PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_EXPORT_SCENARIO)
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public List<ApiScenrioExportJmx> exportJmx(@RequestBody ApiScenarioBatchRequest request) {
return apiAutomationService.exportJmx(request);

View File

@ -20,6 +20,7 @@ import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.json.JSONSchemaGenerator;
import io.metersphere.commons.utils.CronUtils;
import io.metersphere.commons.utils.PageUtils;
@ -94,7 +95,7 @@ public class ApiDefinitionController {
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
@RequiresPermissions("PROJECT_API_DEFINITION:READ+CREATE_API")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_CREATE_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
public void create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
checkPermissionService.checkProjectOwner(request.getProjectId());
@ -102,7 +103,7 @@ public class ApiDefinitionController {
}
@PostMapping(value = "/update", consumes = {"multipart/form-data"})
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EDIT_API")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
public ApiDefinitionWithBLOBs update(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
checkPermissionService.checkProjectOwner(request.getProjectId());
@ -110,14 +111,14 @@ public class ApiDefinitionController {
}
@GetMapping("/delete/{id}")
@RequiresPermissions("PROJECT_API_DEFINITION:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = ApiDefinitionService.class)
public void delete(@PathVariable String id) {
apiDefinitionService.delete(id);
}
@PostMapping("/deleteBatch")
@RequiresPermissions("PROJECT_API_DEFINITION:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class)
public void deleteBatch(@RequestBody List<String> ids) {
apiDefinitionService.deleteBatch(ids);
@ -139,14 +140,14 @@ public class ApiDefinitionController {
}
@PostMapping("/removeToGc")
@RequiresPermissions("PROJECT_API_DEFINITION:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.GC, beforeEvent = "#msClass.getLogDetails(#ids)", msClass = ApiDefinitionService.class)
public void removeToGc(@RequestBody List<String> ids) {
apiDefinitionService.removeToGc(ids);
}
@PostMapping("/removeToGcByParams")
@RequiresPermissions("PROJECT_API_DEFINITION:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_DELETE_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_GC, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = ApiDefinitionService.class)
public void removeToGcByParams(@RequestBody ApiBatchRequest request) {
apiDefinitionService.removeToGcByParams(request);
@ -192,14 +193,14 @@ public class ApiDefinitionController {
}
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
@RequiresPermissions("PROJECT_API_DEFINITION:READ+IMPORT_API")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_IMPORT_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
return apiDefinitionService.apiTestImport(file, request);
}
@PostMapping(value = "/export/{type}")
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EXPORT_API")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EXPORT_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public ApiExportResult export(@RequestBody ApiBatchRequest request, @PathVariable String type) {
return apiDefinitionService.export(request, type);
@ -259,13 +260,13 @@ public class ApiDefinitionController {
}
@PostMapping("/batch/edit")
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EDIT_API")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API)
public void editApiBath(@RequestBody ApiBatchRequest request) {
apiDefinitionService.editApiBath(request);
}
@PostMapping("/batch/editByParams")
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EDIT_API")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request)", content = "#msClass.getLogDetails(#request)", msClass = ApiDefinitionService.class)
public void editByParams(@RequestBody ApiBatchRequest request) {
apiDefinitionService.editApiByParam(request);
@ -288,7 +289,7 @@ public class ApiDefinitionController {
}
@GetMapping("/export/esbExcelTemplate")
@RequiresPermissions("PROJECT_API_DEFINITION:READ+EXPORT_API")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EXPORT_API)
public void testCaseTemplateExport(HttpServletResponse response) {
esbImportService.templateExport(response);
}

View File

@ -75,37 +75,37 @@ public class PermissionConstants {
public static final String PROJECT_USER_READ_EDIT = "PROJECT_USER:READ+EDIT";
public static final String PROJECT_USER_READ_DELETE = "PROJECT_USER:READ+DELETE";
public static final String PROJECT_MANAGER_READ = "PROJECT_MANAGER:READ";
public static final String PROJECT_MANAGER_READ_ = "PROJECT_MANAGER:READ+CREATE";
public static final String PROJECT_MANAGER_READ_CREATE = "PROJECT_MANAGER:READ+CREATE";
public static final String PROJECT_MANAGER_READ_EDIT = "PROJECT_MANAGER:READ+EDIT";
public static final String PROJECT_MANAGER_READ_DELETE = "PROJECT_MANAGER:READ+DELETE";
public static final String PROJECT_ENVIRONMENT_READ = "PROJECT_ENVIRONMENT:READ";
public static final String PROJECT_ENVIRONMENT_READ_ = "PROJECT_ENVIRONMENT:READ+CREATE";
public static final String PROJECT_ENVIRONMENT_READ_CREATE = "PROJECT_ENVIRONMENT:READ+CREATE";
public static final String PROJECT_ENVIRONMENT_READ_EDIT = "PROJECT_ENVIRONMENT:READ+EDIT";
public static final String PROJECT_ENVIRONMENT_READ_DELETE = "PROJECT_ENVIRONMENT:READ+DELETE";
public static final String PROJECT_ENVIRONMENT_READ_COPY = "PROJECT_ENVIRONMENT:READ+COPY";
public static final String PROJECT_ENVIRONMENT_READ_IMPORT = "PROJECT_ENVIRONMENT:READ+IMPORT";
public static final String PROJECT_ENVIRONMENT_READ_EXPORT = "PROJECT_ENVIRONMENT:READ+EXPORT";
public static final String PROJECT_TRACK_CASE_READ = "PROJECT_TRACK_CASE:READ";
public static final String PROJECT_TRACK_CASE_READ_ = "PROJECT_TRACK_CASE:READ+CREATE";
public static final String PROJECT_TRACK_CASE_READ_CREATE = "PROJECT_TRACK_CASE:READ+CREATE";
public static final String PROJECT_TRACK_CASE_READ_EDIT = "PROJECT_TRACK_CASE:READ+EDIT";
public static final String PROJECT_TRACK_CASE_READ_DELETE = "PROJECT_TRACK_CASE:READ+DELETE";
public static final String PROJECT_TRACK_CASE_READ_COPY = "PROJECT_TRACK_CASE:READ+COPY";
public static final String PROJECT_TRACK_CASE_READ_IMPORT = "PROJECT_TRACK_CASE:READ+IMPORT";
public static final String PROJECT_TRACK_CASE_READ_EXPORT = "PROJECT_TRACK_CASE:READ+EXPORT";
public static final String PROJECT_TRACK_REVIEW_READ = "PROJECT_TRACK_REVIEW:READ";
public static final String PROJECT_TRACK_REVIEW_READ_ = "PROJECT_TRACK_REVIEW:READ+CREATE";
public static final String PROJECT_TRACK_REVIEW_READ_CREATE = "PROJECT_TRACK_REVIEW:READ+CREATE";
public static final String PROJECT_TRACK_REVIEW_READ_EDIT = "PROJECT_TRACK_REVIEW:READ+EDIT";
public static final String PROJECT_TRACK_REVIEW_READ_DELETE = "PROJECT_TRACK_REVIEW:READ+DELETE";
public static final String PROJECT_TRACK_REVIEW_READ_COMMENT = "PROJECT_TRACK_REVIEW:READ+COMMENT";
public static final String PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL = "PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL";
public static final String PROJECT_TRACK_PLAN_READ = "PROJECT_TRACK_PLAN:READ";
public static final String PROJECT_TRACK_PLAN_READ_ = "PROJECT_TRACK_PLAN:READ+CREATE";
public static final String PROJECT_TRACK_PLAN_READ_CREATE = "PROJECT_TRACK_PLAN:READ+CREATE";
public static final String PROJECT_TRACK_PLAN_READ_EDIT = "PROJECT_TRACK_PLAN:READ+EDIT";
public static final String PROJECT_TRACK_PLAN_READ_DELETE = "PROJECT_TRACK_PLAN:READ+DELETE";
public static final String PROJECT_TRACK_PLAN_READ_SCHEDULE = "PROJECT_TRACK_PLAN:READ+SCHEDULE";
public static final String PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL = "PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL";
public static final String PROJECT_API_DEFINITION_READ = "PROJECT_API_DEFINITION:READ";
public static final String PROJECT_API_DEFINITION_READ_ = "PROJECT_API_DEFINITION:READ+CREATE_API";
public static final String PROJECT_API_DEFINITION_READ_CREATE_API = "PROJECT_API_DEFINITION:READ+CREATE_API";
public static final String PROJECT_API_DEFINITION_READ_EDIT_API = "PROJECT_API_DEFINITION:READ+EDIT_API";
public static final String PROJECT_API_DEFINITION_READ_DELETE_API = "PROJECT_API_DEFINITION:READ+DELETE_API";
public static final String PROJECT_API_DEFINITION_READ_CREATE_CASE = "PROJECT_API_DEFINITION:READ+CREATE_CASE";
@ -119,7 +119,7 @@ public class PermissionConstants {
public static final String PROJECT_API_DEFINITION_READ_DEBUG = "PROJECT_API_DEFINITION:READ+DEBUG";
public static final String PROJECT_API_DEFINITION_READ_MOCK = "PROJECT_API_DEFINITION:READ+MOCK";
public static final String PROJECT_API_SCENARIO_READ = "PROJECT_API_SCENARIO:READ";
public static final String PROJECT_API_SCENARIO_READ_ = "PROJECT_API_SCENARIO:READ+CREATE";
public static final String PROJECT_API_SCENARIO_READ_CREATE = "PROJECT_API_SCENARIO:READ+CREATE";
public static final String PROJECT_API_SCENARIO_READ_EDIT = "PROJECT_API_SCENARIO:READ+EDIT";
public static final String PROJECT_API_SCENARIO_READ_DELETE = "PROJECT_API_SCENARIO:READ+DELETE";
public static final String PROJECT_API_SCENARIO_READ_COPY = "PROJECT_API_SCENARIO:READ+COPY";
@ -133,7 +133,7 @@ public class PermissionConstants {
public static final String PROJECT_API_REPORT_READ = "PROJECT_API_REPORT:READ";
public static final String PROJECT_API_REPORT_READ_DELETE = "PROJECT_API_REPORT:READ+DELETE";
public static final String PROJECT_PERFORMANCE_TEST_READ = "PROJECT_PERFORMANCE_TEST:READ";
public static final String PROJECT_PERFORMANCE_TEST_READ_ = "PROJECT_PERFORMANCE_TEST:READ+CREATE";
public static final String PROJECT_PERFORMANCE_TEST_READ_CREATE = "PROJECT_PERFORMANCE_TEST:READ+CREATE";
public static final String PROJECT_PERFORMANCE_TEST_READ_EDIT = "PROJECT_PERFORMANCE_TEST:READ+EDIT";
public static final String PROJECT_PERFORMANCE_TEST_READ_DELETE = "PROJECT_PERFORMANCE_TEST:READ+DELETE";
public static final String PROJECT_PERFORMANCE_TEST_READ_COPY = "PROJECT_PERFORMANCE_TEST:READ+COPY";

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.LoadTestReportLog;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.LogDetailDTO;
@ -45,7 +46,7 @@ public class PerformanceReportController {
}
@PostMapping("/delete/{reportId}")
@RequiresPermissions("PROJECT_PERFORMANCE_REPORT:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_REPORT_READ_DELETE)
@MsAuditLog(module = "performance_test_report", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#reportId)", msClass = PerformanceReportService.class)
public void deleteReport(@PathVariable String reportId) {
performanceReportService.deleteReport(reportId);
@ -129,7 +130,7 @@ public class PerformanceReportController {
}
@PostMapping("/batch/delete")
@RequiresPermissions("PROJECT_PERFORMANCE_REPORT:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_REPORT_READ_DELETE)
@MsAuditLog(module = "performance_test_report", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#reportRequest.ids)", msClass = PerformanceReportService.class)
public void deleteReportBatch(@RequestBody DeleteReportRequest reportRequest) {
performanceReportService.deleteReportBatch(reportRequest);

View File

@ -6,6 +6,7 @@ import io.metersphere.base.domain.FileMetadata;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -75,7 +76,7 @@ public class PerformanceTestController {
@PostMapping(value = "/save", consumes = {"multipart/form-data"})
@MsAuditLog(module = "performance_test", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = PerformanceTestService.class)
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ+CREATE")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_CREATE)
public String save(
@RequestPart("request") SaveTestPlanRequest request,
@RequestPart(value = "file") List<MultipartFile> files
@ -87,7 +88,7 @@ public class PerformanceTestController {
@PostMapping(value = "/edit", consumes = {"multipart/form-data"})
@MsAuditLog(module = "performance_test", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = PerformanceTestService.class)
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_EDIT)
public String edit(
@RequestPart("request") EditTestPlanRequest request,
@RequestPart(value = "file", required = false) List<MultipartFile> files
@ -136,7 +137,7 @@ public class PerformanceTestController {
@PostMapping("/delete")
@MsAuditLog(module = "performance_test", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#request.id)", msClass = PerformanceTestService.class)
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_DELETE)
public void delete(@RequestBody DeleteTestPlanRequest request) {
checkPermissionService.checkPerformanceTestOwner(request.getId());
performanceTestService.delete(request);
@ -144,7 +145,7 @@ public class PerformanceTestController {
@PostMapping("/run")
@MsAuditLog(module = "performance_test", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.id)", msClass = PerformanceTestService.class)
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ+RUN")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_RUN)
public String run(@RequestBody RunTestPlanRequest request) {
return performanceTestService.run(request);
}
@ -186,19 +187,19 @@ public class PerformanceTestController {
@PostMapping(value = "/copy")
@MsAuditLog(module = "performance_test", type = OperLogConstants.COPY, content = "#msClass.getLogDetails(#request.id)", msClass = PerformanceTestService.class)
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ+COPY")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_COPY)
public void copy(@RequestBody SaveTestPlanRequest request) {
performanceTestService.copy(request);
}
@PostMapping(value = "/schedule/create")
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ+SCHEDULE")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_SCHEDULE)
public void createSchedule(@RequestBody ScheduleRequest request) {
performanceTestService.createSchedule(request);
}
@PostMapping(value = "/schedule/update")
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ+SCHEDULE")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_SCHEDULE)
public void updateSchedule(@RequestBody Schedule request) {
performanceTestService.updateSchedule(request);
}

View File

@ -1,6 +1,7 @@
package io.metersphere.track.controller;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.dto.TestCaseCommentDTO;
import io.metersphere.track.request.testreview.SaveCommentRequest;
@ -20,7 +21,7 @@ public class TestCaseCommentController {
private TestCaseCommentService testCaseCommentService;
@PostMapping("/save")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+COMMENT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseCommentService.class)
public void saveComment(@RequestBody SaveCommentRequest request) {
request.setId(UUID.randomUUID().toString());
@ -33,14 +34,14 @@ public class TestCaseCommentController {
}
@GetMapping("/delete/{commentId}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+COMMENT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#commentId)", msClass = TestCaseCommentService.class)
public void deleteComment(@PathVariable String commentId) {
testCaseCommentService.delete(commentId);
}
@PostMapping("/edit")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+COMMENT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseCommentService.class)
public void editComment(@RequestBody SaveCommentRequest request) {
testCaseCommentService.edit(request);

View File

@ -7,6 +7,7 @@ import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
@ -46,7 +47,7 @@ public class TestCaseController {
private FileService fileService;
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_CASE:READ")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public Pager<List<TestCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.listTestCase(request));
@ -126,7 +127,7 @@ public class TestCaseController {
}
@PostMapping(value = "/add", consumes = {"multipart/form-data"})
@RequiresPermissions("PROJECT_TRACK_CASE:READ+CREATE")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_CREATE)
@MsAuditLog(module = "track_test_case", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class)
public String addTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file") List<MultipartFile> files) {
request.setId(UUID.randomUUID().toString());
@ -164,7 +165,7 @@ public class TestCaseController {
}
@PostMapping("/importIgnoreError/{projectId}/{userId}")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+IMPORT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_IMPORT)
@MsAuditLog(module = "track_test_case", type = OperLogConstants.IMPORT, project = "#projectId")
public ExcelResponse testCaseImportIgnoreError(MultipartFile file, @PathVariable String projectId, @PathVariable String userId, HttpServletRequest request) {
checkPermissionService.checkProjectOwner(projectId);
@ -172,33 +173,33 @@ public class TestCaseController {
}
@GetMapping("/export/template")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+EXPORT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EXPORT)
public void testCaseTemplateExport(HttpServletResponse response) {
testCaseService.testCaseTemplateExport(response);
}
@GetMapping("/export/xmindTemplate")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+EXPORT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EXPORT)
public void xmindTemplate(HttpServletResponse response) {
testCaseService.testCaseXmindTemplateExport(response);
}
@PostMapping("/export/testcase")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+EXPORT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EXPORT)
@MsAuditLog(module = "track_test_case", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public void testCaseExport(HttpServletResponse response, @RequestBody TestCaseBatchRequest request) {
testCaseService.testCaseExport(response, request);
}
@PostMapping("/batch/edit")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
@MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class)
public void editTestCaseBath(@RequestBody TestCaseBatchRequest request) {
testCaseService.editTestCaseBath(request);
}
@PostMapping("/batch/delete")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE)
@MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class)
public void deleteTestCaseBath(@RequestBody TestCaseBatchRequest request) {
testCaseService.deleteTestCaseBath(request);
@ -235,7 +236,7 @@ public class TestCaseController {
}
@PostMapping("/minder/edit")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
@MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_UPDATE, project = "#request.projectId", beforeEvent = "#msClass.getLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class)
public void minderEdit(@RequestBody TestCaseMinderEditRequest request) {
testCaseService.minderEdit(request);

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
@ -30,7 +31,7 @@ public class TestCaseReviewApiCaseController {
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
@ -38,19 +39,19 @@ public class TestCaseReviewApiCaseController {
}
@GetMapping("/delete/{id}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
public int deleteTestCase(@PathVariable String id) {
return testCaseReviewApiCaseService.delete(id);
}
@PostMapping("/batch/delete")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
public void deleteApiCaseBath(@RequestBody TestReviewApiCaseBatchRequest request) {
testCaseReviewApiCaseService.deleteApiCaseBath(request);
}
@PostMapping("/batch/update/env")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
public void batchUpdateEnv(@RequestBody TestPlanApiCaseBatchRequest request) {
testCaseReviewApiCaseService.batchUpdateEnv(request);
}

View File

@ -6,6 +6,7 @@ import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.TestCaseReview;
import io.metersphere.base.domain.User;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -48,7 +49,7 @@ public class TestCaseReviewController {
}
@PostMapping("/save")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+CREATE")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_CREATE)
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.CREATE, title = "#reviewRequest.name", content = "#msClass.getLogDetails(#reviewRequest.id)", msClass = TestCaseReviewService.class)
public String saveCaseReview(@RequestBody SaveTestCaseReviewRequest reviewRequest) {
reviewRequest.setId(UUID.randomUUID().toString());
@ -73,14 +74,14 @@ public class TestCaseReviewController {
}
@PostMapping("/edit")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_EDIT)
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testCaseReview.id)", title = "#testCaseReview.name", content = "#msClass.getLogDetails(#testCaseReview.id)", msClass = TestCaseReviewService.class)
public String editCaseReview(@RequestBody SaveTestCaseReviewRequest testCaseReview) {
return testCaseReviewService.editCaseReview(testCaseReview);
}
@GetMapping("/delete/{reviewId}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_DELETE)
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#reviewId)", msClass = TestCaseReviewService.class)
public void deleteCaseReview(@PathVariable String reviewId) {
checkPermissionService.checkTestReviewOwner(reviewId);
@ -121,7 +122,7 @@ public class TestCaseReviewController {
}
@PostMapping("/edit/status/{reviewId}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_EDIT)
public void editTestPlanStatus(@PathVariable String reviewId) {
checkPermissionService.checkTestReviewOwner(reviewId);
testCaseReviewService.editTestReviewStatus(reviewId);

View File

@ -6,6 +6,7 @@ import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -45,21 +46,21 @@ public class TestPlanApiCaseController {
}
@GetMapping("/delete/{id}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanApiCaseService.class)
public int deleteTestCase(@PathVariable String id) {
return testPlanApiCaseService.delete(id);
}
@PostMapping("/batch/delete")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanApiCaseService.class)
public void deleteApiCaseBath(@RequestBody TestPlanApiCaseBatchRequest request) {
testPlanApiCaseService.deleteApiCaseBath(request);
}
@PostMapping("/batch/update/env")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.batchLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanApiCaseService.class)
public void batchUpdateEnv(@RequestBody TestPlanApiCaseBatchRequest request) {
testPlanApiCaseService.batchUpdateEnv(request);

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.TestPlan;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -88,7 +89,7 @@ public class TestPlanController {
}
@PostMapping("/add")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+CREATE")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_CREATE)
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.CREATE, title = "#testPlan.name", content = "#msClass.getLogDetails(#testPlan.id)", msClass = TestPlanService.class)
public String addTestPlan(@RequestBody AddTestPlanRequest testPlan) {
testPlan.setId(UUID.randomUUID().toString());
@ -97,14 +98,14 @@ public class TestPlanController {
}
@PostMapping("/edit")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT)
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanDTO.id)", content = "#msClass.getLogDetails(#testPlanDTO.id)", msClass = TestPlanService.class)
public String editTestPlan(@RequestBody TestPlanDTO testPlanDTO) {
return testPlanService.editTestPlan(testPlanDTO, true);
}
@PostMapping("/edit/status/{planId}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+EDIT")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_EDIT)
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#planId)", content = "#msClass.getLogDetails(#planId)", msClass = TestPlanService.class)
public void editTestPlanStatus(@PathVariable String planId) {
checkPermissionService.checkTestPlanOwner(planId);
@ -112,7 +113,7 @@ public class TestPlanController {
}
@PostMapping("/delete/{testPlanId}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+DELETE")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_DELETE)
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanId)", msClass = TestPlanService.class)
public int deleteTestPlan(@PathVariable String testPlanId) {
checkPermissionService.checkTestPlanOwner(testPlanId);