fix:客户信息重名校验
parent
6b9263ca1b
commit
7bcc08ff0e
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.sip.mapper;
|
||||
|
||||
import com.ruoyi.sip.domain.CustomerInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -63,4 +64,8 @@ public interface CustomerInfoMapper
|
|||
public int selectCountByCode(CustomerInfo customerInfo);
|
||||
|
||||
int selectMaxByPrefix(String province);
|
||||
|
||||
int selectCountByName(@Param("name") String name,
|
||||
@Param("excludeId") Long excludeId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService
|
|||
if (i > 0) {
|
||||
throw new ServiceException("客户编码已存在");
|
||||
}
|
||||
i = customerInfoMapper.selectCountByName(customerInfo.getCustomerName(), null);
|
||||
if (i > 0) {
|
||||
throw new ServiceException("最终客户名称已存在");
|
||||
}
|
||||
return customerInfoMapper.insertCustomerInfo(customerInfo);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
|
|
@ -147,6 +151,10 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService
|
|||
if (count > 0) {
|
||||
throw new ServiceException("客户编码已存在");
|
||||
}
|
||||
count = customerInfoMapper.selectCountByName(customerInfo.getCustomerName(), customerInfo.getId());
|
||||
if (count > 0) {
|
||||
throw new ServiceException("最终客户名称已存在");
|
||||
}
|
||||
projectInfoMapper.updateCustomerCodeByCode(oldCustomerInfo.getCustomerCode(), newCustomerCode);
|
||||
return customerInfoMapper.updateCustomerInfo(customerInfo);
|
||||
} finally {
|
||||
|
|
@ -154,7 +162,10 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
int count = customerInfoMapper.selectCountByName(customerInfo.getCustomerName(), customerInfo.getId());
|
||||
if (count > 0) {
|
||||
throw new ServiceException("最终客户名称已存在");
|
||||
}
|
||||
return customerInfoMapper.updateCustomerInfo(customerInfo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,4 +155,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectCountByName" resultType="java.lang.Integer">
|
||||
select count(1) from customer_info
|
||||
where customer_name = #{name} and status=0
|
||||
<if test="excludeId != null">
|
||||
and id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue