feat(测试计划): 新增导出PDF日志&权限
This commit is contained in:
parent
516f2127d2
commit
d80ba71338
|
@ -4,6 +4,9 @@ SET SESSION innodb_lock_wait_timeout = 7200;
|
|||
|
||||
-- 组织管理员增加权限
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'org_admin', 'ORGANIZATION_PROJECT_MEMBER_UPDATE');
|
||||
-- 项目管理员增加导出权限
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_API_REPORT:READ+EXPORT');
|
||||
INSERT INTO user_role_permission (id, role_id, permission_id) VALUES (UUID_SHORT(), 'project_admin', 'PROJECT_TEST_PLAN_REPORT:READ+EXPORT');
|
||||
|
||||
-- 初始化默认参数文件上传大小
|
||||
INSERT INTO system_parameter (param_key, param_value, type) VALUES ('upload.file.size', '50', 'text');
|
||||
|
|
|
@ -293,6 +293,7 @@ public class PermissionConstants {
|
|||
public static final String PROJECT_API_REPORT_UPDATE = "PROJECT_API_REPORT:READ+UPDATE";
|
||||
public static final String PROJECT_API_REPORT_DELETE = "PROJECT_API_REPORT:READ+DELETE";
|
||||
public static final String PROJECT_API_REPORT_SHARE = "PROJECT_API_REPORT:READ+SHARE";
|
||||
public static final String PROJECT_API_REPORT_EXPORT = "PROJECT_API_REPORT:READ+EXPORT";
|
||||
/*------ end: API_REPORT ------*/
|
||||
|
||||
//个人中心
|
||||
|
@ -317,6 +318,7 @@ public class PermissionConstants {
|
|||
public static final String TEST_PLAN_REPORT_READ_UPDATE = "PROJECT_TEST_PLAN_REPORT:READ+UPDATE";
|
||||
public static final String TEST_PLAN_REPORT_READ_SHARE = "PROJECT_TEST_PLAN_REPORT:READ+SHARE";
|
||||
public static final String TEST_PLAN_REPORT_READ_DELETE = "PROJECT_TEST_PLAN_REPORT:READ+DELETE";
|
||||
public static final String TEST_PLAN_REPORT_READ_EXPORT = "PROJECT_TEST_PLAN_REPORT:READ+EXPORT";
|
||||
/*------ end: TEST_PLAN ------*/
|
||||
|
||||
/*------ start: SYSTEM_TASK_CENTER ------*/
|
||||
|
|
|
@ -112,4 +112,10 @@ public class ApiReportController {
|
|||
return apiReportService.getDetail(reportId, stepId);
|
||||
}
|
||||
|
||||
@GetMapping("/export/{reportId}")
|
||||
@Operation(summary = "接口测试-用例报告-导出日志")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_REPORT_EXPORT)
|
||||
public void exportLog(@PathVariable String reportId) {
|
||||
apiReportService.exportLog(reportId, SessionUtils.getUserId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,4 +112,10 @@ public class ApiScenarioReportController {
|
|||
return apiScenarioReportService.getDetail(reportId, stepId);
|
||||
}
|
||||
|
||||
@GetMapping("/export/{reportId}")
|
||||
@Operation(summary = "接口测试-场景报告-导出日志")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_REPORT_EXPORT)
|
||||
public void exportLog(@PathVariable String reportId) {
|
||||
apiScenarioReportService.exportLog(reportId, SessionUtils.getUserId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,4 +87,19 @@ public class ApiReportLogService {
|
|||
});
|
||||
operationLogService.batchAdd(logs);
|
||||
}
|
||||
|
||||
public void exportLog(ApiReport report, String userId) {
|
||||
Project project = projectMapper.selectByPrimaryKey(report.getProjectId());
|
||||
LogDTO dto = new LogDTO(
|
||||
report.getProjectId(),
|
||||
project.getOrganizationId(),
|
||||
report.getId(),
|
||||
userId,
|
||||
OperationLogType.EXPORT.name(),
|
||||
OperationLogModule.API_REPORT,
|
||||
report.getName());
|
||||
dto.setPath("/api/report/case/export/" + report.getId());
|
||||
dto.setMethod(HttpMethodConstants.GET.name());
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,4 +258,9 @@ public class ApiReportService {
|
|||
apiReport.setUpdateTime(System.currentTimeMillis());
|
||||
apiReportMapper.updateByPrimaryKeySelective(apiReport);
|
||||
}
|
||||
|
||||
public void exportLog(String reportId, String userId) {
|
||||
ApiReport apiReport = apiReportMapper.selectByPrimaryKey(reportId);
|
||||
Optional.ofNullable(apiReport).ifPresent(report -> apiReportLogService.exportLog(report, userId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,4 +87,19 @@ public class ApiScenarioReportLogService {
|
|||
});
|
||||
operationLogService.batchAdd(logs);
|
||||
}
|
||||
|
||||
public void exportLog(ApiScenarioReport report, String userId) {
|
||||
Project project = projectMapper.selectByPrimaryKey(report.getProjectId());
|
||||
LogDTO dto = new LogDTO(
|
||||
report.getProjectId(),
|
||||
project.getOrganizationId(),
|
||||
report.getId(),
|
||||
userId,
|
||||
OperationLogType.EXPORT.name(),
|
||||
OperationLogModule.API_TEST_REPORT_SCENARIO,
|
||||
report.getName());
|
||||
dto.setPath("/api/report/scenario/export/" + report.getId());
|
||||
dto.setMethod(HttpMethodConstants.GET.name());
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,4 +392,9 @@ public class ApiScenarioReportService {
|
|||
reportExample.createCriteria().andIdIn(reportIds);
|
||||
return apiScenarioReportMapper.selectByExample(reportExample);
|
||||
}
|
||||
|
||||
public void exportLog(String reportId, String userId) {
|
||||
ApiScenarioReport apiScenarioReport = apiScenarioReportMapper.selectByPrimaryKey(reportId);
|
||||
Optional.ofNullable(apiScenarioReport).ifPresent(report -> apiScenarioReportLogService.exportLog(report, userId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,6 +153,9 @@
|
|||
{
|
||||
"id": "PROJECT_API_REPORT:READ+SHARE",
|
||||
"name": "permission.api_doc.share"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_API_REPORT:READ+EXPORT"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
private static final String GET = BASIC + "/get/";
|
||||
private static final String BATCH_DELETE = BASIC + "/batch/delete";
|
||||
private static final String DETAIL = BASIC + "/get/detail/";
|
||||
private static final String EXPORT_REPORT = BASIC + "/export/";
|
||||
|
||||
|
||||
@Test
|
||||
|
@ -487,4 +488,9 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
.andExpect(status().is5xxServerError());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
public void testExportReport() throws Exception {
|
||||
this.requestGet(EXPORT_REPORT + "api-report-id1");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
private static final String GET = BASIC + "/get/";
|
||||
private static final String BATCH_DELETE = BASIC + "/batch/delete";
|
||||
private static final String DETAIL = BASIC + "/get/detail/";
|
||||
private static final String EXPORT_REPORT = BASIC + "/export/";
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
|
@ -532,5 +533,9 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
.andExpect(status().is5xxServerError());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
public void testExportReport() throws Exception {
|
||||
this.requestGet(EXPORT_REPORT + "scenario-report-id1");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,4 +220,12 @@ public class TestPlanReportController {
|
|||
public ResponseEntity<byte[]> previewMd(@PathVariable String projectId, @PathVariable String fileId, @PathVariable("compressed") boolean compressed) {
|
||||
return testPlanReportService.previewMd(projectId, fileId, compressed);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/export/{reportId}")
|
||||
@Operation(summary = "测试计划-报告-导出日志")
|
||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_REPORT_READ_EXPORT)
|
||||
public void exportLog(@PathVariable String reportId) {
|
||||
testPlanReportService.exportLog(reportId, SessionUtils.getUserId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,4 +136,19 @@ public class TestPlanReportLogService {
|
|||
log.setOriginalValue(JSON.toJSONBytes(report));
|
||||
operationLogService.add(log);
|
||||
}
|
||||
|
||||
public void exportLog(TestPlanReport report, String userId) {
|
||||
Project project = projectMapper.selectByPrimaryKey(report.getProjectId());
|
||||
LogDTO log = new LogDTO(
|
||||
report.getProjectId(),
|
||||
project.getOrganizationId(),
|
||||
report.getId(),
|
||||
userId,
|
||||
OperationLogType.EXPORT.name(),
|
||||
report.getIntegrated() ? OperationLogModule.TEST_PLAN_GROUP_REPORT : OperationLogModule.TEST_PLAN_REPORT,
|
||||
report.getName());
|
||||
log.setMethod(HttpMethodConstants.GET.name());
|
||||
log.setPath("/test-plan/report/export/" + report.getId());
|
||||
operationLogService.add(log);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1263,4 +1263,9 @@ public class TestPlanReportService {
|
|||
}
|
||||
return modules.stream().collect(Collectors.toMap(TestPlanBaseModule::getId, TestPlanBaseModule::getName));
|
||||
}
|
||||
|
||||
public void exportLog(String reportId, String userId) {
|
||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(reportId);
|
||||
Optional.ofNullable(testPlanReport).ifPresent(report -> testPlanReportLogService.exportLog(report, userId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
},
|
||||
{
|
||||
"id": "PROJECT_TEST_PLAN_REPORT:READ+DELETE"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_TEST_PLAN_REPORT:READ+EXPORT"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ public class TestPlanReportControllerTests extends BaseTest {
|
|||
private static final String GET_SHARE_REPORT_API_REPORT_LIST = "/test-plan/report/share/detail/api-report";
|
||||
private static final String GET_SHARE_REPORT_SCENARIO_REPORT_LIST = "/test-plan/report/share/detail/scenario-report";
|
||||
private static final String GET_SHARE_REPORT_DETAIL_FUNCTIONAL_RESULT = "/test-plan/report/share/detail/functional/case/step";
|
||||
private static final String GET_EXPORT_REPORT = "/test-plan/report/export/";
|
||||
|
||||
@Autowired
|
||||
private TestPlanReportMapper testPlanReportMapper;
|
||||
|
@ -473,4 +474,11 @@ public class TestPlanReportControllerTests extends BaseTest {
|
|||
example.createCriteria().andTestPlanIdEqualTo("plan_id_for_gen_report").andDefaultLayoutEqualTo(false);
|
||||
return testPlanReportMapper.selectByExample(example).getFirst().getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(25)
|
||||
void testExportReport() throws Exception {
|
||||
this.requestGet(GET_EXPORT_REPORT + "test-plan-report-id-1");
|
||||
this.requestGet(GET_EXPORT_REPORT + "test-plan-report-id-3");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue