refactor(接口测试): 接口管理模块接口定义简化代码

This commit is contained in:
lan-yonghui 2023-11-24 15:08:08 +08:00 committed by Craftsman
parent f313c43ba3
commit e89049ec76
5 changed files with 48 additions and 52 deletions

View File

@ -8,7 +8,7 @@ public class SubListUtils {
/**
* 将较长的数组截断成较短的数组进行批处理
*/
public static void dealForSubList(List totalList, Integer batchSize, Consumer<List> subFunc) {
public static <T> void dealForSubList(List<T> totalList, Integer batchSize, Consumer<List<T>> subFunc) {
int count = totalList.size();
int iteratorCount = count / batchSize;
for (int i = 0; i <= iteratorCount; i++) {
@ -18,7 +18,7 @@ public class SubListUtils {
if (endIndex == startIndex) {
break;
}
List subList = totalList.subList(startIndex, endIndex);
List<T> subList = totalList.subList(startIndex, endIndex);
subFunc.accept(subList);
}
}

View File

@ -19,6 +19,7 @@ import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.LogUtils;
import io.metersphere.sdk.util.SubListUtils;
import io.metersphere.system.service.UserLoginService;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.uid.NumGenerator;
@ -327,16 +328,15 @@ public class ApiDefinitionService {
}
private void checkUpdateExist(ApiDefinition apiDefinition, ApiDefinition originApiDefinition) {
if (StringUtils.isBlank(apiDefinition.getPath()) || StringUtils.isBlank(apiDefinition.getMethod())) {
return;
}
ApiDefinitionExample example = new ApiDefinitionExample();
example.createCriteria()
.andIdNotEqualTo(apiDefinition.getId()).andProtocolEqualTo(apiDefinition.getProtocol())
.andModuleIdEqualTo(apiDefinition.getModuleId() == null ? originApiDefinition.getModuleId() : apiDefinition.getModuleId())
.andPathEqualTo(apiDefinition.getPath()).andMethodEqualTo(apiDefinition.getMethod());
if (apiDefinitionMapper.countByExample(example) > 0) {
throw new MSException(ApiResultCode.API_DEFINITION_EXIST);
if (StringUtils.isNotEmpty(apiDefinition.getPath()) && StringUtils.isNotEmpty(apiDefinition.getMethod())) {
ApiDefinitionExample example = new ApiDefinitionExample();
example.createCriteria()
.andIdNotEqualTo(apiDefinition.getId()).andProtocolEqualTo(apiDefinition.getProtocol())
.andModuleIdEqualTo(apiDefinition.getModuleId() == null ? originApiDefinition.getModuleId() : apiDefinition.getModuleId())
.andPathEqualTo(apiDefinition.getPath()).andMethodEqualTo(apiDefinition.getMethod());
if (apiDefinitionMapper.countByExample(example) > 0) {
throw new MSException(ApiResultCode.API_DEFINITION_EXIST);
}
}
}
@ -431,15 +431,10 @@ public class ApiDefinitionService {
}
} else {
// 列表删除
// 选中的数据直接放入回收站
while (!ids.isEmpty()) {
if (ids.size() <= 2000) {
doDelete(ids, userId, projectId);
break;
}
List<String> subList = ids.subList(0, 2000);
doDelete(subList, userId, projectId);
ids.removeAll(subList);
if (!ids.isEmpty()) {
SubListUtils.dealForSubList(ids, 2000, subList -> {
doDelete(subList, userId, projectId);
});
}
}
}
@ -514,15 +509,9 @@ public class ApiDefinitionService {
}
private void handleRestoreApiDefinition(List<String> ids, String userId, String projectId){
if (CollectionUtils.isNotEmpty(ids)) {
while (!ids.isEmpty()) {
if (ids.size() <= 2000) {
doRestore(ids, userId, projectId);
break;
}
List<String> subList = ids.subList(0, 2000);
doRestore(ids, userId, projectId);
ids.removeAll(subList);
}
SubListUtils.dealForSubList(ids, 2000, subList -> {
doRestore(subList, userId, projectId);
});
}
}
@ -584,15 +573,9 @@ public class ApiDefinitionService {
private void handleRecycleDelApiDefinition(List<String> ids, String userId, String projectId, Boolean isBatch){
if (CollectionUtils.isNotEmpty(ids)) {
while (!ids.isEmpty()) {
if (ids.size() <= 2000) {
doRecycleDel(ids, userId, projectId, isBatch);
break;
}
List<String> subList = ids.subList(0, 2000);
doRecycleDel(ids, userId, projectId, isBatch);
ids.removeAll(subList);
}
SubListUtils.dealForSubList(ids, 2000, subList -> {
doRecycleDel(subList, userId, projectId, isBatch);
});
}
}

View File

@ -667,11 +667,13 @@ public class ApiDefinitionControllerTests extends BaseTest {
private void configureKeywordSearch(ApiDefinitionPageRequest request) {
request.setKeyword("100");
request.setSort(Map.of("status", "asc"));
request.setVersionId("100570499574136985");
}
private void configureFilterSearch(ApiDefinitionPageRequest request) {
Map<String, List<String>> filters = new HashMap<>();
request.setSort(Map.of("updateTime", "asc"));
filters.put("status", Arrays.asList("Underway", "Completed"));
filters.put("method", List.of("GET"));
filters.put("version_id", List.of("1005704995741369851"));
@ -729,6 +731,12 @@ public class ApiDefinitionControllerTests extends BaseTest {
// Assertions.assertNull(item.getDeleteTime());
// });
// }
// @恢复一条数据
apiDefinitionDeleteRequest.setId("111");
// @@请求成功
assertErrorCode(this.requestPost(RESTORE, apiDefinitionDeleteRequest), ApiResultCode.API_DEFINITION_NOT_EXIST);
// @@校验权限
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_UPDATE, RESTORE, apiDefinitionDeleteRequest);
}

View File

@ -1,31 +1,36 @@
-- 插入测试数据
DELETE FROM `api_definition` WHERE `id` in ('1001','1002','1003','1004','1005','1006');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1001', 'test-1', 'HTTP', 'POST', '/api/admin/1', 'Prepare', 1001, '[\"test1\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1001', NULL, 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1002', 'test-2', 'HTTP', 'GET', '/api/admin/2', 'Underway', 1002, '[\"test2\",\"te\"]', 1, '100001100001', 'root', b'1', '1005704995741369851', '1002', NULL, 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1003', 'test-3', 'HTTP', 'POST', '/api/admin/3', 'Completed', 1003, '[\"test3\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1002', NULL, 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1004', 'test-4', 'HTTP', 'GET', '/api/admin/4', 'Prepare', 1004, '[\"test4\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1004', NULL, 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1005', 'test-65', 'HTTP', 'POST', '/api/admin/5', 'Underway', 1005, '[\"test5\",\"te\"]', 1, '100001100001', 'root', b'0', '100570499574136985', '1004', NULL, 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1006', 'test-6', 'HTTP', 'GET', '/api/admin/6', 'Completed', 1006, '[\"test6\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1006', NULL, 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1001', 'test-1', 'HTTP', 'POST', '/api/admin/1', 'Prepare', 1001, '[\"test1\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1001', NULL, 1699500298164, 'admin', 1699500298162, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1002', 'test-2', 'HTTP', 'GET', '/api/admin/2', 'Underway', 1002, '[\"test2\",\"te\"]', 1, '100001100001', 'root', b'1', '1005704995741369851', '1002', NULL, 1699500298165, 'admin', 1699500298163, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1003', 'test-3', 'HTTP', 'POST', '/api/admin/3', 'Completed', 1003, '[\"test3\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1002', NULL, 1699500298166, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1004', 'test-4', 'HTTP', 'GET', '/api/admin/4', 'Prepare', 1004, '[\"test4\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1004', NULL, 1699500298167, 'admin', 1699500298165, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1005', 'test-65', 'HTTP', 'POST', '/api/admin/5', 'Underway', 1005, '[\"test5\",\"te\"]', 1, '100001100001', 'root', b'0', '100570499574136985', '1004', NULL, 1699500298168, 'admin', 1699500298166, 'admin', NULL, NULL, b'0');
INSERT INTO `api_definition` (`id`, `name`, `protocol`, `method`, `path`, `status`, `num`, `tags`, `pos`, `project_id`, `module_id`, `latest`, `version_id`, `ref_id`, `description`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_user`, `delete_time`, `deleted`) VALUES ('1006', 'test-6', 'HTTP', 'GET', '/api/admin/6', 'Completed', 1006, '[\"test6\",\"te\"]', 1, '100001100001', 'root', b'1', '100570499574136985', '1006', NULL, 1699500298169, 'admin', 1699500298167, 'admin', NULL, NULL, b'0');
DELETE FROM `project_version` WHERE `id` = '100570499574136985';
INSERT INTO project_version (id, project_id, name, description, status, latest, publish_time, start_time, end_time, create_time, create_user) VALUES ('100570499574136985', '100001100001', 'v1.0.0', NULL, 'open', 1, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin');
DELETE FROM `api_test_case` WHERE `id` in ('12df5721-c5e6-a38b-e999-3eafcb992094','12df5721-c5e6-a38b-e999-3eafcb992100','12df5721-c5e6-a38b-e999-3eafcb992233','3ee2ae9c-a680-4ed6-b115-1f6ab8980973','3ee2ae9c-a680-4ed6-b115-1f6ab8980100','3ee2ae9c-a680-4ed6-b115-1f6ab8980589');
DELETE FROM `api_test_case` WHERE `id` in ('12df5721-c5e6-a38b-e999-3eafcb992094','12df5721-c5e6-a38b-e999-3eafcb992100','12df5721-c5e6-a38b-e999-3eafcb992233','3ee2ae9c-a680-4ed6-b115-1f6ab8980973','3ee2ae9c-a680-4ed6-b115-1f6ab8980100','3ee2ae9c-a680-4ed6-b115-1f6ab8980589','3ee2ae9c-a680-4ed6-b115-1f6ab8980553','3ee2ae9c-a680-4ed6-b115-1f6ab8980104','3ee2ae9c-a680-4ed6-b115-1f6ab8980545');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992094', '查询windows主机', 'P0', 100002001, NULL, 'PENDING', NULL, '10001', 10000, '100001100001', '1001', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992100', '查询windows主机', 'P0', 100002002, NULL, 'PENDING', NULL, '10002', 10000, '100001100001', '1001', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('12df5721-c5e6-a38b-e999-3eafcb992233', '查询windows主机', 'P0', 100002003, NULL, 'PENDING', NULL, '10003', 10000, '100001100001', '1002', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980973', '查询Linux主机', 'P0', 100002004, NULL, 'PENDING', NULL, '10004', 10000, '100001100001', '1002', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980100', '查询Linux主机', 'P0', 100002005, NULL, 'PENDING', NULL, '10005', 10000, '100001100001', '1003', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980589', '查询Linux主机', 'P0', 100002006, NULL, 'PENDING', NULL, '10006', 10000, '100001100001', '1004', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980553', '查询Linux主机', 'P0', 100002007, NULL, 'PENDING', NULL, '10007', 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980104', '查询Linux主机', 'P0', 100002008, NULL, 'PENDING', NULL, '10008', 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
INSERT INTO `api_test_case` (`id`, `name`, `priority`, `num`, `tags`, `status`, `last_report_status`, `last_report_id`, `pos`, `project_id`, `api_definition_id`, `version_id`, `environment_id`, `create_time`, `create_user`, `update_time`, `update_user`, `delete_time`, `delete_user`, `deleted`) VALUES ('3ee2ae9c-a680-4ed6-b115-1f6ab8980545', '查询Linux主机', 'P0', 100002009, NULL, 'PENDING', NULL, NULL, 10000, '100001100001', '1005', '100570499574136985', 'admin', 1699500298164, 'admin', 1699500298164, 'admin', NULL, NULL, b'0');
DELETE FROM `api_report` WHERE `id` in ('10001','10002','10003','10004','10005','10006');
DELETE FROM `api_report` WHERE `id` in ('10001','10002','10003','10004','10005','10006','10007','10008','10009');
INSERT INTO `api_report` (`id`, `name`, `resource_id`, `create_time`, `update_time`, `create_user`, `update_user`, `deleted`, `status`, `start_time`, `end_time`, `run_mode`, `pool_id`, `trigger_mode`, `version_id`, `project_id`, `integrated_report_id`, `integrated`) VALUES ('10001', '报告001', 'resource_id_10001', 1680624405386, 1680624405386, 'admin', 'admin', b'0', 'SUCCESS', 1680624405386, 1680624405386, 'API', 'pol_id_100001', 'hand', NULL, '100001100001', 'NONE', b'0');
INSERT INTO `api_report` (`id`, `name`, `resource_id`, `create_time`, `update_time`, `create_user`, `update_user`, `deleted`, `status`, `start_time`, `end_time`, `run_mode`, `pool_id`, `trigger_mode`, `version_id`, `project_id`, `integrated_report_id`, `integrated`) VALUES ('10002', '报告002', 'resource_id_10001', 1680624405386, 1680624405386, 'admin', 'admin', b'0', 'ERROR', 1680624405386, 1680624405386, 'API', 'pol_id_100001', 'hand', NULL, '100001100001', 'NONE', b'0');
INSERT INTO `api_report` (`id`, `name`, `resource_id`, `create_time`, `update_time`, `create_user`, `update_user`, `deleted`, `status`, `start_time`, `end_time`, `run_mode`, `pool_id`, `trigger_mode`, `version_id`, `project_id`, `integrated_report_id`, `integrated`) VALUES ('10003', '报告003', 'resource_id_10001', 1680624405386, 1680624405386, 'admin', 'admin', b'0', 'FAKE_ERROR', 1680624405386, 1680624405386, 'API', 'pol_id_100001', 'hand', NULL, '100001100001', 'NONE', b'0');
INSERT INTO `api_report` (`id`, `name`, `resource_id`, `create_time`, `update_time`, `create_user`, `update_user`, `deleted`, `status`, `start_time`, `end_time`, `run_mode`, `pool_id`, `trigger_mode`, `version_id`, `project_id`, `integrated_report_id`, `integrated`) VALUES ('10004', '报告004', 'resource_id_10001', 1680624405386, 1680624405386, 'admin', 'admin', b'0', 'SUCCESS', 1680624405386, 1680624405386, 'API', 'pol_id_100001', 'hand', NULL, '100001100001', 'NONE', b'0');
INSERT INTO `api_report` (`id`, `name`, `resource_id`, `create_time`, `update_time`, `create_user`, `update_user`, `deleted`, `status`, `start_time`, `end_time`, `run_mode`, `pool_id`, `trigger_mode`, `version_id`, `project_id`, `integrated_report_id`, `integrated`) VALUES ('10005', '报告005', 'resource_id_10001', 1680624405386, 1680624405386, 'admin', 'admin', b'0', 'ERROR', 1680624405386, 1680624405386, 'API', 'pol_id_100001', 'hand', NULL, '100001100001', 'NONE', b'0');
INSERT INTO `api_report` (`id`, `name`, `resource_id`, `create_time`, `update_time`, `create_user`, `update_user`, `deleted`, `status`, `start_time`, `end_time`, `run_mode`, `pool_id`, `trigger_mode`, `version_id`, `project_id`, `integrated_report_id`, `integrated`) VALUES ('10006', '报告006', 'resource_id_10001', 1680624405386, 1680624405386, 'admin', 'admin', b'0', 'SUCCESS', 1680624405386, 1680624405386, 'API', 'pol_id_100001', 'hand', NULL, '100001100001', 'NONE', b'0');
INSERT INTO `api_report` (`id`, `name`, `resource_id`, `create_time`, `update_time`, `create_user`, `update_user`, `deleted`, `status`, `start_time`, `end_time`, `run_mode`, `pool_id`, `trigger_mode`, `version_id`, `project_id`, `integrated_report_id`, `integrated`) VALUES ('10007', '报告004', 'resource_id_10001', 1680624405386, 1680624405386, 'admin', 'admin', b'0', 'SUCCESS', 1680624405386, 1680624405386, 'API', 'pol_id_100001', 'hand', NULL, '100001100001', 'NONE', b'0');
INSERT INTO `api_report` (`id`, `name`, `resource_id`, `create_time`, `update_time`, `create_user`, `update_user`, `deleted`, `status`, `start_time`, `end_time`, `run_mode`, `pool_id`, `trigger_mode`, `version_id`, `project_id`, `integrated_report_id`, `integrated`) VALUES ('10008', '报告005', 'resource_id_10001', 1680624405386, 1680624405386, 'admin', 'admin', b'0', 'ERROR', 1680624405386, 1680624405386, 'API', 'pol_id_100001', 'hand', NULL, '100001100001', 'NONE', b'0');
DELETE FROM `api_definition_module` WHERE `id` = '10001';
INSERT INTO `api_definition_module` (`id`, `name`, `protocol`, `parent_id`, `project_id`, `pos`, `create_time`, `update_time`, `update_user`, `create_user`) VALUES ('10001', 'module1', 'HTTP', 'NONE', '100001100001', 10, 0, 0, 'admin', 'admin');

View File

@ -82,14 +82,14 @@ public class OrganizationStatusFlowSettingService extends BaseStatusFlowSettingS
if (request.getEnable()) {
List<StatusDefinition> projectStatusDefinitions = subStatusItems.stream().map(statusItem -> {
StatusDefinition statusDefinition = new StatusDefinition();
statusDefinition.setStatusId(((StatusItem) statusItem).getId());
statusDefinition.setStatusId(statusItem.getId());
statusDefinition.setDefinitionId(request.getDefinitionId());
return statusDefinition;
}).toList();
baseStatusDefinitionService.batchAdd(projectStatusDefinitions);
} else {
List<String> projectStatusIds = subStatusItems.stream()
.map(statusItem -> ((StatusItem) statusItem).getId())
.map(StatusItem::getId)
.toList();
baseStatusDefinitionService.deleteByStatusIdsAndDefinitionId(projectStatusIds, request.getDefinitionId());
}
@ -149,9 +149,9 @@ public class OrganizationStatusFlowSettingService extends BaseStatusFlowSettingS
public void addRefProjectStatusItem(String orgId, StatusItem orgStatusItem) {
List<String> projectIds = baseProjectMapper.getProjectIdByOrgId(orgId);
SubListUtils.dealForSubList(projectIds, 200, (subProjectIds) -> {
List projectStatusItems = subProjectIds.stream().map(projectId -> {
List<StatusItem> projectStatusItems = subProjectIds.stream().map(projectId -> {
StatusItem statusItem = BeanUtils.copyBean(new StatusItem(), orgStatusItem);
statusItem.setScopeId((String) projectId);
statusItem.setScopeId(projectId);
statusItem.setRefId(orgStatusItem.getId());
statusItem.setScopeType(TemplateScopeType.PROJECT.name());
return statusItem;
@ -311,4 +311,4 @@ public class OrganizationStatusFlowSettingService extends BaseStatusFlowSettingS
}
return statusItems;
}
}
}