fix: 修复删除问题
This commit is contained in:
@@ -141,6 +141,12 @@ public class CustomerServiceImpl implements CustomerService {
|
|||||||
public void deleteCustomer(Long id) {
|
public void deleteCustomer(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
CustomerDO customerDO = validateCustomerExists(id);
|
CustomerDO customerDO = validateCustomerExists(id);
|
||||||
|
|
||||||
|
List<ProjectDO> projects = projectMapper.selectList(Wrappers.<ProjectDO>lambdaQuery().eq(ProjectDO::getCustomerId, id));
|
||||||
|
if (CollUtil.isNotEmpty(projects)) {
|
||||||
|
throw exception(CUSTOMER_EXISTS_PROJECT);
|
||||||
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
customerMapper.deleteById(id);
|
customerMapper.deleteById(id);
|
||||||
|
|
||||||
@@ -152,10 +158,7 @@ public class CustomerServiceImpl implements CustomerService {
|
|||||||
if (customerDO == null) {
|
if (customerDO == null) {
|
||||||
throw exception(CUSTOMER_NOT_EXISTS);
|
throw exception(CUSTOMER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
List<ProjectDO> projects = projectMapper.selectList(Wrappers.<ProjectDO>lambdaQuery().eq(ProjectDO::getCustomerId, id));
|
|
||||||
if (CollUtil.isNotEmpty(projects)) {
|
|
||||||
throw exception(CUSTOMER_EXISTS_PROJECT);
|
|
||||||
}
|
|
||||||
return customerDO;
|
return customerDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,11 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
public void deleteProject(Long id) {
|
public void deleteProject(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
ProjectDO project = validateProjectExists(id);
|
ProjectDO project = validateProjectExists(id);
|
||||||
|
|
||||||
|
List<LicenseDO> licenses = licenseMapper.selectList(Wrappers.<LicenseDO>lambdaQuery().eq(LicenseDO::getProjectId, project.getId()));
|
||||||
|
if (CollUtil.isNotEmpty(licenses)) {
|
||||||
|
throw exception(PROJECT_EXISTS_LICENSE);
|
||||||
|
}
|
||||||
// 删除
|
// 删除
|
||||||
projectMapper.deleteById(id);
|
projectMapper.deleteById(id);
|
||||||
LogRecordContext.putVariable("project", project);
|
LogRecordContext.putVariable("project", project);
|
||||||
@@ -125,10 +130,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
if (projectDO == null) {
|
if (projectDO == null) {
|
||||||
throw exception(PROJECT_NOT_EXISTS);
|
throw exception(PROJECT_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
List<LicenseDO> licenses = licenseMapper.selectList(Wrappers.<LicenseDO>lambdaQuery().eq(LicenseDO::getProjectId, projectDO.getId()));
|
|
||||||
if (CollUtil.isNotEmpty(licenses)) {
|
|
||||||
throw exception(PROJECT_EXISTS_LICENSE);
|
|
||||||
}
|
|
||||||
return projectDO;
|
return projectDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user