feat: add resource pool inUsed and del org relation
This commit is contained in:
parent
db8626ac0e
commit
d653f9f483
|
@ -6,4 +6,7 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class TestResourcePoolDTO extends TestResourcePool {
|
public class TestResourcePoolDTO extends TestResourcePool {
|
||||||
private TestResourceDTO testResourceDTO;
|
private TestResourceDTO testResourceDTO;
|
||||||
|
|
||||||
|
private Boolean inUsed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,7 @@ import io.metersphere.sdk.dto.TestResourceDTO;
|
||||||
import io.metersphere.sdk.dto.TestResourcePoolDTO;
|
import io.metersphere.sdk.dto.TestResourcePoolDTO;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.*;
|
import io.metersphere.sdk.util.*;
|
||||||
import io.metersphere.system.domain.TestResourcePool;
|
import io.metersphere.system.domain.*;
|
||||||
import io.metersphere.system.domain.TestResourcePoolBlob;
|
|
||||||
import io.metersphere.system.domain.TestResourcePoolExample;
|
|
||||||
import io.metersphere.system.domain.TestResourcePoolOrganization;
|
|
||||||
import io.metersphere.system.mapper.TestResourcePoolBlobMapper;
|
import io.metersphere.system.mapper.TestResourcePoolBlobMapper;
|
||||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
||||||
import io.metersphere.system.mapper.TestResourcePoolOrganizationMapper;
|
import io.metersphere.system.mapper.TestResourcePoolOrganizationMapper;
|
||||||
|
@ -38,6 +35,8 @@ public class TestResourcePoolService {
|
||||||
@Resource
|
@Resource
|
||||||
private TestResourcePoolBlobMapper testResourcePoolBlobMapper;
|
private TestResourcePoolBlobMapper testResourcePoolBlobMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
private TestResourcePoolOrganizationMapper testResourcePoolOrganizationMapper;
|
||||||
|
@Resource
|
||||||
private SqlSessionFactory sqlSessionFactory;
|
private SqlSessionFactory sqlSessionFactory;
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,12 +153,20 @@ public class TestResourcePoolService {
|
||||||
if (testResourcePool == null) {
|
if (testResourcePool == null) {
|
||||||
throw new MSException(Translator.get("test_resource_pool_not_exists"));
|
throw new MSException(Translator.get("test_resource_pool_not_exists"));
|
||||||
}
|
}
|
||||||
|
//删除与组织的关系
|
||||||
|
deleteOrgRelation(testResourcePoolId);
|
||||||
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
||||||
testResourcePool.setEnable(false);
|
testResourcePool.setEnable(false);
|
||||||
testResourcePool.setDeleted(true);
|
testResourcePool.setDeleted(true);
|
||||||
testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool);
|
testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteOrgRelation(String testResourcePoolId) {
|
||||||
|
TestResourcePoolOrganizationExample testResourcePoolOrganizationExample = new TestResourcePoolOrganizationExample();
|
||||||
|
testResourcePoolOrganizationExample.createCriteria().andTestResourcePoolIdEqualTo(testResourcePoolId);
|
||||||
|
testResourcePoolOrganizationMapper.deleteByExample(testResourcePoolOrganizationExample);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateTestResourcePool(TestResourcePoolDTO testResourcePool) {
|
public void updateTestResourcePool(TestResourcePoolDTO testResourcePool) {
|
||||||
checkTestResourcePool(testResourcePool);
|
checkTestResourcePool(testResourcePool);
|
||||||
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
||||||
|
@ -192,6 +199,12 @@ public class TestResourcePoolService {
|
||||||
TestResourcePoolDTO testResourcePoolDTO = new TestResourcePoolDTO();
|
TestResourcePoolDTO testResourcePoolDTO = new TestResourcePoolDTO();
|
||||||
BeanUtils.copyBean(testResourcePoolDTO, pool);
|
BeanUtils.copyBean(testResourcePoolDTO, pool);
|
||||||
testResourcePoolDTO.setTestResourceDTO(testResourceDTO);
|
testResourcePoolDTO.setTestResourceDTO(testResourceDTO);
|
||||||
|
TestResourcePoolOrganizationExample testResourcePoolOrganizationExample = new TestResourcePoolOrganizationExample();
|
||||||
|
testResourcePoolOrganizationExample.createCriteria().andTestResourcePoolIdEqualTo(pool.getId());
|
||||||
|
List<TestResourcePoolOrganization> testResourcePoolOrganizations = testResourcePoolOrganizationMapper.selectByExample(testResourcePoolOrganizationExample);
|
||||||
|
if (pool.getAllOrg() || CollectionUtils.isNotEmpty(testResourcePoolOrganizations)) {
|
||||||
|
testResourcePoolDTO.setInUsed(true);
|
||||||
|
}
|
||||||
testResourcePoolDTOS.add(testResourcePoolDTO);
|
testResourcePoolDTOS.add(testResourcePoolDTO);
|
||||||
});
|
});
|
||||||
return testResourcePoolDTOS;
|
return testResourcePoolDTOS;
|
||||||
|
|
Loading…
Reference in New Issue