Переглянути джерело

编辑站点 增加站点名称 用户名错误提示

lqc 5 роки тому
батько
коміт
5114ae47bc

+ 4 - 2
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxStationController.java

@@ -65,17 +65,19 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
+        FosterwxStation oldVO = fosterwxStationService.getById(editHandle.getRaw().getId());
 
         // 判断站点名是否存在
         LambdaQueryWrapper<FosterwxStation> fosterwxStationLambdaQueryWrapper = new LambdaQueryWrapper<>();
         fosterwxStationLambdaQueryWrapper.eq(FosterwxStation::getStationName, editHandle.getRaw().getStationName());
-        if (fosterwxStationService.count(fosterwxStationLambdaQueryWrapper) > 0) {
+        if (!editHandle.getRaw().getStationName().equals(oldVO.getStationName()) &&
+                fosterwxStationService.count(fosterwxStationLambdaQueryWrapper) > 0) {
             return AjaxResult.error("站点名重复");
         }
         //判断用户名是否存在
         fosterwxStationLambdaQueryWrapper = new LambdaQueryWrapper<>();
         fosterwxStationLambdaQueryWrapper.eq(FosterwxStation::getLoginUsername, editHandle.getRaw().getLoginUsername());
-        if (fosterwxStationService.count(fosterwxStationLambdaQueryWrapper) > 0) {
+        if (!editHandle.getRaw().getLoginUsername().equals(oldVO.getLoginUsername()) && fosterwxStationService.count(fosterwxStationLambdaQueryWrapper) > 0) {
             return AjaxResult.error("用户名重复");
         }