分包公司数据校验
This commit is contained in:
@ -14,7 +14,6 @@ import org.dromara.common.core.utils.ObjectUtils;
|
|||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
|
||||||
import org.dromara.contractor.domain.SubConstructionUser;
|
import org.dromara.contractor.domain.SubConstructionUser;
|
||||||
import org.dromara.contractor.domain.SubContractor;
|
import org.dromara.contractor.domain.SubContractor;
|
||||||
import org.dromara.contractor.domain.dto.contractor.SubContractorCreateReq;
|
import org.dromara.contractor.domain.dto.contractor.SubContractorCreateReq;
|
||||||
@ -118,16 +117,19 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
|||||||
contractor.setFiles(fileMapStr);
|
contractor.setFiles(fileMapStr);
|
||||||
// 数据校验
|
// 数据校验
|
||||||
validEntityBeforeSave(contractor);
|
validEntityBeforeSave(contractor);
|
||||||
String name = req.getName();
|
|
||||||
Long count = this.lambdaQuery().eq(SubContractor::getName, name).count();
|
|
||||||
if (count > 0) {
|
|
||||||
throw new ServiceException("分包单位名称重复", HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
Long projectId = req.getProjectId();
|
Long projectId = req.getProjectId();
|
||||||
BusProject project = projectService.getById(projectId);
|
BusProject project = projectService.getById(projectId);
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
|
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
String name = req.getName();
|
||||||
|
Long count = this.lambdaQuery()
|
||||||
|
.eq(SubContractor::getName, name)
|
||||||
|
.eq(SubContractor::getProjectId, projectId)
|
||||||
|
.count();
|
||||||
|
if (count > 0) {
|
||||||
|
throw new ServiceException("分包单位名称重复", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
// 操作数据库
|
// 操作数据库
|
||||||
boolean save = this.save(contractor);
|
boolean save = this.save(contractor);
|
||||||
if (!save) {
|
if (!save) {
|
||||||
@ -160,7 +162,10 @@ public class SubContractorServiceImpl extends ServiceImpl<SubContractorMapper, S
|
|||||||
}
|
}
|
||||||
// 判断名称是否重复
|
// 判断名称是否重复
|
||||||
if (!oldContractor.getName().equals(req.getName())) {
|
if (!oldContractor.getName().equals(req.getName())) {
|
||||||
Long count = this.lambdaQuery().eq(SubContractor::getName, req.getName()).count();
|
Long count = this.lambdaQuery()
|
||||||
|
.eq(SubContractor::getName, req.getName())
|
||||||
|
.eq(SubContractor::getProjectId, req.getProjectId())
|
||||||
|
.count();
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
throw new ServiceException("分包单位名称重复", HttpStatus.BAD_REQUEST);
|
throw new ServiceException("分包单位名称重复", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user