对名称、型号、规格的长度进行校验
This commit is contained in:
@@ -332,6 +332,15 @@ public class ExceptionConstants {
|
||||
//EXCEL中存在重复的条码
|
||||
public static final int MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_CODE = 80000021;
|
||||
public static final String MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_MSG = "抱歉,EXCEL中存在重复的条码,具体条码为:%s";
|
||||
//名称长度超出
|
||||
public static final int MATERIAL_NAME_OVER_CODE = 8000022;
|
||||
public static final String MATERIAL_NAME_OVER_MSG = "第%s行名称长度超出100个字符";
|
||||
//规格长度超出
|
||||
public static final int MATERIAL_STANDARD_OVER_CODE = 8000023;
|
||||
public static final String MATERIAL_STANDARD_OVER_MSG = "第%s行规格长度超出100个字符";
|
||||
//型号长度超出
|
||||
public static final int MATERIAL_MODEL_OVER_CODE = 8000024;
|
||||
public static final String MATERIAL_MODEL_OVER_MSG = "第%s行型号长度超出100个字符";
|
||||
|
||||
/**
|
||||
* 单据信息
|
||||
|
||||
@@ -576,6 +576,21 @@ public class MaterialService {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_EMPTY_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_NAME_EMPTY_MSG, i+1));
|
||||
}
|
||||
//名称长度超出
|
||||
if(name.length()>100) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_OVER_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_NAME_OVER_MSG, i+1));
|
||||
}
|
||||
//规格长度超出
|
||||
if(StringUtil.isNotEmpty(standard) && standard.length()>100) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STANDARD_OVER_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_STANDARD_OVER_MSG, i+1));
|
||||
}
|
||||
//型号长度超出
|
||||
if(StringUtil.isNotEmpty(model) && model.length()>100) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_MODEL_OVER_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_MODEL_OVER_MSG, i+1));
|
||||
}
|
||||
//基本单位为空
|
||||
if(StringUtil.isEmpty(unit)) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
|
||||
|
||||
Reference in New Issue
Block a user