diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java index 239b0f5..7f15e51 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java @@ -387,6 +387,19 @@ public class TablexController extends JeecgController { webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("对应模块填写不能为空"); } + + //判断实体是否已存在 + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(Tablex::getModuleId,voList.get(i).getModuleId()); + Tablex tablex1 = tablexService.getOne(query); + if (tablex1 != null){ + message.put("isError", "true"); + message.put("status","导入失败,第" + (i + 1) + "条的实体已存在"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条的实体已存在"); + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Modulex::getId, moduleId); Modulex modulex = modulexService.getOne(queryWrapper); @@ -407,7 +420,7 @@ public class TablexController extends JeecgController { //判断版本状态 //int verisonStatusInt = verisonStatus.equals("当前") ? 1 : verisonStatus.equals("历史") ? 0 : 3; - //判断版本号,若实体已存在,查找最大的版本号并且版本号+1 + //判断版本号 if(voList.get(i).getVerison() == null || voList.get(i).getVerison().equals("")){ message.put("isError", "true"); message.put("status","导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); @@ -415,30 +428,16 @@ public class TablexController extends JeecgController { webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); } - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(Tablex::getTableName,voList.get(i).getTableName()); - List verisonList = tablexService.list(query); - if (verisonList != null){ - int version = 0; - for(Tablex verisonMax : verisonList){ - if(verisonMax.getVerison() > version){ - version = verisonMax.getVerison(); - } - } - int v = version + 1; - tablex.setVerison(v); - }else { - //判断版本号是否为正整数且长度不能大于5 - if (!voList.get(i).getVerison().matches("^[0-9]*[1-9][0-9]*$") && voList.get(i).getVerison().length() > 5){ - message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!"); - message.put("closeable","true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!"); - } - tablex.setVerison(Integer.valueOf(voList.get(i).getVerison())); - } + //判断版本号是否为正整数且长度不能大于5 + if (!voList.get(i).getVerison().matches("^[0-9]*[1-9][0-9]*$") || voList.get(i).getVerison().length() > 5){ + message.put("isError", "true"); + message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!"); + } + tablex.setVerison(Integer.valueOf(voList.get(i).getVerison())); //判断对应模块 if (modulexId != null && voList.get(i).getModuleId() != null && !voList.get(i).getModuleId().equals("")) { //判断中文名称