体检项目新增增加验证项目编码是否重复 重复返回999

This commit is contained in:
lxd 2025-02-14 17:38:53 +08:00
parent 0625aee311
commit bf96597c85

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.inspect.service.inspectitems;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -29,6 +30,14 @@ public class InspectitemsServiceImpl implements InspectitemsService {
@Override
public Integer createINSPECTITEMSinspectitems(InspectitemsSaveReqVO createReqVO) {
//验证itemCode是否存在
QueryWrapper<InspectitemsDO> wrapper = new QueryWrapper<>();
wrapper.eq("itemCode", createReqVO.getItemCode());
boolean exists = iNSPECTITEMSinspectitemsMapper.selectCount(wrapper) > 0;
if(exists)
{
return 999;
}
// 插入
InspectitemsDO iNSPECTITEMSinspectitems = BeanUtils.toBean(createReqVO, InspectitemsDO.class);
iNSPECTITEMSinspectitemsMapper.insert(iNSPECTITEMSinspectitems);
@ -55,7 +64,7 @@ public class InspectitemsServiceImpl implements InspectitemsService {
private void validateINSPECTITEMSinspectitemsExists(Integer id) {
if (iNSPECTITEMSinspectitemsMapper.selectById(id) == null) {
throw new IllegalArgumentException("数据已存在");
}
}