refactor: 修改资源池列表查询时校验的逻辑 (#6056)
* refactor: 修改资源池列表查询时校验的逻辑 Co-authored-by: Captain.B <bin@fit2cloud.com>
This commit is contained in:
parent
3c0d9ababd
commit
1ad1c8afe3
|
@ -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) {
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue