demand: tms-客户管理-报关清关级别维护-改为校验客户名称头尾不能有空格

committer: heyu
This commit is contained in:
aike 2025-10-15 13:59:57 +08:00
parent df2c3e86df
commit 36bd1744b9

View File

@ -9,7 +9,6 @@
package com.xdadan.erp.emis.service.impl;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -22,9 +21,6 @@ public class EmisCustomsLevelServiceImpl implements IEmisCustomsLevelService {
@Autowired
private EmisCustomsLevelMapper emisCustomsLevelMapper;
private static final Pattern INVALID_NAME_PATTERN = Pattern
.compile("[\\s`~!@#$%^&*()+=|{}':;',\\[\\]\\.<>/?!¥…()—【】‘;:”“’。,、?]");
/**
* 将前端传来的name转换为对应的code
*
@ -110,8 +106,8 @@ public class EmisCustomsLevelServiceImpl implements IEmisCustomsLevelService {
if (StringUtils.isBlank(po.getCustomerName())) {
throw new IllegalArgumentException("客户名称不能为空");
}
if (INVALID_NAME_PATTERN.matcher(po.getCustomerName()).find()) {
throw new IllegalArgumentException("客户名称不能包含空格或特殊符号");
if (!po.getCustomerName().equals(po.getCustomerName().trim())) {
throw new IllegalArgumentException("客户名称头尾不能有空格");
}
if (StringUtils.isBlank(po.getCategory()) || !("1".equals(po.getCategory()) || "2".equals(po.getCategory())
|| "3".equals(po.getCategory()) || "4".equals(po.getCategory()))) {