Commit 8d10a035 authored by 刘帅阳's avatar 刘帅阳

修改bug

parent 0c18ec3b
......@@ -245,8 +245,11 @@ public class CmsPriceClickServiceImpl extends ServiceImpl<CmsPriceClickRepositor
cmsPriceClicksDTOList.stream().filter(Objects::nonNull).collect(Collectors.toList());
//
Pattern pattern = Pattern.compile("[0-9]*");
//行数
Integer sum = 0;
//添加前先遍历一下那些数据有问题
for (CmsPriceClickDTO cmsPriceClickDTO : cmsPriceClicksDTOList) {
sum++;
//用户名去空格
cmsPriceClickDTO.setUserName(cmsPriceClickDTO.getUserName().replaceAll("\\s+", "").trim());
cmsPriceClickDTO.setUserName(cmsPriceClickDTO.getUserName().replaceAll("\\p{Zs}", "").trim());
......@@ -262,40 +265,35 @@ public class CmsPriceClickServiceImpl extends ServiceImpl<CmsPriceClickRepositor
//1.用户身份证号不能为空 18位 且必须为数字类型
if (cmsPriceClickDTO.getIdCard() == null || cmsPriceClickDTO.getIdCard().length() != 18) {
// throw new CyServiceException(AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getCode(), AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getMessage() + ":" + cmsPriceClickDTO.getIdCard());
throw new CyServiceException(AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getCode(), AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getMessage());
throw new CyServiceException(AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getCode(), sum + "行" + AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getMessage());
}
//2.用户手机号 11位
if (cmsPriceClickDTO.getPhone() == null || cmsPriceClickDTO.getPhone().length() != 11) {
// System.out.println("+++" + cmsPriceClickDTO.getPhone() + "+++");
// throw new CyServiceException(AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getCode(), AdminUserInfoExceptionEnums.PHONE_LENGTH_ERROR.getMessage() + ":" + cmsPriceClickDTO.getPhone());
throw new CyServiceException(AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getCode(), AdminUserInfoExceptionEnums.PHONE_LENGTH_ERROR.getMessage());
throw new CyServiceException(AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getCode(), sum + "行" + AdminUserInfoExceptionEnums.PHONE_LENGTH_ERROR.getMessage());
}
//3.银行卡号不能为空 19位
if (cmsPriceClickDTO.getBankCard() == null || cmsPriceClickDTO.getBankCard().length() > 30) {
// throw new CyServiceException(AdminUserInfoExceptionEnums.ID_LENGTH_ERROR.getCode(), AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getMessage() + ":" + cmsPriceClickDTO.getBankCard());
throw new CyServiceException(AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getCode(), cmsPriceClickDTO.getIdCard() + AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getMessage());
throw new CyServiceException(AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getCode(), sum + "行" + AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getMessage());
}
//4.推广次数不能为空
if (cmsPriceClickDTO.getClickThroughRate() == null) {
throw new CyServiceException(AdminUserInfoExceptionEnums.CLICK_THROUGH_RATE_ERROR.getCode(), AdminUserInfoExceptionEnums.CLICK_THROUGH_RATE_ERROR.getMessage());
throw new CyServiceException(AdminUserInfoExceptionEnums.CLICK_THROUGH_RATE_ERROR.getCode(), sum + "行" + AdminUserInfoExceptionEnums.CLICK_THROUGH_RATE_ERROR.getMessage());
}
//5.价格不能为空
if (cmsPriceClickDTO.getPrice() == null) {
throw new CyServiceException(AdminUserInfoExceptionEnums.PRICE_ERROR.getCode(), AdminUserInfoExceptionEnums.PRICE_ERROR.getMessage());
throw new CyServiceException(AdminUserInfoExceptionEnums.PRICE_ERROR.getCode(), sum + "行" + AdminUserInfoExceptionEnums.PRICE_ERROR.getMessage());
}
//手机号只能是数字
if (!pattern.matcher(cmsPriceClickDTO.getPhone()).matches()) {
throw new CyServiceException(AdminUserInfoExceptionEnums.PHONE_LENGTH_ERROR.getCode(), AdminUserInfoExceptionEnums.PHONE_LENGTH_ERROR.getMessage());
throw new CyServiceException(AdminUserInfoExceptionEnums.PHONE_LENGTH_ERROR.getCode(), sum + "行" + AdminUserInfoExceptionEnums.PHONE_LENGTH_ERROR.getMessage());
}
//银行卡号只能是数字
if (!pattern.matcher(cmsPriceClickDTO.getBankCard()).matches()) {
// System.out.println("++" + cmsPriceClickDTO.getBankCard() + "+++");
throw new CyServiceException(AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getCode(), AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getMessage());
throw new CyServiceException(AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getCode(), sum + "行" + AdminUserInfoExceptionEnums.BANK_LENGTH_ERROR.getMessage());
}
//用户名称不能为空且 不能大于30
if (cmsPriceClickDTO.getUserName() == null || cmsPriceClickDTO.getUserName().length() > 30) {
throw new CyServiceException(AdminUserInfoExceptionEnums.USER_NAME_LENGTH_ERROR.getCode(), AdminUserInfoExceptionEnums.USER_NAME_LENGTH_ERROR.getMessage());
throw new CyServiceException(AdminUserInfoExceptionEnums.USER_NAME_LENGTH_ERROR.getCode(), sum + "行" + AdminUserInfoExceptionEnums.USER_NAME_LENGTH_ERROR.getMessage());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment