refactor(权限管理): 测试跟踪权限

This commit is contained in:
Captain.B 2021-05-21 18:10:34 +08:00 committed by 刘瑞斌
parent f2e562e850
commit 8e583f7254
8 changed files with 53 additions and 49 deletions

View File

@ -5,6 +5,7 @@ import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.dto.TestCaseCommentDTO; import io.metersphere.track.dto.TestCaseCommentDTO;
import io.metersphere.track.request.testreview.SaveCommentRequest; import io.metersphere.track.request.testreview.SaveCommentRequest;
import io.metersphere.track.service.TestCaseCommentService; import io.metersphere.track.service.TestCaseCommentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -19,6 +20,7 @@ public class TestCaseCommentController {
private TestCaseCommentService testCaseCommentService; private TestCaseCommentService testCaseCommentService;
@PostMapping("/save") @PostMapping("/save")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+COMMENT")
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseCommentService.class) @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseCommentService.class)
public void saveComment(@RequestBody SaveCommentRequest request) { public void saveComment(@RequestBody SaveCommentRequest request) {
request.setId(UUID.randomUUID().toString()); request.setId(UUID.randomUUID().toString());
@ -31,12 +33,14 @@ public class TestCaseCommentController {
} }
@GetMapping("/delete/{commentId}") @GetMapping("/delete/{commentId}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+COMMENT")
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#commentId)", msClass = TestCaseCommentService.class) @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#commentId)", msClass = TestCaseCommentService.class)
public void deleteComment(@PathVariable String commentId) { public void deleteComment(@PathVariable String commentId) {
testCaseCommentService.delete(commentId); testCaseCommentService.delete(commentId);
} }
@PostMapping("/edit") @PostMapping("/edit")
@RequiresPermissions("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) @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) { public void editComment(@RequestBody SaveCommentRequest request) {
testCaseCommentService.edit(request); testCaseCommentService.edit(request);

View File

@ -7,7 +7,6 @@ import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.TestCase; import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
@ -22,8 +21,7 @@ import io.metersphere.track.request.testcase.TestCaseBatchRequest;
import io.metersphere.track.request.testcase.TestCaseMinderEditRequest; import io.metersphere.track.request.testcase.TestCaseMinderEditRequest;
import io.metersphere.track.request.testplan.FileOperationRequest; import io.metersphere.track.request.testplan.FileOperationRequest;
import io.metersphere.track.service.TestCaseService; import io.metersphere.track.service.TestCaseService;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -38,7 +36,6 @@ import java.util.UUID;
@RequestMapping("/test/case") @RequestMapping("/test/case")
@RestController @RestController
public class TestCaseController { public class TestCaseController {
@Resource @Resource
@ -49,12 +46,14 @@ public class TestCaseController {
private FileService fileService; private FileService fileService;
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_CASE:READ")
public Pager<List<TestCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) { public Pager<List<TestCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.listTestCase(request)); return PageUtils.setPageInfo(page, testCaseService.listTestCase(request));
} }
@GetMapping("/list/{projectId}") @GetMapping("/list/{projectId}")
@RequiresPermissions("PROJECT_TRACK_CASE:READ")
public List<TestCaseDTO> list(@PathVariable String projectId) { public List<TestCaseDTO> list(@PathVariable String projectId) {
checkPermissionService.checkProjectOwner(projectId); checkPermissionService.checkProjectOwner(projectId);
QueryTestCaseRequest request = new QueryTestCaseRequest(); QueryTestCaseRequest request = new QueryTestCaseRequest();
@ -127,7 +126,7 @@ public class TestCaseController {
} }
@PostMapping(value = "/add", consumes = {"multipart/form-data"}) @PostMapping(value = "/add", consumes = {"multipart/form-data"})
@RequiresPermissions("PROJECT_TRACK_CASE:READ+CREATE")
@MsAuditLog(module = "track_test_case", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class) @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) { public String addTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file") List<MultipartFile> files) {
request.setId(UUID.randomUUID().toString()); request.setId(UUID.randomUUID().toString());
@ -165,7 +164,7 @@ public class TestCaseController {
} }
@PostMapping("/importIgnoreError/{projectId}/{userId}") @PostMapping("/importIgnoreError/{projectId}/{userId}")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+IMPORT")
@MsAuditLog(module = "track_test_case", type = OperLogConstants.IMPORT, project = "#projectId") @MsAuditLog(module = "track_test_case", type = OperLogConstants.IMPORT, project = "#projectId")
public ExcelResponse testCaseImportIgnoreError(MultipartFile file, @PathVariable String projectId, @PathVariable String userId, HttpServletRequest request) { public ExcelResponse testCaseImportIgnoreError(MultipartFile file, @PathVariable String projectId, @PathVariable String userId, HttpServletRequest request) {
checkPermissionService.checkProjectOwner(projectId); checkPermissionService.checkProjectOwner(projectId);
@ -173,33 +172,33 @@ public class TestCaseController {
} }
@GetMapping("/export/template") @GetMapping("/export/template")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+EXPORT")
public void testCaseTemplateExport(HttpServletResponse response) { public void testCaseTemplateExport(HttpServletResponse response) {
testCaseService.testCaseTemplateExport(response); testCaseService.testCaseTemplateExport(response);
} }
@GetMapping("/export/xmindTemplate") @GetMapping("/export/xmindTemplate")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+EXPORT")
public void xmindTemplate(HttpServletResponse response) { public void xmindTemplate(HttpServletResponse response) {
testCaseService.testCaseXmindTemplateExport(response); testCaseService.testCaseXmindTemplateExport(response);
} }
@PostMapping("/export/testcase") @PostMapping("/export/testcase")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+EXPORT")
@MsAuditLog(module = "track_test_case", type = OperLogConstants.EXPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId") @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) { public void testCaseExport(HttpServletResponse response, @RequestBody TestCaseBatchRequest request) {
testCaseService.testCaseExport(response, request); testCaseService.testCaseExport(response, request);
} }
@PostMapping("/batch/edit") @PostMapping("/batch/edit")
@RequiresPermissions("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) @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) { public void editTestCaseBath(@RequestBody TestCaseBatchRequest request) {
testCaseService.editTestCaseBath(request); testCaseService.editTestCaseBath(request);
} }
@PostMapping("/batch/delete") @PostMapping("/batch/delete")
@RequiresPermissions("PROJECT_TRACK_CASE:READ+DELETE")
@MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class) @MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class)
public void deleteTestCaseBath(@RequestBody TestCaseBatchRequest request) { public void deleteTestCaseBath(@RequestBody TestCaseBatchRequest request) {
testCaseService.deleteTestCaseBath(request); testCaseService.deleteTestCaseBath(request);
@ -236,7 +235,7 @@ public class TestCaseController {
} }
@PostMapping("/minder/edit") @PostMapping("/minder/edit")
@RequiresPermissions("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) @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) { public void minderEdit(@RequestBody TestCaseMinderEditRequest request) {
testCaseService.minderEdit(request); testCaseService.minderEdit(request);

View File

@ -2,12 +2,9 @@ package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCaseReport; import io.metersphere.base.domain.TestCaseReport;
import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.request.testCaseReport.CreateReportRequest; import io.metersphere.track.request.testCaseReport.CreateReportRequest;
import io.metersphere.track.service.TestCaseReportService; import io.metersphere.track.service.TestCaseReportService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -32,7 +29,6 @@ public class TestCaseReportController {
} }
@PostMapping("/add") @PostMapping("/add")
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseReportService.class) @MsAuditLog(module = "track_test_plan", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseReportService.class)
public String addByTemplateId(@RequestBody CreateReportRequest request) { public String addByTemplateId(@RequestBody CreateReportRequest request) {
request.setId(UUID.randomUUID().toString()); request.setId(UUID.randomUUID().toString());
@ -40,14 +36,12 @@ public class TestCaseReportController {
} }
@PostMapping("/edit") @PostMapping("/edit")
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#TestCaseReport.id)", content = "#msClass.getLogDetails(#TestCaseReport.id)", msClass = TestCaseReportService.class) @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#TestCaseReport.id)", content = "#msClass.getLogDetails(#TestCaseReport.id)", msClass = TestCaseReportService.class)
public void edit(@RequestBody TestCaseReport TestCaseReport) { public void edit(@RequestBody TestCaseReport TestCaseReport) {
testCaseReportService.editTestCaseReport(TestCaseReport); testCaseReportService.editTestCaseReport(TestCaseReport);
} }
@PostMapping("/delete/{id}") @PostMapping("/delete/{id}")
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestCaseReportService.class) @MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestCaseReportService.class)
public int delete(@PathVariable String id) { public int delete(@PathVariable String id) {
return testCaseReportService.deleteTestCaseReport(id); return testCaseReportService.deleteTestCaseReport(id);

View File

@ -5,15 +5,13 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.definition.ApiTestCaseDTO; import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO; import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest; import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import io.metersphere.track.request.testreview.TestReviewApiCaseBatchRequest; import io.metersphere.track.request.testreview.TestReviewApiCaseBatchRequest;
import io.metersphere.track.service.TestCaseReviewApiCaseService; import io.metersphere.track.service.TestCaseReviewApiCaseService;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -24,12 +22,15 @@ import java.util.List;
public class TestCaseReviewApiCaseController { public class TestCaseReviewApiCaseController {
@Resource @Resource
private TestCaseReviewApiCaseService testCaseReviewApiCaseService; private TestCaseReviewApiCaseService testCaseReviewApiCaseService;
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<TestPlanApiCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) { public Pager<List<TestPlanApiCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseReviewApiCaseService.list(request)); return PageUtils.setPageInfo(page, testCaseReviewApiCaseService.list(request));
} }
@PostMapping("/relevance/list/{goPage}/{pageSize}") @PostMapping("/relevance/list/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL")
public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) { public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
@ -37,19 +38,19 @@ public class TestCaseReviewApiCaseController {
} }
@GetMapping("/delete/{id}") @GetMapping("/delete/{id}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL")
public int deleteTestCase(@PathVariable String id) { public int deleteTestCase(@PathVariable String id) {
return testCaseReviewApiCaseService.delete(id); return testCaseReviewApiCaseService.delete(id);
} }
@PostMapping("/batch/delete") @PostMapping("/batch/delete")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL")
public void deleteApiCaseBath(@RequestBody TestReviewApiCaseBatchRequest request) { public void deleteApiCaseBath(@RequestBody TestReviewApiCaseBatchRequest request) {
testCaseReviewApiCaseService.deleteApiCaseBath(request); testCaseReviewApiCaseService.deleteApiCaseBath(request);
} }
@PostMapping("/batch/update/env") @PostMapping("/batch/update/env")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+RELEVANCE_OR_CANCEL")
public void batchUpdateEnv(@RequestBody TestPlanApiCaseBatchRequest request) { public void batchUpdateEnv(@RequestBody TestPlanApiCaseBatchRequest request) {
testCaseReviewApiCaseService.batchUpdateEnv(request); testCaseReviewApiCaseService.batchUpdateEnv(request);
} }

View File

@ -21,6 +21,7 @@ import io.metersphere.track.request.testreview.TestReviewRelevanceRequest;
import io.metersphere.track.service.TestCaseReviewService; import io.metersphere.track.service.TestCaseReviewService;
import io.metersphere.track.service.TestReviewProjectService; import io.metersphere.track.service.TestReviewProjectService;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -47,7 +48,7 @@ public class TestCaseReviewController {
} }
@PostMapping("/save") @PostMapping("/save")
@RequiresPermissions("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) @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) { public String saveCaseReview(@RequestBody SaveTestCaseReviewRequest reviewRequest) {
reviewRequest.setId(UUID.randomUUID().toString()); reviewRequest.setId(UUID.randomUUID().toString());
@ -72,14 +73,14 @@ public class TestCaseReviewController {
} }
@PostMapping("/edit") @PostMapping("/edit")
@RequiresPermissions("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) @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) { public String editCaseReview(@RequestBody SaveTestCaseReviewRequest testCaseReview) {
return testCaseReviewService.editCaseReview(testCaseReview); return testCaseReviewService.editCaseReview(testCaseReview);
} }
@GetMapping("/delete/{reviewId}") @GetMapping("/delete/{reviewId}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+DELETE")
@MsAuditLog(module = "track_test_case_review", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#reviewId)", msClass = TestCaseReviewService.class) @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#reviewId)", msClass = TestCaseReviewService.class)
public void deleteCaseReview(@PathVariable String reviewId) { public void deleteCaseReview(@PathVariable String reviewId) {
checkPermissionService.checkTestReviewOwner(reviewId); checkPermissionService.checkTestReviewOwner(reviewId);
@ -120,7 +121,7 @@ public class TestCaseReviewController {
} }
@PostMapping("/edit/status/{reviewId}") @PostMapping("/edit/status/{reviewId}")
@RequiresPermissions("PROJECT_TRACK_REVIEW:READ+EDIT")
public void editTestPlanStatus(@PathVariable String reviewId) { public void editTestPlanStatus(@PathVariable String reviewId) {
checkPermissionService.checkTestReviewOwner(reviewId); checkPermissionService.checkTestReviewOwner(reviewId);
testCaseReviewService.editTestReviewStatus(reviewId); testCaseReviewService.editTestReviewStatus(reviewId);

View File

@ -13,6 +13,7 @@ import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest; import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import io.metersphere.track.service.TestPlanApiCaseService; import io.metersphere.track.service.TestPlanApiCaseService;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -44,21 +45,21 @@ public class TestPlanApiCaseController {
} }
@GetMapping("/delete/{id}") @GetMapping("/delete/{id}")
@RequiresPermissions("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) @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanApiCaseService.class)
public int deleteTestCase(@PathVariable String id) { public int deleteTestCase(@PathVariable String id) {
return testPlanApiCaseService.delete(id); return testPlanApiCaseService.delete(id);
} }
@PostMapping("/batch/delete") @PostMapping("/batch/delete")
@RequiresPermissions("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) @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanApiCaseService.class)
public void deleteApiCaseBath(@RequestBody TestPlanApiCaseBatchRequest request) { public void deleteApiCaseBath(@RequestBody TestPlanApiCaseBatchRequest request) {
testPlanApiCaseService.deleteApiCaseBath(request); testPlanApiCaseService.deleteApiCaseBath(request);
} }
@PostMapping("/batch/update/env") @PostMapping("/batch/update/env")
@RequiresPermissions("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) @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) { public void batchUpdateEnv(@RequestBody TestPlanApiCaseBatchRequest request) {
testPlanApiCaseService.batchUpdateEnv(request); testPlanApiCaseService.batchUpdateEnv(request);

View File

@ -22,6 +22,7 @@ import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest;
import io.metersphere.track.service.TestPlanProjectService; import io.metersphere.track.service.TestPlanProjectService;
import io.metersphere.track.service.TestPlanService; import io.metersphere.track.service.TestPlanService;
import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -46,6 +47,7 @@ public class TestPlanController {
} }
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ")
public Pager<List<TestPlanDTOWithMetric>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) { public Pager<List<TestPlanDTOWithMetric>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
request.setWorkspaceId(currentWorkspaceId); request.setWorkspaceId(currentWorkspaceId);
@ -86,7 +88,7 @@ public class TestPlanController {
} }
@PostMapping("/add") @PostMapping("/add")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+CREATE")
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.CREATE, title = "#testPlan.name", content = "#msClass.getLogDetails(#testPlan.id)", msClass = TestPlanService.class) @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) { public String addTestPlan(@RequestBody AddTestPlanRequest testPlan) {
testPlan.setId(UUID.randomUUID().toString()); testPlan.setId(UUID.randomUUID().toString());
@ -95,14 +97,14 @@ public class TestPlanController {
} }
@PostMapping("/edit") @PostMapping("/edit")
@RequiresPermissions("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) @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) { public String editTestPlan(@RequestBody TestPlanDTO testPlanDTO) {
return testPlanService.editTestPlan(testPlanDTO, true); return testPlanService.editTestPlan(testPlanDTO, true);
} }
@PostMapping("/edit/status/{planId}") @PostMapping("/edit/status/{planId}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+EDIT")
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#planId)", content = "#msClass.getLogDetails(#planId)", msClass = TestPlanService.class) @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) { public void editTestPlanStatus(@PathVariable String planId) {
checkPermissionService.checkTestPlanOwner(planId); checkPermissionService.checkTestPlanOwner(planId);
@ -110,7 +112,7 @@ public class TestPlanController {
} }
@PostMapping("/delete/{testPlanId}") @PostMapping("/delete/{testPlanId}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ+DELETE")
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanId)", msClass = TestPlanService.class) @MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanId)", msClass = TestPlanService.class)
public int deleteTestPlan(@PathVariable String testPlanId) { public int deleteTestPlan(@PathVariable String testPlanId) {
checkPermissionService.checkTestPlanOwner(testPlanId); checkPermissionService.checkTestPlanOwner(testPlanId);

View File

@ -16,19 +16,21 @@
</div> </div>
<div> <div>
<el-input <el-input
ref="test" ref="test"
type="textarea" type="textarea"
:placeholder="$t('test_track.comment.send_comment')" :placeholder="$t('test_track.comment.send_comment')"
v-model.trim="textarea" v-model.trim="textarea"
maxlength="180" maxlength="180"
show-word-limt show-word-limt
resize="none" resize="none"
:autosize="{ minRows: 4, maxRows: 4}" :autosize="{ minRows: 4, maxRows: 4}"
@keyup.ctrl.enter.native="sendComment" @keyup.ctrl.enter.native="sendComment"
:disabled="isReadOnly" :disabled="isReadOnly"
> >
</el-input> </el-input>
<el-button type="primary" size="mini" class="send-btn" @click="sendComment" :disabled="isReadOnly"> <el-button type="primary" size="mini" class="send-btn"
v-permission="['PROJECT_TRACK_REVIEW:READ+COMMENT']"
@click="sendComment" :disabled="isReadOnly">
{{ $t('test_track.comment.send') }} {{ $t('test_track.comment.send') }}
</el-button> </el-button>
</div> </div>
@ -53,7 +55,7 @@ export default {
result: {}, result: {},
textarea: '', textarea: '',
isReadOnly: false isReadOnly: false
} };
}, },
created() { created() {
this.isReadOnly = !checkoutTestManagerOrTestUser(); this.isReadOnly = !checkoutTestManagerOrTestUser();
@ -63,7 +65,7 @@ export default {
let comment = {}; let comment = {};
comment.caseId = this.caseId; comment.caseId = this.caseId;
comment.description = this.textarea; comment.description = this.textarea;
comment.reviewId=this.reviewId; comment.reviewId = this.reviewId;
if (!this.textarea) { if (!this.textarea) {
this.$warning(this.$t('test_track.comment.description_is_null')); this.$warning(this.$t('test_track.comment.description_is_null'));
return; return;
@ -81,7 +83,7 @@ export default {
this.$emit('getComments'); this.$emit('getComments');
}, },
} }
} };
</script> </script>
<style scoped> <style scoped>