refactor: 修改资源池列表查询时校验的逻辑 (#6056)

* refactor: 修改资源池列表查询时校验的逻辑


Co-authored-by: Captain.B <bin@fit2cloud.com>
This commit is contained in:
metersphere-bot 2021-09-09 12:07:40 +08:00 committed by GitHub
parent 3c0d9ababd
commit 1ad1c8afe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -16,11 +16,11 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
@ -38,7 +38,6 @@ public class NodeResourcePoolService {
@Resource
private TestResourceMapper testResourceMapper;
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public boolean validate(TestResourcePoolDTO testResourcePool) {
if (CollectionUtils.isEmpty(testResourcePool.getResources())) {
MSException.throwException(Translator.get("no_nodes_message"));
@ -82,9 +81,12 @@ public class NodeResourcePoolService {
}
private void deleteTestResources(Collection<String> ids) {
for (String deletedResourceId : ids) {
testResourceMapper.deleteByPrimaryKey(deletedResourceId);
if (CollectionUtils.isEmpty(ids)) {
return;
}
TestResourceExample example = new TestResourceExample();
example.createCriteria().andIdIn(new ArrayList<>(ids));
testResourceMapper.deleteByExample(example);
}
private List<TestResource> getResourcesFromDB(TestResourcePoolDTO testResourcePool) {

View File

@ -218,8 +218,9 @@ public class TestResourcePoolService {
continue;
}
try {
updateTestResourcePool(pool);
} catch (MSException e) {
validateTestResourcePool(pool);
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
pool.setStatus(INVALID.name());
pool.setUpdateTime(System.currentTimeMillis());
testResourcePoolMapper.updateByPrimaryKeySelective(pool);

@ -1 +1 @@
Subproject commit ca9bd63b69870cb3f937719fa1addcfe2f732b38
Subproject commit 4f28d1b94c09361c5645fcbe16eacc5ea6477539