refactor(测试跟踪): 补充测试跟踪接口权限校验

This commit is contained in:
chenjianxing 2023-06-12 16:28:54 +08:00 committed by fit2-zhao
parent 21db088955
commit cb4b47b59d
26 changed files with 266 additions and 320 deletions

View File

@ -187,20 +187,13 @@
test_case.delete_user_id ,test_case.delete_time,
project_version.name as versionName,
project_version.id as versionId,
<if test="request.selectFields != null and request.selectFields.size() > 0">
<foreach collection="request.selectFields" item="field" separator=",">
${field}
</foreach>
</if>
<if test="request.selectFields == null or request.selectFields.size() == 0">
test_case.id, test_case.node_id, test_case.node_path, test_case.project_id, test_case.`name`,
test_case.`type`, test_case.maintainer, test_case.priority, test_case.`method`,
test_case.create_time, test_case.update_time, test_case.test_id, test_case.sort, test_case.num,
test_case.other_test_name, test_case.review_status, test_case.tags,
test_case.demand_id, test_case.demand_name, test_case.`status`,
test_case.custom_num, test_case.step_model, test_case.create_user,
test_case.custom_fields, test_case.ref_id
</if>
test_case.id, test_case.node_id, test_case.node_path, test_case.project_id, test_case.`name`,
test_case.`type`, test_case.maintainer, test_case.priority, test_case.`method`,
test_case.create_time, test_case.update_time, test_case.test_id, test_case.sort, test_case.num,
test_case.other_test_name, test_case.review_status, test_case.tags,
test_case.demand_id, test_case.demand_name, test_case.`status`,
test_case.custom_num, test_case.step_model, test_case.create_user,
test_case.custom_fields, test_case.ref_id
from test_case
left join project_version on project_version.id = test_case.version_id
<include refid="queryWhereCondition"/>
@ -211,21 +204,14 @@
select
project_version.name as versionName,
project_version.id as versionId,
<if test="request.selectFields != null and request.selectFields.size() > 0">
<foreach collection="request.selectFields" item="field" separator=",">
${field}
</foreach>
</if>
<if test="request.selectFields == null or request.selectFields.size() == 0">
test_case.id, test_case.node_id, test_case.node_path, test_case.project_id, test_case.`name`,
test_case.`type`, test_case.maintainer, test_case.priority, test_case.`method`,
test_case.create_time, test_case.update_time, test_case.test_id, test_case.sort, test_case.num,
test_case.other_test_name, test_case.review_status, test_case.tags,
test_case.demand_id, test_case.demand_name, test_case.`status`,
test_case.custom_num, test_case.step_model, test_case.create_user,u.name as createName,
test_case.custom_fields,test_case.case_public ,
project.workspace_id , project.name as projectName ,test_case.ref_id ,test_case.`order`
</if>
test_case.id, test_case.node_id, test_case.node_path, test_case.project_id, test_case.`name`,
test_case.`type`, test_case.maintainer, test_case.priority, test_case.`method`,
test_case.create_time, test_case.update_time, test_case.test_id, test_case.sort, test_case.num,
test_case.other_test_name, test_case.review_status, test_case.tags,
test_case.demand_id, test_case.demand_name, test_case.`status`,
test_case.custom_num, test_case.step_model, test_case.create_user,u.name as createName,
test_case.custom_fields,test_case.case_public ,
project.workspace_id , project.name as projectName ,test_case.ref_id ,test_case.`order`
from test_case left join user u on test_case.create_user=u.id
left join (select id,workspace_id,NAME from project where workspace_id =#{request.workspaceId})
project on test_case.project_id = project.id

View File

@ -96,6 +96,7 @@ public class PermissionConstants {
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_CASE_READ_BATCH_ADD_PUBLIC = "PROJECT_TRACK_CASE:READ+BATCH_ADD_PUBLIC";
public static final String PROJECT_TRACK_REVIEW_READ = "PROJECT_TRACK_REVIEW:READ";
public static final String PROJECT_TRACK_REVIEW_READ_CREATE = "PROJECT_TRACK_REVIEW:READ+CREATE";

View File

@ -5,11 +5,13 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.CustomField;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.QueryCustomFieldRequest;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.CustomFieldService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -24,45 +26,53 @@ public class CustomFieldController {
private CustomFieldService customFieldService;
@PostMapping("/add")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_FIELD, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#customField.id)", msClass = CustomFieldService.class)
public String add(@RequestBody CustomField customField) {
return customFieldService.add(customField);
}
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
public Pager<List<CustomField>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryCustomFieldRequest request) {
Page<List<CustomField>> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, customFieldService.list(request));
}
@PostMapping("/list/relate/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
public Pager<List<CustomField>> listRelate(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryCustomFieldRequest request) {
return customFieldService.listRelate(goPage, pageSize, request);
}
@GetMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_FIELD, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = CustomFieldService.class)
public void delete(@PathVariable(value = "id") String id) {
customFieldService.delete(id);
}
@PostMapping("/update")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_FIELD, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#customField.id)", content = "#msClass.getLogDetails(#customField.id)", msClass = CustomFieldService.class)
public void update(@RequestBody CustomField customField) {
customFieldService.update(customField);
}
@PostMapping("/list/ids")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
public List<String> list(@RequestBody QueryCustomFieldRequest request) {
return customFieldService.listIds(request);
}
@PostMapping("/list")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
public List<CustomField> getList(@RequestBody QueryCustomFieldRequest request) {
return customFieldService.list(request);
}
@PostMapping("/default")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
public List<CustomField> getDefaultList(@RequestBody QueryCustomFieldRequest request) {
return customFieldService.getDefaultField(request);
}

View File

@ -2,8 +2,10 @@ package io.metersphere.controller;
import io.metersphere.base.domain.CustomField;
import io.metersphere.base.domain.CustomFieldTemplate;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.dto.CustomFieldTemplateDao;
import io.metersphere.service.CustomFieldTemplateService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -17,16 +19,19 @@ public class CustomFieldTemplateController {
CustomFieldTemplateService customFieldTemplateService;
@PostMapping("/list")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
public List<CustomFieldTemplateDao> list(@RequestBody CustomFieldTemplate request) {
return customFieldTemplateService.list(request);
}
@PostMapping("/update")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
public void update(@RequestBody CustomFieldTemplate request) {
customFieldTemplateService.update(request);
}
@GetMapping("/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM)
public CustomField get(@PathVariable String id) {
return customFieldTemplateService.getCustomField(id);
}

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.IssueTemplate;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.BaseQueryRequest;
@ -12,6 +13,8 @@ import io.metersphere.controller.request.UpdateIssueTemplateRequest;
import io.metersphere.dto.IssueTemplateDao;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.IssueTemplateService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -25,35 +28,42 @@ public class IssueTemplateController {
private IssueTemplateService issueTemplateService;
@PostMapping("/add")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_ISSUE_TEMPLATE)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_ISSUE, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request)", msClass = IssueTemplateService.class)
public void add(@RequestBody UpdateIssueTemplateRequest request) {
issueTemplateService.add(request);
}
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_ISSUE_TEMPLATE)
public Pager<List<IssueTemplate>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody BaseQueryRequest request) {
Page<List<IssueTemplate>> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, issueTemplateService.list(request));
}
@GetMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_ISSUE_TEMPLATE)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_ISSUE, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = IssueTemplateService.class)
public void delete(@PathVariable(value = "id") String id) {
issueTemplateService.delete(id);
}
@PostMapping("/update")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_ISSUE_TEMPLATE)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_ISSUE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id,#request.customFields)", content = "#msClass.getLogDetails(#request)", msClass = IssueTemplateService.class)
public void update(@RequestBody UpdateIssueTemplateRequest request) {
issueTemplateService.update(request);
}
@GetMapping({"/option/{projectId}", "/option"})
@RequiresPermissions(value = {PermissionConstants.PROJECT_TEMPLATE_READ_ISSUE_TEMPLATE,
PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ_CREATE, PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ_EDIT}, logical = Logical.OR)
public List<IssueTemplate> list(@PathVariable(required = false) String projectId) {
return issueTemplateService.getOption(projectId);
}
@GetMapping("/get/relate/{projectId}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TEMPLATE_READ_ISSUE_TEMPLATE, PermissionConstants.PROJECT_TRACK_ISSUE_READ}, logical = Logical.OR)
public IssueTemplateDao getTemplate(@PathVariable String projectId) {
return issueTemplateService.getTemplate(projectId);
}

View File

@ -6,6 +6,7 @@ import io.metersphere.base.domain.TestCaseTemplate;
import io.metersphere.base.domain.TestCaseTemplateWithBLOBs;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.BaseQueryRequest;
@ -13,6 +14,8 @@ import io.metersphere.controller.request.UpdateCaseFieldTemplateRequest;
import io.metersphere.dto.TestCaseTemplateDao;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.TestCaseTemplateService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -27,35 +30,42 @@ public class TestCaseTemplateController {
private TestCaseTemplateService testCaseTemplateService;
@PostMapping("/add")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CASE_TEMPLATE)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_CASE, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseTemplateService.class)
public void add(@RequestBody UpdateCaseFieldTemplateRequest request) {
testCaseTemplateService.add(request);
}
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CASE_TEMPLATE)
public Pager<List<TestCaseTemplateWithBLOBs>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody BaseQueryRequest request) {
Page<List<TestCaseTemplateWithBLOBs>> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseTemplateService.list(request));
}
@GetMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CASE_TEMPLATE)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_CASE, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestCaseTemplateService.class)
public void delete(@PathVariable(value = "id") String id) {
testCaseTemplateService.delete(id);
}
@PostMapping("/update")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CASE_TEMPLATE)
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_CASE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseTemplateService.class)
public void update(@RequestBody UpdateCaseFieldTemplateRequest request) {
testCaseTemplateService.update(request);
}
@GetMapping({"/option/{projectId}", "/option"})
@RequiresPermissions(value = {PermissionConstants.PROJECT_TEMPLATE_READ_CASE_TEMPLATE,
PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ_CREATE, PermissionConstants.WORKSPACE_PROJECT_MANAGER_READ_EDIT}, logical = Logical.OR)
public List<TestCaseTemplate> list(@PathVariable(required = false) String projectId) {
return testCaseTemplateService.getOption(projectId);
}
@GetMapping("/get/relate/{projectId}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TEMPLATE_READ_CASE_TEMPLATE, PermissionConstants.PROJECT_TRACK_CASE_READ}, logical = Logical.OR)
public TestCaseTemplateDao getTemplate(@PathVariable String projectId) {
return testCaseTemplateService.getTemplate(projectId);
}

View File

@ -67,11 +67,6 @@ public class BaseQueryRequest {
*/
private Map<String, Object> combine;
/**
* 要查询的字段
*/
private List<String> selectFields;
/**
* 版本 ID
*/

View File

@ -28,7 +28,7 @@ public class IssueCommentController {
private IssueCommentService issueCommentService;
@PostMapping("/save")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT)
@SendNotice(taskType = NoticeConstants.TaskType.DEFECT_TASK, target = "#targetClass.get(#request.issuesId)", targetClass = IssuesService.class,
event = NoticeConstants.Event.COMMENT, subject = "缺陷")
public IssueComment saveComment(@RequestBody IssuesRelevanceRequest request) {
@ -37,19 +37,20 @@ public class IssueCommentController {
}
@GetMapping("/list/{issueId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<IssueCommentDTO> getComments(@PathVariable String issueId) {
return issueCommentService.getComments(issueId);
}
@GetMapping("/delete/{commentId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT)
@MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#commentId)", msClass = TestCaseCommentService.class)
public void deleteComment(@PathVariable String commentId) {
issueCommentService.delete(commentId);
}
@PostMapping("/edit")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_COMMENT)
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT)
@MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseCommentService.class)
public IssueComment editComment(@RequestBody SaveIssueCommentRequest request) {
return issueCommentService.edit(request);

View File

@ -100,21 +100,25 @@ public class IssuesController {
}
@PostMapping("/user/auth")
@RequiresPermissions(PermissionConstants.WORKSPACE_SERVICE_READ)
public void userAuth(@RequestBody AuthUserIssueRequest authUserIssueRequest) {
issuesService.userAuth(authUserIssueRequest);
}
@GetMapping("/close/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT)
public void closeLocalIssue(@PathVariable String id) {
issuesService.closeLocalIssue(id);
}
@PostMapping("/delete/relate")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public void deleteRelate(@RequestBody IssuesRequest request) {
issuesService.deleteIssueRelate(request);
}
@GetMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_DELETE)
@MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = IssuesService.class)
@SendNotice(taskType = NoticeConstants.TaskType.DEFECT_TASK, target = "#targetClass.get(#id)", targetClass = IssuesService.class, event = NoticeConstants.Event.DELETE, subject = "缺陷通知")
public void delete(@PathVariable String id) {
@ -122,66 +126,79 @@ public class IssuesController {
}
@PostMapping("/tapd/user")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<PlatformUser> getTapdUsers(@RequestBody IssuesRequest request) {
return issuesService.getTapdProjectUsers(request);
}
@PostMapping("/zentao/user")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<PlatformUser> getZentaoUsers(@RequestBody IssuesRequest request) {
return issuesService.getZentaoUsers(request);
}
@PostMapping("/zentao/builds")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<ZentaoBuild> getZentaoBuilds(@RequestBody IssuesRequest request) {
return issuesService.getZentaoBuilds(request);
}
@GetMapping("/sync/{projectId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT)
public boolean getPlatformIssue(@PathVariable String projectId) {
return issuesService.syncThirdPartyIssues(projectId);
}
@GetMapping("/sync/check/{projectId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public boolean checkSync(@PathVariable String projectId) {
return issuesService.checkSync(projectId);
}
@PostMapping("/change/status")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT)
public void changeStatus(@RequestBody IssuesRequest request) {
issuesService.changeStatus(request);
}
@PostMapping("/status/count")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<IssuesStatusCountDao> getCountByStatus(@RequestBody IssuesRequest request) {
return issuesService.getCountByStatus(request);
}
@GetMapping("/follow/{issueId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<String> getFollows(@PathVariable String issueId) {
return issuesService.getFollows(issueId);
}
@PostMapping("/up/follows/{issueId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public void saveFollows(@PathVariable String issueId, @RequestBody List<String> follows) {
issuesService.saveFollows(issueId, follows);
}
@GetMapping("/thirdpart/template/{projectId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public IssueTemplateDao getThirdPartTemplate(@PathVariable String projectId) {
return issuesService.getThirdPartTemplate(projectId);
}
@PostMapping("/jira/issuetype")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<JiraIssueType> getJiraIssueType(@RequestBody JiraIssueTypeRequest request) {
return issuesService.getIssueTypes(request);
}
@GetMapping("/demand/list/{projectId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<DemandDTO> getDemandList(@PathVariable String projectId) {
return issuesService.getDemandList(projectId);
}
@PostMapping("/platform/transitions")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<PlatformStatusDTO> getPlatformTransitions(@RequestBody PlatformIssueTypeRequest request) {
return issuesService.getPlatformTransitions(request);
}

View File

@ -11,6 +11,7 @@ import io.metersphere.track.dto.TestCaseCommentDTO;
import io.metersphere.track.request.testreview.SaveCommentRequest;
import io.metersphere.track.service.TestCaseCommentService;
import io.metersphere.track.service.TestCaseService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
@ -36,6 +37,8 @@ public class TestCaseCommentController {
}
@GetMapping("/list/{caseId}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ,
PermissionConstants.PROJECT_TRACK_REVIEW_READ, PermissionConstants.PROJECT_TRACK_PLAN_READ}, logical = Logical.OR)
public List<TestCaseCommentDTO> getCaseComments(@PathVariable String caseId) {
return testCaseCommentService.getCaseComments(caseId);
}

View File

@ -76,12 +76,13 @@ public class TestCaseController {
@PostMapping("/public/case/node")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<TestCaseNodeDTO> getPublicCaseNode(@RequestBody QueryTestCaseRequest request) {
return testCaseService.getPublicCaseNode(request);
}
@GetMapping("/list/{projectId}")
@RequiresPermissions("PROJECT_TRACK_CASE:READ")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<TestCaseDTO> list(@PathVariable String projectId) {
checkPermissionService.checkProjectOwner(projectId);
QueryTestCaseRequest request = new QueryTestCaseRequest();
@ -90,19 +91,21 @@ public class TestCaseController {
}
@PostMapping("/list")
@RequiresPermissions("PROJECT_TRACK_CASE:READ")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<TestCaseDTO> list(@RequestBody QueryTestCaseRequest request) {
checkPermissionService.checkProjectOwner(request.getProjectId());
return testCaseService.listTestCase(request);
}
@PostMapping("/list/minder")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<TestCaseDTO> listForMinder(@RequestBody QueryTestCaseRequest request) {
checkPermissionService.checkProjectOwner(request.getProjectId());
return testCaseService.listTestCaseForMinder(request);
}
@PostMapping("/list/minder/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public Pager<List<TestCaseDTO>> listForMinder(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
checkPermissionService.checkProjectOwner(request.getProjectId());
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
@ -111,6 +114,7 @@ public class TestCaseController {
/*jenkins项目下所有接口和性能测试用例*/
@GetMapping("/list/method/{projectId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<TestCaseDTO> listByMethod(@PathVariable String projectId) {
QueryTestCaseRequest request = new QueryTestCaseRequest();
request.setProjectId(projectId);
@ -118,21 +122,25 @@ public class TestCaseController {
}
@GetMapping("/relationship/case/{id}/{relationshipType}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<RelationshipEdgeDTO> getRelationshipCase(@PathVariable("id") String id, @PathVariable("relationshipType") String relationshipType) {
return testCaseService.getRelationshipCase(id, relationshipType);
}
@PostMapping("/relationship/add")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
public void saveRelationshipBatch(@RequestBody TestCaseRelationshipEdgeRequest request) {
testCaseService.saveRelationshipBatch(request);
}
@GetMapping("/relationship/case/count/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public int getRelationshipCase(@PathVariable("id") String id) {
return testCaseService.getRelationshipCount(id);
}
@GetMapping("recent/{count}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<TestCase> recentTestPlans(@PathVariable int count) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
QueryTestCaseRequest request = new QueryTestCaseRequest();
@ -142,71 +150,84 @@ public class TestCaseController {
}
@PostMapping("/relate/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public Pager<List<TestCaseDTO>> getTestCaseRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
return testCaseService.getTestCaseRelateList(request, goPage, pageSize);
}
@PostMapping("/relationship/relate/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public Pager<List<TestCaseDTO>> getRelationshipRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
return testCaseService.getRelationshipRelateList(request, goPage, pageSize);
}
@PostMapping("/relate/issue/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public Pager<List<TestCaseDTO>> getTestCaseIssueRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.getTestCaseIssueRelateList(request));
}
@PostMapping("/relevance/api/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ)
public Pager<List<ApiTestCaseDTO>> getTestCaseApiCaseRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.getTestCaseApiCaseRelateList(request));
}
@PostMapping("/relevance/scenario/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ)
public Pager<List<ApiScenarioDTO>> getTestCaseScenarioCaseRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.getTestCaseScenarioCaseRelateList(request));
}
@PostMapping("/relevance/load/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ)
public Pager<List<LoadTestDTO>> getTestCaseLoadCaseRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody LoadCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.getTestCaseLoadCaseRelateList(request));
}
@GetMapping("/relate/test/list/{caseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<TestCaseTestDao> getRelateTest(@PathVariable String caseId) {
return testCaseService.getRelateTest(caseId);
}
@PostMapping("/relate/test/{type}/{caseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
public void relateTest(@PathVariable String type, @PathVariable String caseId, @RequestBody List<String> apiIds) {
testCaseService.relateTest(type, caseId, apiIds);
}
@GetMapping("/relate/delete/{caseId}/{testId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
public void relateDelete(@PathVariable String caseId, @PathVariable String testId) {
testCaseService.relateDelete(caseId, testId);
}
@PostMapping("/reviews/case/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public Pager<List<TestCaseDTO>> getReviewCase(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.getReviewCase(request));
}
@GetMapping("/get/{testCaseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public TestCaseWithBLOBs getTestCase(@PathVariable String testCaseId) {
return testCaseService.getTestCase(testCaseId);
}
@GetMapping("/get/step/{testCaseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public TestCaseWithBLOBs getTestCaseStep(@PathVariable String testCaseId) {
return testCaseService.getTestCaseStep(testCaseId);
}
@GetMapping("/project/{testCaseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public Project getProjectByTestCaseId(@PathVariable String testCaseId) {
checkPermissionService.checkTestCaseOwner(testCaseId);
return testCaseService.getProjectByTestCaseId(testCaseId);
@ -228,12 +249,14 @@ public class TestCaseController {
}
@PostMapping("/edit/order")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
public void orderCase(@RequestBody ResetOrderRequest request) {
checkPermissionService.checkTestCaseOwner(request.getMoveId());
testCaseService.updateOrder(request);
}
@PostMapping(value = "/edit", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, target = "#targetClass.getTestCase(#request.id)", targetClass = TestCaseService.class,
event = NoticeConstants.Event.UPDATE, subject = "测试用例通知")
@ -242,12 +265,14 @@ public class TestCaseController {
}
@PostMapping(value = "/edit/testPlan", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogBeforeDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class)
public String editTestCaseByTestPlan(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
return testCaseService.editTestCase(request, files, Boolean.TRUE);
}
@PostMapping("/delete/{testCaseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testCaseId)", msClass = TestCaseService.class)
public int deleteTestCase(@PathVariable String testCaseId) {
checkPermissionService.checkTestCaseOwner(testCaseId);
@ -255,6 +280,7 @@ public class TestCaseController {
}
@PostMapping("/deleteToGc/{testCaseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.GC, beforeEvent = "#msClass.getLogDetails(#testCaseId)", msClass = TestCaseService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getTestCase(#testCaseId)", targetClass = TestCaseService.class,
subject = "测试用例通知")
@ -264,6 +290,7 @@ public class TestCaseController {
}
@GetMapping("/deletePublic/{versionId}/{refId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_BATCH_ADD_PUBLIC)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.GC, beforeEvent = "#msClass.getLogDetails(#testCaseId)", msClass = TestCaseService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getTestCase(#testCaseId)", targetClass = TestCaseService.class,
subject = "测试用例通知")
@ -273,6 +300,7 @@ public class TestCaseController {
@PostMapping("/import")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_IMPORT)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.IMPORT, project = "#request.projectId")
public ExcelResponse testCaseImport(@RequestPart("request") TestCaseImportRequest request, @RequestPart("file") MultipartFile file, HttpServletRequest httpRequest) {
checkPermissionService.checkProjectOwner(request.getProjectId());
@ -357,6 +385,7 @@ public class TestCaseController {
}
@PostMapping("/reduction")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.RESTORE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class)
public void reduction(@RequestBody TestCaseBatchRequest request) {
testCaseService.reduction(request);
@ -364,11 +393,13 @@ public class TestCaseController {
@GetMapping("/file/metadata/{caseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<FileMetadata> getFileMetadata(@PathVariable String caseId) {
return fileService.getFileMetadataByCaseId(caseId);
}
@PostMapping("/file/download")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public ResponseEntity<byte[]> download(@RequestBody FileOperationRequest fileOperationRequest) {
byte[] bytes = fileService.loadFileAsBytes(fileOperationRequest.getId());
return ResponseEntity.ok()
@ -378,6 +409,7 @@ public class TestCaseController {
}
@GetMapping("/file/preview/{fileId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public ResponseEntity<byte[]> preview(@PathVariable String fileId) {
byte[] bytes = fileService.loadFileAsBytes(fileId);
return ResponseEntity.ok()
@ -387,6 +419,7 @@ public class TestCaseController {
}
@PostMapping("/save")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_CREATE)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.CREATE, title = "#testCaseWithBLOBs.name", content = "#msClass.getLogDetails(#testCaseWithBLOBs.id)", msClass = TestCaseService.class)
public TestCaseWithBLOBs saveTestCase(@RequestBody EditTestCaseRequest request) {
request.setId(UUID.randomUUID().toString());
@ -401,6 +434,7 @@ public class TestCaseController {
}
@GetMapping("/follow/{caseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<String> getFollows(@PathVariable String caseId) {
return testCaseService.getFollows(caseId);
}
@ -412,17 +446,20 @@ public class TestCaseController {
}
@GetMapping("versions/{caseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public List<TestCaseDTO> getTestCaseVersions(@PathVariable String caseId) {
return testCaseService.getTestCaseVersions(caseId);
}
@GetMapping("get/{version}/{refId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public TestCaseDTO getTestCase(@PathVariable String version, @PathVariable String refId) {
return testCaseService.getTestCaseByVersion(refId, version);
}
@GetMapping("delete/{version}/{refId}")
public void deleteApiDefinition(@PathVariable String version, @PathVariable String refId) {
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_DELETE)
public void deleteTestCaseByVersion(@PathVariable String version, @PathVariable String refId) {
testCaseService.deleteTestCaseByVersion(refId, version);
}
@ -433,6 +470,7 @@ public class TestCaseController {
* @return
*/
@GetMapping("hasOtherInfo/{caseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ)
public Boolean hasOtherInfo(@PathVariable String caseId) {
return testCaseService.hasOtherInfo(caseId);
}

View File

@ -2,10 +2,13 @@ package io.metersphere.track.controller;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.dto.TestCaseDTO;
import io.metersphere.track.request.issues.IssuesRelevanceRequest;
import io.metersphere.track.service.TestCaseIssueService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -22,11 +25,13 @@ public class TestCaseIssuesController {
private TestCaseIssueService testCaseIssueService;
@PostMapping("/list")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ, PermissionConstants.PROJECT_TRACK_ISSUE_READ}, logical = Logical.OR)
public List<TestCaseDTO> list(@RequestBody IssuesRelevanceRequest request) {
return testCaseIssueService.list(request);
}
@PostMapping("/relate")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ, PermissionConstants.PROJECT_TRACK_ISSUE_READ}, logical = Logical.OR)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.ASSOCIATE_ISSUE, content = "#msClass.getLogDetails(#request)", msClass = TestCaseIssueService.class)
public void relate(@RequestBody IssuesRelevanceRequest request) {
testCaseIssueService.relate(request);

View File

@ -3,6 +3,7 @@ package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCaseNode;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.CheckPermissionService;
import io.metersphere.track.dto.TestCaseNodeDTO;
@ -10,6 +11,7 @@ import io.metersphere.track.request.testcase.DragNodeRequest;
import io.metersphere.track.request.testcase.QueryNodeRequest;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.track.service.TestCaseNodeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -26,51 +28,60 @@ public class TestCaseNodeController {
private CheckPermissionService checkPermissionService;
@GetMapping("/list/{projectId}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public List<TestCaseNodeDTO> getNodeByProjectId(@PathVariable String projectId) {
checkPermissionService.checkProjectOwner(projectId);
return testCaseNodeService.getNodeTreeByProjectId(projectId);
}
@PostMapping("/minder/extraNode/count")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public Map<String, Integer> getMinderTreeExtraNodeCount(@RequestBody List<String> nodeIds) {
return testCaseNodeService.getMinderTreeExtraNodeCount(nodeIds);
}
@GetMapping("/trashCount/{projectId}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public long trashCount(@PathVariable String projectId) {
checkPermissionService.checkProjectOwner(projectId);
return testCaseNodeService.trashCount(projectId);
}
@GetMapping("/publicCount/{workSpaceId}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public long publicCount(@PathVariable String workSpaceId) {
return testCaseNodeService.publicCount(workSpaceId);
}
/*模块列表列表*/
@PostMapping("/list/all/plan")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public List<TestCaseNodeDTO> getAllNodeByPlanId(@RequestBody QueryNodeRequest request) {
return testCaseNodeService.getAllNodeByPlanId(request);
}
/*模块列表列表*/
@PostMapping("/list/project")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public List<TestCaseNodeDTO> getAllNodeByProjectId(@RequestBody QueryNodeRequest request) {
return testCaseNodeService.getAllNodeByProjectId(request);
}
@PostMapping("/list/all/review")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public List<TestCaseNodeDTO> getAllNodeByReviewId(@RequestBody QueryNodeRequest request) {
return testCaseNodeService.getAllNodeByReviewId(request);
}
@GetMapping("/list/plan/{planId}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public List<TestCaseNodeDTO> getNodeByPlanId(@PathVariable String planId) {
checkPermissionService.checkTestPlanOwner(planId);
return testCaseNodeService.getNodeByPlanId(planId);
}
@GetMapping("/list/plan/{planId}/{runResult}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public List<TestCaseNodeDTO> getNodeByPlanIdAndRunResult(@PathVariable String planId,@PathVariable String runResult) {
checkPermissionService.checkTestPlanOwner(planId);
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
@ -80,24 +91,28 @@ public class TestCaseNodeController {
}
@GetMapping("/list/review/{reviewId}")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ})
public List<TestCaseNodeDTO> getNodeByReviewId(@PathVariable String reviewId) {
checkPermissionService.checkTestReviewOwner(reviewId);
return testCaseNodeService.getNodeByReviewId(reviewId);
}
@PostMapping("/add")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT})
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.CREATE, title = "#node.name", content = "#msClass.getLogDetails(#node)", msClass = TestCaseNodeService.class)
public String addNode(@RequestBody TestCaseNode node) {
return testCaseNodeService.addNode(node);
}
@PostMapping("/edit")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT})
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#node)", title = "#node.name", content = "#msClass.getLogDetails(#node)", msClass = TestCaseNodeService.class)
public int editNode(@RequestBody DragNodeRequest node) {
return testCaseNodeService.editNode(node);
}
@PostMapping("/delete")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT})
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#nodeIds)", msClass = TestCaseNodeService.class)
public int deleteNode(@RequestBody List<String> nodeIds) {
//nodeIds 包含删除节点ID及其所有子节点ID
@ -105,12 +120,14 @@ public class TestCaseNodeController {
}
@PostMapping("/drag")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT})
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#node)", title = "#node.name", content = "#msClass.getLogDetails(#node)", msClass = TestCaseNodeService.class)
public void dragNode(@RequestBody DragNodeRequest node) {
testCaseNodeService.dragNode(node);
}
@PostMapping("/pos")
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT})
public void treeSort(@RequestBody List<String> ids) {
testCaseNodeService.sort(ids);
}

View File

@ -1,51 +0,0 @@
package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCaseReport;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.request.testCaseReport.CreateReportRequest;
import io.metersphere.track.service.TestCaseReportService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;
@RequestMapping("/case/report")
@RestController
public class TestCaseReportController {
@Resource
TestCaseReportService testCaseReportService;
@PostMapping("/list")
public List<TestCaseReport> list(@RequestBody TestCaseReport request) {
return testCaseReportService.listTestCaseReport(request);
}
@GetMapping("/get/{id}")
public TestCaseReport get(@PathVariable String id) {
return testCaseReportService.getTestCaseReport(id);
}
@PostMapping("/add")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseReportService.class)
public String addByTemplateId(@RequestBody CreateReportRequest request) {
request.setId(UUID.randomUUID().toString());
return testCaseReportService.addTestCaseReportByTemplateId(request);
}
@PostMapping("/edit")
@MsAuditLog(module = OperLogModule.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) {
testCaseReportService.editTestCaseReport(TestCaseReport);
}
@PostMapping("/delete/{id}")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestCaseReportService.class)
public int delete(@PathVariable String id) {
return testCaseReportService.deleteTestCaseReport(id);
}
}

View File

@ -1,49 +0,0 @@
package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCaseReportTemplate;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.request.testCaseReport.QueryTemplateRequest;
import io.metersphere.track.service.TestCaseReportTemplateService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RequestMapping("/case/report/template")
@RestController
public class TestCaseReportTemplateController {
@Resource
TestCaseReportTemplateService testCaseReportTemplateService;
@PostMapping("/list")
public List<TestCaseReportTemplate> list(@RequestBody QueryTemplateRequest request) {
return testCaseReportTemplateService.listTestCaseReportTemplate(request);
}
@GetMapping("/get/{id}")
public TestCaseReportTemplate get(@PathVariable String id) {
return testCaseReportTemplateService.getTestCaseReportTemplate(id);
}
@PostMapping("/add")
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS, type = OperLogConstants.CREATE, title = "#testCaseReportTemplate.name",sourceId = "#testCaseReportTemplate.id")
public void add(@RequestBody TestCaseReportTemplate testCaseReportTemplate) {
testCaseReportTemplateService.addTestCaseReportTemplate(testCaseReportTemplate);
}
@PostMapping("/edit")
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS, type = OperLogConstants.UPDATE, title = "#testCaseReportTemplate.name",sourceId = "#testCaseReportTemplate.id")
public void edit(@RequestBody TestCaseReportTemplate testCaseReportTemplate) {
testCaseReportTemplateService.editTestCaseReportTemplate(testCaseReportTemplate);
}
@PostMapping("/delete/{id}")
@MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestCaseReportTemplateService.class)
public int delete(@PathVariable String id) {
return testCaseReportTemplateService.deleteTestCaseReportTemplate(id);
}
}

View File

@ -1,57 +0,0 @@
package io.metersphere.track.controller;
import com.github.pagehelper.Page;
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;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import io.metersphere.track.request.testreview.TestReviewApiCaseBatchRequest;
import io.metersphere.track.service.TestCaseReviewApiCaseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/test/case/review/api/case")
public class TestCaseReviewApiCaseController {
@Resource
private TestCaseReviewApiCaseService testCaseReviewApiCaseService;
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<TestPlanApiCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseReviewApiCaseService.list(request));
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
@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);
return PageUtils.setPageInfo(page, testCaseReviewApiCaseService.relevanceList(request));
}
@GetMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
public int deleteTestCase(@PathVariable String id) {
return testCaseReviewApiCaseService.delete(id);
}
@PostMapping("/batch/delete")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
public void deleteApiCaseBath(@RequestBody TestReviewApiCaseBatchRequest request) {
testCaseReviewApiCaseService.deleteApiCaseBath(request);
}
@PostMapping("/batch/update/env")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
public void batchUpdateEnv(@RequestBody TestPlanApiCaseBatchRequest request) {
testCaseReviewApiCaseService.batchUpdateEnv(request);
}
}

View File

@ -66,16 +66,19 @@ public class TestCaseReviewController {
}
@PostMapping("/reviewer")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public List<User> getUserByReviewId(@RequestBody TestCaseReview request) {
return testCaseReviewService.getUserByReviewId(request);
}
@PostMapping("/follow")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public List<User> getFollowByReviewId(@RequestBody TestCaseReview request) {
return testCaseReviewService.getFollowByReviewId(request);
}
@GetMapping("/recent/{count}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public List<TestCaseReviewDTO> recentTestPlans(@PathVariable int count) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
PageHelper.startPage(1, count, true);
@ -107,12 +110,14 @@ public class TestCaseReviewController {
}
@PostMapping("/relevance")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#request)", msClass = TestCaseReviewService.class)
public void testReviewRelevance(@RequestBody ReviewRelevanceRequest request) {
testCaseReviewService.testReviewRelevance(request);
}
@PostMapping("/projects")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public List<Project> getProjectByReviewId(@RequestBody TestReviewRelevanceRequest request) {
List<String> projectIds = testReviewProjectService.getProjectIdsByReviewId();
request.setProjectIds(projectIds);
@ -120,6 +125,7 @@ public class TestCaseReviewController {
}
@PostMapping("/project/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public Pager<List<Project>> getProjectByReviewId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRelevanceRequest request) {
List<String> projectIds = testReviewProjectService.getProjectIdsByReviewId();
request.setProjectIds(projectIds);
@ -143,6 +149,7 @@ public class TestCaseReviewController {
}
@PostMapping("/list/all/relate")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public List<TestReviewDTOWithMetric> listRelateAll(@RequestBody ReviewRelateRequest request) {
return testCaseReviewService.listRelateAll(request);
}

View File

@ -1,55 +0,0 @@
package io.metersphere.track.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.automation.*;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.track.dto.RelevanceScenarioRequest;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import io.metersphere.track.service.TestCaseReviewScenarioCaseService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/test/case/review/scenario/case")
public class TestCaseReviewScenarioCaseController {
@Resource
TestCaseReviewScenarioCaseService testCaseReviewScenarioCaseService;
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<ApiScenarioDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestPlanScenarioRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseReviewScenarioCaseService.list(request));
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Pager<List<ApiScenarioDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseReviewScenarioCaseService.relevanceList(request));
}
@GetMapping("/delete/{id}")
public int deleteTestCase(@PathVariable String id) {
return testCaseReviewScenarioCaseService.delete(id);
}
@PostMapping("/batch/delete")
public void deleteApiCaseBath(@RequestBody TestPlanApiCaseBatchRequest request) {
testCaseReviewScenarioCaseService.deleteApiCaseBath(request);
}
@PostMapping(value = "/run")
public List<MsExecResponseDTO> run(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Completed.name());
return testCaseReviewScenarioCaseService.run(request);
}
@PostMapping("/batch/update/env")
public void batchUpdateEnv(@RequestBody RelevanceScenarioRequest request) {
testCaseReviewScenarioCaseService.batchUpdateEnv(request);
}
}

View File

@ -31,37 +31,44 @@ public class TestPlanApiCaseController {
TestPlanApiCaseService testPlanApiCaseService;
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<TestPlanApiCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanApiCaseService.list(request));
}
@GetMapping("/list/failure/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanFailureApiDTO> getFailureList(@PathVariable String planId) {
return testPlanApiCaseService.getFailureCases(planId);
}
@GetMapping("/list/errorReport/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanFailureApiDTO> getErrorReportList(@PathVariable String planId) {
return testPlanApiCaseService.getErrorReportCases(planId);
}
@GetMapping("/list/unExecute/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanFailureApiDTO> getUnExecuteCases(@PathVariable String planId) {
return testPlanApiCaseService.getUnExecuteCases(planId);
}
@GetMapping("/list/all/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanFailureApiDTO> getAllList(@PathVariable String planId) {
return testPlanApiCaseService.getAllCases(planId);
}
@PostMapping("/selectAllTableRows")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanApiCaseDTO> selectAllTableRows(@RequestBody TestPlanApiCaseBatchRequest request) {
return testPlanApiCaseService.selectAllTableRows(request);
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
return testPlanApiCaseService.relevanceList(goPage, pageSize, request);
}
@ -88,12 +95,14 @@ public class TestPlanApiCaseController {
}
@PostMapping(value = "/run")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.planIds)", msClass = TestPlanApiCaseService.class)
public List<MsExecResponseDTO> run(@RequestBody BatchRunDefinitionRequest request) {
return testPlanApiCaseService.run(request);
}
@PostMapping("/edit/order")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
public void orderCase(@RequestBody ResetOrderRequest request) {
testPlanApiCaseService.updateOrder(request);
}

View File

@ -47,19 +47,20 @@ public class TestPlanController {
private ApiAutomationService apiAutomationService;
@PostMapping("/autoCheck/{testPlanId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public void autoCheck(@PathVariable String testPlanId) {
testPlanService.checkStatus(testPlanId);
}
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<TestPlanDTOWithMetric>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanService.listTestPlan(request));
}
@PostMapping("/dashboard/list/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<TestPlanDTOWithMetric>> listByWorkspaceId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanService.listByWorkspaceId(request));
@ -67,6 +68,7 @@ public class TestPlanController {
/*jenkins测试计划*/
@GetMapping("/list/all/{projectId}/{workspaceId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanDTOWithMetric> listByProjectId(@PathVariable String projectId, @PathVariable String workspaceId) {
QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setWorkspaceId(workspaceId);
@ -81,11 +83,13 @@ public class TestPlanController {
}
@GetMapping("/get/stage/option/{projectId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public JSONArray getStageOption(@PathVariable("projectId") String projectId) {
return testPlanService.getStageOption(projectId);
}
@GetMapping("recent/{count}/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlan> recentTestPlans(@PathVariable("count") int count, @PathVariable("id") String projectId) {
PageHelper.startPage(1, count, true);
return testPlanService.recentTestPlans(projectId);
@ -147,27 +151,32 @@ public class TestPlanController {
}
@PostMapping("/relevance")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#request)", msClass = TestPlanService.class)
public void testPlanRelevance(@RequestBody PlanCaseRelevanceRequest request) {
testPlanService.testPlanRelevance(request);
}
@GetMapping("/get/metric/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public TestCaseReportMetricDTO getMetric(@PathVariable String planId) {
return testPlanService.getMetric(planId);
}
@GetMapping("/get/statistics/metric/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public TestCaseReportMetricDTO getStatisticsMetric(@PathVariable String planId) {
return testPlanService.getStatisticsMetric(planId);
}
@GetMapping("/project/name/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public String getProjectNameByPlanId(@PathVariable String planId) {
return testPlanService.getProjectNameByPlanId(planId);
}
@PostMapping("/project")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<Project> getProjectByPlanId(@RequestBody TestCaseRelevanceRequest request) {
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId());
request.setProjectIds(projectIds);
@ -175,6 +184,7 @@ public class TestPlanController {
}
@PostMapping("/project/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<Project>> getProjectByPlanId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestCaseRelevanceRequest request) {
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId());
request.setProjectIds(projectIds);
@ -183,44 +193,52 @@ public class TestPlanController {
}
@PostMapping("/copy/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_CREATE)
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.CREATE, subject = "测试计划通知")
public TestPlan copy(@PathVariable String id) {
return testPlanService.copy(id);
}
@PostMapping("/api/case/env")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Map<String, List<String>> getApiCaseEnv(@RequestBody List<String> caseIds) {
return testPlanService.getApiCaseEnv(caseIds);
}
@PostMapping("/api/scenario/env")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Map<String, List<String>> getApiScenarioEnv(@RequestBody List<String> caseIds) {
return testPlanService.getApiScenarioEnv(caseIds);
}
@PostMapping("/case/env")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Map<String, List<String>> getPlanCaseEnv(@RequestBody TestPlan plan) {
return testPlanService.getPlanCaseEnv(plan.getId());
}
@PostMapping("/edit/runModeConfig")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
public void updateRunModeConfig(@RequestBody TestPlanRunRequest testplanRunRequest) {
testPlanService.updateRunModeConfig(testplanRunRequest);
}
@PostMapping("/run")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
public String run(@RequestBody TestPlanRunRequest testplanRunRequest) {
return testPlanService.runPlan(testplanRunRequest);
}
@PostMapping("/run/save")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
public String runAndSave(@RequestBody TestPlanRunRequest testplanRunRequest) {
testPlanService.updateRunModeConfig(testplanRunRequest);
return testPlanService.runPlan(testplanRunRequest);
}
@PostMapping(value = "/run/batch")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.testPlanIds)", msClass = TestPlanService.class)
public void runBatch(@RequestBody TestPlanRunRequest request) {
request.setTriggerMode(TriggerMode.BATCH.name());
@ -228,36 +246,43 @@ public class TestPlanController {
}
@GetMapping("/report/export/{planId}/{lang}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ_EXPORT)
public void exportHtmlReport(@PathVariable String planId, @PathVariable(required = false) String lang, HttpServletResponse response) throws UnsupportedEncodingException {
testPlanService.exportPlanReport(planId, lang, response);
}
@GetMapping("/get/report/export/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ_EXPORT)
public TestPlanSimpleReportDTO getExportHtmlReport(@PathVariable String planId, HttpServletResponse response) throws UnsupportedEncodingException {
return testPlanService.buildPlanReport(planId, true);
}
@GetMapping("/report/db/export/{reportId}/{lang}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ_EXPORT)
public void exportHtmlDbReport(@PathVariable String reportId, @PathVariable(required = false) String lang, HttpServletResponse response) throws UnsupportedEncodingException {
testPlanService.exportPlanDbReport(reportId, lang, response);
}
@GetMapping("/report/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public TestPlanSimpleReportDTO getReport(@PathVariable String planId) {
return testPlanService.getReport(planId, null);
}
@GetMapping("/report/functional/result")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public TestCaseReportStatusResultDTO getFunctionalResultReport(@PathVariable String planId) {
return testPlanService.getFunctionalResultReport(planId);
}
@PostMapping("/edit/report")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public void editReport(@RequestBody TestPlanWithBLOBs testPlanWithBLOBs) {
testPlanService.editReport(testPlanWithBLOBs);
}
@PostMapping(value = "/schedule/updateEnableByPrimyKey")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_SCHEDULE)
public Schedule updateScheduleEnableByPrimyKey(@RequestBody ScheduleInfoRequest request) {
Schedule schedule = scheduleService.getSchedule(request.getTaskID());
schedule.setEnable(request.isEnable());
@ -266,6 +291,7 @@ public class TestPlanController {
}
@PostMapping(value = "/schedule/updateEnableByPrimyKey/disable")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_SCHEDULE)
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_HOME_TASK, event = NoticeConstants.Event.CLOSE_SCHEDULE, subject = "测试跟踪通知")
public Schedule disableSchedule(@RequestBody ScheduleInfoRequest request) {
Schedule schedule = scheduleService.getSchedule(request.getTaskID());
@ -275,31 +301,37 @@ public class TestPlanController {
}
@GetMapping("/have/exec/case/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public boolean haveExecCase(@PathVariable String id) {
return testPlanService.haveExecCase(id);
}
@GetMapping("/principal/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<User> getPlanPrincipal(@PathVariable String planId) {
return testPlanService.getPlanPrincipal(planId);
}
@GetMapping("/follow/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<User> getPlanFollow(@PathVariable String planId) {
return testPlanService.getPlanFollow(planId);
}
@PostMapping(value = "/schedule/Batch/updateEnable")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_SCHEDULE)
public void updateBatchScheduleEnable(@RequestBody ScheduleInfoRequest request) {
testPlanService.batchUpdateScheduleEnable(request);
}
@PostMapping(value = "/schedule/enable/total")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public long countByScheduleEnableTotal(@RequestBody QueryTestPlanRequest request) {
return testPlanService.countScheduleEnableTotal(request);
}
@PostMapping(value = "/update/scheduleByEnable")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_SCHEDULE)
public ScheduleDTO updateTestPlanBySchedule(@RequestBody ScheduleInfoRequest request) {
return testPlanService.updateTestPlanBySchedule(request);
}

View File

@ -7,6 +7,7 @@ import io.metersphere.base.domain.TestPlanLoadCase;
import io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.constants.TriggerMode;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -20,6 +21,7 @@ import io.metersphere.track.request.testplan.LoadCaseReportRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest;
import io.metersphere.track.request.testplan.RunBatchTestPlanRequest;
import io.metersphere.track.service.TestPlanLoadCaseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -33,40 +35,47 @@ public class TestPlanLoadCaseController {
private TestPlanLoadCaseService testPlanLoadCaseService;
@PostMapping("/relevance/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<LoadTestDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody LoadCaseRequest request) {
return testPlanLoadCaseService.relevanceList(request, goPage, pageSize);
}
@PostMapping("/relevance")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#request.caseIds,#request.testPlanId)", msClass = TestPlanLoadCaseService.class)
public void relevanceCase(@RequestBody LoadCaseRequest request) {
testPlanLoadCaseService.relevanceCase(request);
}
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<TestPlanLoadCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody LoadCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanLoadCaseService.list(request));
}
@PostMapping("/selectAllTableRows")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanLoadCaseDTO> selectAllTableRows(@RequestBody LoadCaseReportBatchRequest request) {
return testPlanLoadCaseService.selectAllTableRows(request);
}
@GetMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_CREATE)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanLoadCaseService.class)
public void delete(@PathVariable String id) {
testPlanLoadCaseService.delete(id);
}
@PostMapping("/run")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.testPlanLoadId)", msClass = TestPlanLoadCaseService.class)
public String run(@RequestBody RunTestPlanRequest request) {
return testPlanLoadCaseService.run(request);
}
@PostMapping("/run/batch")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getRunLogDetails(#request.requests)", msClass = TestPlanLoadCaseService.class)
public void runBatch(@RequestBody RunBatchTestPlanRequest request) {
if (request.getRequests() != null) {
@ -78,54 +87,64 @@ public class TestPlanLoadCaseController {
}
@PostMapping("/report/exist")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Boolean isExistReport(@RequestBody LoadCaseReportRequest request) {
return testPlanLoadCaseService.isExistReport(request);
}
@PostMapping("/batch/delete")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanLoadCaseService.class)
public void batchDelete(@RequestBody LoadCaseReportBatchRequest request) {
testPlanLoadCaseService.batchDelete(request);
}
@PostMapping("/update")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#testPlanLoadCase.id)", msClass = TestPlanLoadCaseService.class)
public void update(@RequestBody TestPlanLoadCaseWithBLOBs testPlanLoadCase) {
testPlanLoadCaseService.update(testPlanLoadCase);
}
@PostMapping("/update/api")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#testPlanLoadCase.id)", msClass = TestPlanLoadCaseService.class)
public void updateByApi(@RequestBody TestPlanLoadCase testPlanLoadCase) {
testPlanLoadCaseService.updateByApi(testPlanLoadCase);
}
@GetMapping("/list/failure/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanLoadCaseDTO> getFailureCases(@PathVariable String planId) {
return testPlanLoadCaseService.getFailureCases(planId);
}
@GetMapping("/list/all/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanLoadCaseDTO> getAllCases(@PathVariable String planId) {
return testPlanLoadCaseService.getAllCases(planId);
}
@GetMapping("/get-load-config/{loadCaseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public String getPlanLoadCaseConfig(@PathVariable String loadCaseId) {
return testPlanLoadCaseService.getPlanLoadCaseConfig(loadCaseId);
}
@GetMapping("/get-advanced-config/{loadCaseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public String getAdvancedConfiguration(@PathVariable String loadCaseId) {
return testPlanLoadCaseService.getAdvancedConfiguration(loadCaseId);
}
@GetMapping("/get/{loadCaseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public TestPlanLoadCase getTestPlanLoadCase(@PathVariable String loadCaseId) {
return testPlanLoadCaseService.getTestPlanLoadCase(loadCaseId);
}
@PostMapping("/edit/order")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
public void orderCase(@RequestBody ResetOrderRequest request) {
testPlanLoadCaseService.updateOrder(request);
}

View File

@ -6,6 +6,7 @@ import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
@ -17,6 +18,7 @@ import io.metersphere.track.dto.TestPlanSimpleReportDTO;
import io.metersphere.track.request.report.QueryTestPlanReportRequest;
import io.metersphere.track.request.report.TestPlanReportSaveRequest;
import io.metersphere.track.service.TestPlanReportService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -36,22 +38,26 @@ public class TestPlanReportController {
private TestPlanReportService testPlanReportService;
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public Pager<List<TestPlanReportDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanReportRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanReportService.list(request));
}
@GetMapping("/getMetric/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public TestPlanReportDTO getMetric(@PathVariable String planId) {
return testPlanReportService.getMetric(planId);
}
@GetMapping("/db/{reportId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public TestPlanSimpleReportDTO getReport(@PathVariable String reportId) {
return testPlanReportService.getReport(reportId);
}
@GetMapping("/status/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public String getStatus(@PathVariable String planId) {
TestPlanReport report = testPlanReportService.getTestPlanReport(planId);
String status = report.getStatus();
@ -59,6 +65,7 @@ public class TestPlanReportController {
}
@PostMapping("/delete")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ_DELETE)
@MsAuditLog(module = OperLogModule.TRACK_REPORT, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanReportIdList)", msClass = TestPlanReportService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_REPORT_TASK, target = "#targetClass.getReports(#testPlanReportIdList)", targetClass = TestPlanReportService.class,
event = NoticeConstants.Event.DELETE, subject = "报告通知")
@ -67,11 +74,13 @@ public class TestPlanReportController {
}
@PostMapping("/deleteBatchByParams")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ_DELETE)
public void deleteBatchByParams(@RequestBody QueryTestPlanReportRequest request) {
testPlanReportService.delete(request);
}
@GetMapping("/saveTestPlanReport/{planId}/{triggerMode}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public String saveTestPlanReport(@PathVariable String planId, @PathVariable String triggerMode) {
String userId = SessionUtils.getUser().getId();
String reportId = UUID.randomUUID().toString();
@ -83,6 +92,7 @@ public class TestPlanReportController {
}
@PostMapping("/reName")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REPORT_READ)
public void reName(@RequestBody TestPlanReport request) {
testPlanReportService.reName(request.getId(), request.getName());
}

View File

@ -6,6 +6,7 @@ import io.metersphere.api.dto.automation.*;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.constants.RunModeConstants;
@ -16,6 +17,7 @@ import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.dto.RelevanceScenarioRequest;
import io.metersphere.track.request.testcase.TestPlanScenarioCaseBatchRequest;
import io.metersphere.track.service.TestPlanScenarioCaseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -31,54 +33,64 @@ public class TestPlanScenarioCaseController {
TestPlanScenarioCaseService testPlanScenarioCaseService;
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<ApiScenarioDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestPlanScenarioRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanScenarioCaseService.list(request));
}
@GetMapping("/list/failure/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanFailureScenarioDTO> getFailureList(@PathVariable String planId) {
return testPlanScenarioCaseService.getFailureCases(planId);
}
@GetMapping("/list/errorReport/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanFailureScenarioDTO> getErrorReportList(@PathVariable String planId) {
return testPlanScenarioCaseService.getErrorReportCases(planId);
}
@GetMapping("/list/unExecute/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanFailureScenarioDTO> getUnExecuteCases(@PathVariable String planId) {
return testPlanScenarioCaseService.getUnExecuteCases(planId);
}
@GetMapping("/list/all/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanFailureScenarioDTO> getAllList(@PathVariable String planId) {
return testPlanScenarioCaseService.getAllCases(planId);
}
@PostMapping("/selectAllTableRows")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<ApiScenarioDTO> selectAllTableRows(@RequestBody TestPlanScenarioCaseBatchRequest request) {
return testPlanScenarioCaseService.selectAllTableRows(request);
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<ApiScenarioDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
return testPlanScenarioCaseService.relevanceList(request, goPage, pageSize);
}
@GetMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanScenarioCaseService.class)
public int deleteTestCase(@PathVariable String id) {
return testPlanScenarioCaseService.delete(id);
}
@PostMapping("/batch/delete")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanScenarioCaseService.class)
public void deleteApiCaseBath(@RequestBody TestPlanScenarioCaseBatchRequest request) {
testPlanScenarioCaseService.deleteApiCaseBath(request);
}
@PostMapping(value = "/run")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.planCaseIds)", msClass = TestPlanScenarioCaseService.class)
public List<MsExecResponseDTO> run(@RequestBody RunTestPlanScenarioRequest request) {
request.setExecuteType(ExecuteType.Completed.name());
@ -92,6 +104,7 @@ public class TestPlanScenarioCaseController {
}
@PostMapping(value = "/jenkins/run")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanScenarioCaseService.class)
public List<MsExecResponseDTO> runByRun(@RequestBody RunTestPlanScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
@ -101,17 +114,20 @@ public class TestPlanScenarioCaseController {
}
@PostMapping("/batch/update/env")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.batchLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanScenarioCaseService.class)
public void batchUpdateEnv(@RequestBody RelevanceScenarioRequest request) {
testPlanScenarioCaseService.batchUpdateEnv(request);
}
@PostMapping("/env")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Map<String, String> getScenarioCaseEnv(@RequestBody HashMap<String, String> map) {
return testPlanScenarioCaseService.getScenarioCaseEnv(map);
}
@PostMapping("/edit/order")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
public void orderCase(@RequestBody ResetOrderRequest request) {
testPlanScenarioCaseService.updateOrder(request);
}

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestPlanTestCaseWithBLOBs;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ResetOrderRequest;
@ -14,6 +15,7 @@ import io.metersphere.track.request.testcase.TestPlanCaseBatchRequest;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.track.request.testplancase.TestPlanFuncCaseBatchRequest;
import io.metersphere.track.service.TestPlanTestCaseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -28,6 +30,7 @@ public class TestPlanTestCaseController {
TestPlanTestCaseService testPlanTestCaseService;
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<TestPlanCaseDTO>> getTestPlanCases(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanCaseRequest request) {
testPlanTestCaseService.wrapQueryTestPlanCaseRequest(request);
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
@ -36,6 +39,7 @@ public class TestPlanTestCaseController {
/*jenkins测试计划下全部用例*/
@GetMapping("/list/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> getTestPlanCaseByPlanId(@PathVariable String planId) {
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
request.setPlanId(planId);
@ -44,17 +48,20 @@ public class TestPlanTestCaseController {
}
@PostMapping("/list/minder")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> listForMinder(@RequestBody QueryTestPlanCaseRequest request) {
return testPlanTestCaseService.listForMinder(request);
}
@PostMapping("/list/minder/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public Pager<List<TestPlanCaseDTO>> listForMinder(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanTestCaseService.listForMinder(request));
}
@GetMapping("/list/node/{planId}/{nodePaths}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> getTestPlanCasesByNodePath(@PathVariable String planId, @PathVariable String nodePaths) {
String nodePath = nodePaths.replace("f", "/");
String[] array = nodePath.split(",");
@ -67,6 +74,7 @@ public class TestPlanTestCaseController {
}
@GetMapping("/list/node/all/{planId}/{nodePaths}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> getTestPlanCasesByNodePaths(@PathVariable String planId, @PathVariable String nodePaths) {
String nodePath = nodePaths.replace("f", "");
String[] array = nodePath.split(",");
@ -79,72 +87,85 @@ public class TestPlanTestCaseController {
}
@GetMapping("/get/{caseId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public TestPlanCaseDTO getTestPlanCases(@PathVariable String caseId) {
return testPlanTestCaseService.get(caseId);
}
@PostMapping("recent/{count}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> getRecentTestCases(@PathVariable int count, @RequestBody QueryTestPlanCaseRequest request) {
return testPlanTestCaseService.getRecentTestCases(request, count);
}
@PostMapping("pending/{count}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> getPrepareTestCases(@PathVariable int count, @RequestBody QueryTestPlanCaseRequest request) {
return testPlanTestCaseService.getPendingTestCases(request, count);
}
@PostMapping("/list/all")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> getTestPlanCases(@RequestBody QueryTestPlanCaseRequest request) {
testPlanTestCaseService.wrapQueryTestPlanCaseRequest(request);
return testPlanTestCaseService.list(request);
}
@PostMapping("/idList/all")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<String> getTestPlanCases(@RequestBody TestPlanFuncCaseBatchRequest request) {
return testPlanTestCaseService.idList(request);
}
@PostMapping("/edit")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#testPlanTestCase.id)", msClass = TestPlanTestCaseService.class)
public void editTestCase(@RequestBody TestPlanTestCaseWithBLOBs testPlanTestCase) {
testPlanTestCaseService.editTestCase(testPlanTestCase);
}
@PostMapping("/minder/edit")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getCaseLogDetails(#testPlanTestCases)", msClass = TestPlanTestCaseService.class)
public void editTestCaseForMinder(@RequestBody List<TestPlanTestCaseWithBLOBs> testPlanTestCases) {
testPlanTestCaseService.editTestCaseForMinder(testPlanTestCases);
}
@PostMapping("/batch/edit")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.batchLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanTestCaseService.class)
public void editTestCaseBath(@RequestBody TestPlanCaseBatchRequest request) {
testPlanTestCaseService.editTestCaseBath(request);
}
@PostMapping("/batch/delete")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanTestCaseService.class)
public void deleteTestCaseBath(@RequestBody TestPlanCaseBatchRequest request) {
testPlanTestCaseService.deleteTestCaseBath(request);
}
@PostMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanTestCaseService.class)
public int deleteTestCase(@PathVariable String id) {
return testPlanTestCaseService.deleteTestCase(id);
}
@GetMapping("/list/failure/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> getFailureCases(@PathVariable String planId) {
return testPlanTestCaseService.getFailureCases(planId);
}
@GetMapping("/list/all/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<TestPlanCaseDTO> getAllCases(@PathVariable String planId) {
return testPlanTestCaseService.getAllCases(planId);
}
@PostMapping("/edit/order")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RELEVANCE_OR_CANCEL)
public void orderCase(@RequestBody ResetOrderRequest request) {
testPlanTestCaseService.updateOrder(request);
}

View File

@ -1,66 +0,0 @@
package io.metersphere.track.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestCaseReviewLoad;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.dto.TestReviewLoadCaseDTO;
import io.metersphere.performance.request.RunTestPlanRequest;
import io.metersphere.track.request.testplan.LoadCaseReportRequest;
import io.metersphere.track.request.testreview.TestReviewRequest;
import io.metersphere.track.service.TestCaseReviewLoadService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/test/review/load/case")
public class TestReviewLoadCaseController {
@Resource
private TestCaseReviewLoadService testCaseReviewLoadService;
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Pager<List<LoadTestDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseReviewLoadService.relevanceList(request));
}
@PostMapping("/relevance")
public void relevanceCase(@RequestBody TestReviewRequest request) {
testCaseReviewLoadService.relevanceCase(request);
}
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<TestReviewLoadCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseReviewLoadService.list(request));
}
@GetMapping("/delete/{id}")
public void delete(@PathVariable String id) {
testCaseReviewLoadService.delete(id);
}
@PostMapping("/run")
public String run(@RequestBody RunTestPlanRequest request) {
return testCaseReviewLoadService.run(request);
}
@PostMapping("/report/exist")
public Boolean isExistReport(@RequestBody LoadCaseReportRequest request) {
return testCaseReviewLoadService.isExistReport(request);
}
@PostMapping("/batch/delete")
public void batchDelete(@RequestBody List<String> ids) {
testCaseReviewLoadService.batchDelete(ids);
}
@PostMapping("/update")
public void update(@RequestBody TestCaseReviewLoad testCaseReviewLoad) {
testCaseReviewLoadService.update(testCaseReviewLoad);
}
}

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestCaseReviewTestCase;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ResetOrderRequest;
@ -14,6 +15,7 @@ import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest;
import io.metersphere.track.request.testreview.DeleteRelevanceRequest;
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
import io.metersphere.track.service.TestReviewTestCaseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -27,58 +29,68 @@ public class TestReviewTestCaseController {
TestReviewTestCaseService testReviewTestCaseService;
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public Pager<List<TestReviewCaseDTO>> getTestPlanCases(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryCaseReviewRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testReviewTestCaseService.list(request));
}
@PostMapping("/delete")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request)", msClass = TestReviewTestCaseService.class)
public int deleteTestCase(@RequestBody DeleteRelevanceRequest request) {
return testReviewTestCaseService.deleteTestCase(request);
}
@PostMapping("/batch/delete")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request)", msClass = TestReviewTestCaseService.class)
public void deleteTestCaseBatch(@RequestBody TestReviewCaseBatchRequest request) {
testReviewTestCaseService.deleteTestCaseBatch(request);
}
@PostMapping("/batch/edit/status")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_EDIT)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.batchLogDetails(#request)", content = "#msClass.getLogDetails(#request)", msClass = TestReviewTestCaseService.class)
public void editTestCaseBatch(@RequestBody TestReviewCaseBatchRequest request) {
testReviewTestCaseService.editTestCaseBatchStatus(request);
}
@PostMapping("/minder/edit/{reviewId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_EDIT)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#testCases)", msClass = TestReviewTestCaseService.class)
public void editTestCaseForMinder(@PathVariable("reviewId") String reviewId, @RequestBody List<TestCaseReviewTestCase> testCases) {
testReviewTestCaseService.editTestCaseForMinder(reviewId, testCases);
}
@PostMapping("/list/minder")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public List<TestReviewCaseDTO> listForMinder(@RequestBody QueryCaseReviewRequest request) {
return testReviewTestCaseService.listForMinder(request);
}
@PostMapping("/list/minder/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public Pager<List<TestReviewCaseDTO>> listForMinder(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryCaseReviewRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testReviewTestCaseService.listForMinder(request));
}
@PostMapping("/edit")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_EDIT)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.REVIEW, content = "#msClass.getLogDetails(#testCaseReviewTestCase)", msClass = TestReviewTestCaseService.class)
public void editTestCase(@RequestBody TestCaseReviewTestCase testCaseReviewTestCase) {
testReviewTestCaseService.editTestCase(testCaseReviewTestCase);
}
@GetMapping("/get/{reviewId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ)
public TestReviewCaseDTO get(@PathVariable String reviewId) {
return testReviewTestCaseService.get(reviewId);
}
@PostMapping("/edit/order")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_RELEVANCE_OR_CANCEL)
public void orderCase(@RequestBody ResetOrderRequest request) {
testReviewTestCaseService.updateOrder(request);
}