refactor: 查询资源池节点时按照创建时间排序

This commit is contained in:
CaptainB 2022-11-03 11:21:29 +08:00 committed by 刘瑞斌
parent 4a658221a3
commit 8d59cfaeb9
6 changed files with 10 additions and 0 deletions

View File

@ -49,6 +49,7 @@ public class ResourcePoolCalculation {
List<String> poolIds = pools.stream().map(pool -> pool.getId()).collect(Collectors.toList());
TestResourceExample resourceExample = new TestResourceExample();
resourceExample.createCriteria().andTestResourcePoolIdIn(poolIds);
resourceExample.setOrderByClause("create_time");
List<TestResource> testResources = testResourceMapper.selectByExampleWithBLOBs(resourceExample);
return testResources;
}

View File

@ -85,6 +85,7 @@ public class ExtApiTaskService extends TaskService {
List<String> poolIds = pools.stream().map(pool -> pool.getId()).collect(Collectors.toList());
TestResourceExample resourceExample = new TestResourceExample();
resourceExample.createCriteria().andTestResourcePoolIdIn(poolIds);
resourceExample.setOrderByClause("create_time");
List<TestResource> testResources = testResourceMapper.selectByExampleWithBLOBs(resourceExample);
for (TestResource testResource : testResources) {
String configuration = testResource.getConfiguration();

View File

@ -53,6 +53,7 @@ public class BaseTestResourcePoolService {
testResourcePools.forEach(pool -> {
TestResourceExample example2 = new TestResourceExample();
example2.createCriteria().andTestResourcePoolIdEqualTo(pool.getId());
example2.setOrderByClause("create_time");
List<TestResource> testResources = testResourceMapper.selectByExampleWithBLOBs(example2);
TestResourcePoolDTO testResourcePoolDTO = new TestResourcePoolDTO();
try {
@ -77,6 +78,7 @@ public class BaseTestResourcePoolService {
if (pool != null) {
TestResourceExample example = new TestResourceExample();
example.createCriteria().andTestResourcePoolIdEqualTo(pool.getId());
example.setOrderByClause("create_time");
List<TestResource> resources = testResourceMapper.selectByExampleWithBLOBs(example);
List<DetailColumn> columns = ReflexObjectUtil.getColumns(pool, SystemReference.poolColumns);
if (pool.getType().equals("NODE")) {

View File

@ -19,12 +19,14 @@ public class BaseTestResourceService {
public List<TestResource> getTestResourceList(String testResourcePoolId) {
TestResourceExample testResourceExample = new TestResourceExample();
testResourceExample.createCriteria().andTestResourcePoolIdEqualTo(testResourcePoolId);
testResourceExample.setOrderByClause("create_time");
return testResourceMapper.selectByExampleWithBLOBs(testResourceExample);
}
public List<TestResource> getResourcesByPoolId(String resourcePoolId) {
TestResourceExample example = new TestResourceExample();
example.createCriteria().andTestResourcePoolIdEqualTo(resourcePoolId);
example.setOrderByClause("create_time");
return testResourceMapper.selectByExampleWithBLOBs(example);
}

View File

@ -99,6 +99,7 @@ public class NodeResourcePoolService {
private List<TestResource> getResourcesFromDB(TestResourcePoolDTO testResourcePool) {
TestResourceExample example = new TestResourceExample();
example.createCriteria().andTestResourcePoolIdEqualTo(testResourcePool.getId());
example.setOrderByClause("create_time");
return testResourceMapper.selectByExample(example);
}

View File

@ -112,6 +112,7 @@ public class TestResourcePoolService {
BeanUtils.copyProperties(testResourcePoolDTO, testResourcePool);
TestResourceExample example2 = new TestResourceExample();
example2.createCriteria().andTestResourcePoolIdEqualTo(poolId);
example2.setOrderByClause("create_time");
List<TestResource> testResources = testResourceMapper.selectByExampleWithBLOBs(example2);
testResourcePoolDTO.setResources(testResources);
if (validateTestResourcePool(testResourcePoolDTO)) {
@ -172,6 +173,7 @@ public class TestResourcePoolService {
testResourcePools.forEach(pool -> {
TestResourceExample example2 = new TestResourceExample();
example2.createCriteria().andTestResourcePoolIdEqualTo(pool.getId());
example2.setOrderByClause("create_time");
List<TestResource> testResources = testResourceMapper.selectByExampleWithBLOBs(example2);
TestResourcePoolDTO testResourcePoolDTO = new TestResourcePoolDTO();
try {
@ -242,6 +244,7 @@ public class TestResourcePoolService {
if (pool != null) {
TestResourceExample example = new TestResourceExample();
example.createCriteria().andTestResourcePoolIdEqualTo(pool.getId());
example.setOrderByClause("create_time");
List<TestResource> resources = testResourceMapper.selectByExampleWithBLOBs(example);
List<DetailColumn> columns = ReflexObjectUtil.getColumns(pool, SystemReference.poolColumns);
if (pool.getType().equals("NODE")) {