Bladeren bron

批量上传新增字符限制验证

anderx 5 jaren geleden
bovenliggende
commit
10cca3db75
1 gewijzigde bestanden met toevoegingen van 13 en 0 verwijderingen
  1. 13 0
      src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

+ 13 - 0
src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

@@ -999,6 +999,7 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 	        	int lastCellNum = row.getLastCellNum();
 		        //循环当前行 cellNum = (firstCellNum+1) 则是除开第一例
 	        	Demand in=new Demand();
+	        	List<String> list2 =new ArrayList<>();
 		        for(int cellNum = (firstCellNum); cellNum < lastCellNum;cellNum++){
 			        Cell cell = row.getCell(cellNum);
 			    	try {
@@ -1014,6 +1015,9 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 							break;
 						case 3:
 							in.setProblemDes(FileUtils.getCellValue(cell));
+							if (in.getProblemDes().length()>512) {
+								list2.add(in.getName());
+							}
 							break;
 						case 4:
 							in.setKeyword(FileUtils.getCellValue(cell));
@@ -1035,6 +1039,15 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 			    		throw new BusinessException(new Error("表格第"+(rowNum+1)+"行输入内容不正确。"));
 					}
 		        }
+		        if (!list2.isEmpty()) {
+		        	StringBuffer str=new StringBuffer("[");
+		        	for (String string : list2) {
+						str.append(string+",");
+					}
+		        	str.deleteCharAt(str.length()-1);
+		        	str.append("]");
+		        	throw new BusinessException(new Error("名称"+str+"内容过长,请控制在512个字符内"));
+				}
 		        in.setDeletedSign(DeleteStatus.UNDELETE.getCode());
 		        in.setEmployerId(TokenManager.getAdminId());
 		        in.setCreateTime(date);