完善客商模块
This commit is contained in:
@@ -73,7 +73,7 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
private static final int STATUS_ENABLED = 1;
|
||||
private static final int STATUS_DISABLED = 2;
|
||||
private static final int CODE_MAX_LENGTH = 20;
|
||||
private static final int NAME_MAX_LENGTH = 100;
|
||||
private static final int NAME_MAX_LENGTH = 50;
|
||||
private static final int RAILWAY_LINE_MAX_LENGTH = 100;
|
||||
private static final int REGION_NAME_MAX_LENGTH = 128;
|
||||
private static final int REGION_CODE_MAX_LENGTH = 32;
|
||||
@@ -175,7 +175,7 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
try {
|
||||
return new BigDecimal(trimValue);
|
||||
} catch (NumberFormatException exception) {
|
||||
throw new ServiceException(name + "格式不正确");
|
||||
throw new ServiceException(name + "范围不正确");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,16 +216,16 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
throw new ServiceException("TMIS国标编码为5位数字");
|
||||
}
|
||||
if (Func.isEmpty(railwayStation.getTelegraphCode())) {
|
||||
throw new ServiceException("电报码不能为空");
|
||||
throw new ServiceException("电报码格式不正确或已存在");
|
||||
}
|
||||
if (!TELEGRAPH_CODE_PATTERN.matcher(railwayStation.getTelegraphCode()).matches()) {
|
||||
throw new ServiceException("电报码为3位大写字母");
|
||||
throw new ServiceException("电报码格式不正确或已存在");
|
||||
}
|
||||
if (Func.isEmpty(railwayStation.getName())) {
|
||||
throw new ServiceException("车站名称不能为空");
|
||||
throw new ServiceException("请输入车站名称");
|
||||
}
|
||||
validateLength(railwayStation.getCode(), CODE_MAX_LENGTH, "编码不能超过20字");
|
||||
validateLength(railwayStation.getName(), NAME_MAX_LENGTH, "车站名称不能超过100字");
|
||||
validateLength(railwayStation.getName(), NAME_MAX_LENGTH, "请输入车站名称");
|
||||
// validateLength(railwayStation.getRailwayLine(), RAILWAY_LINE_MAX_LENGTH, "所属铁路线路不能超过100字");
|
||||
validateLength(railwayStation.getProvinceName(), REGION_NAME_MAX_LENGTH, "所属省份不能超过128字");
|
||||
validateLength(railwayStation.getCityName(), REGION_NAME_MAX_LENGTH, "所属城市不能超过128字");
|
||||
@@ -234,15 +234,21 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
validateLength(railwayStation.getRegionName(), REGION_NAME_MAX_LENGTH, "行政区划不能超过128字");
|
||||
validateLength(railwayStation.getDetailAddress(), DETAIL_ADDRESS_MAX_LENGTH, "详细地址不能超过255字");
|
||||
validateLength(railwayStation.getRemark(), REMARK_MAX_LENGTH, "备注不能超过200字");
|
||||
if (Func.isEmpty(railwayStation.getProvinceCode()) || Func.isEmpty(railwayStation.getCityCode()) || Func.isEmpty(railwayStation.getDistrictCode())) {
|
||||
throw new ServiceException("请选择省份、城市和区县");
|
||||
if (Func.isEmpty(railwayStation.getProvinceCode())) {
|
||||
throw new ServiceException("请选择所属省份");
|
||||
}
|
||||
if (Func.isEmpty(railwayStation.getCityCode())) {
|
||||
throw new ServiceException("请选择所属城市");
|
||||
}
|
||||
if (Func.isEmpty(railwayStation.getDistrictCode())) {
|
||||
throw new ServiceException("请选择所属区县");
|
||||
}
|
||||
validateCoordinate(railwayStation.getLongitude(), MIN_LONGITUDE, MAX_LONGITUDE, "经度");
|
||||
validateCoordinate(railwayStation.getLatitude(), MIN_LATITUDE, MAX_LATITUDE, "纬度");
|
||||
validateDataSource(railwayStation.getDataSource());
|
||||
validateStatus(railwayStation.getStatus());
|
||||
validateUnique(railwayStation, RailwayStation::getTmisCode, railwayStation.getTmisCode(), "该TMIS编码已存在");
|
||||
validateUnique(railwayStation, RailwayStation::getTelegraphCode, railwayStation.getTelegraphCode(), "该电报码已存在");
|
||||
validateUnique(railwayStation, RailwayStation::getTelegraphCode, railwayStation.getTelegraphCode(), "电报码格式不正确或已存在");
|
||||
validateUnique(railwayStation, RailwayStation::getCode, railwayStation.getCode(), "该编码已存在");
|
||||
}
|
||||
|
||||
@@ -257,7 +263,7 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
.eq(Region::getName, railwayStation.getProvinceName()), false);
|
||||
}
|
||||
if (Func.isEmpty(province)) {
|
||||
throw new ServiceException("请选择省份");
|
||||
throw new ServiceException("请选择所属省份");
|
||||
}
|
||||
|
||||
Region city = null;
|
||||
@@ -270,7 +276,7 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
.eq(Region::getName, railwayStation.getCityName()), false);
|
||||
}
|
||||
if (Func.isEmpty(city)) {
|
||||
throw new ServiceException("请选择城市");
|
||||
throw new ServiceException("请选择所属城市");
|
||||
}
|
||||
if (!Objects.equals(city.getParentCode(), province.getCode())) {
|
||||
throw new ServiceException("所属城市与所属省份不匹配");
|
||||
@@ -290,7 +296,7 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
.eq(Region::getName, railwayStation.getDistrictName()), false);
|
||||
}
|
||||
if (Func.isEmpty(district)) {
|
||||
throw new ServiceException("请选择区县");
|
||||
throw new ServiceException("请选择所属区县");
|
||||
}
|
||||
if (!Objects.equals(district.getParentCode(), city.getCode())) {
|
||||
throw new ServiceException("所属区县与所属城市不匹配");
|
||||
@@ -306,7 +312,7 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
return;
|
||||
}
|
||||
if (value.compareTo(min) < 0 || value.compareTo(max) > 0) {
|
||||
throw new ServiceException(name + ("经度".equals(name) ? "范围为 -180 到 180" : "范围为 -90 到 90"));
|
||||
throw new ServiceException(name + "范围不正确");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user