Forráskód Böngészése

修改能耗接口不能新增数据

wuweihao 3 éve
szülő
commit
6e4360fa7d

+ 2 - 2
gis_cms/src/main/java/com/gis/cms/controller/EnergyController.java

@@ -38,8 +38,8 @@ public class EnergyController {
     }
 
 
-    @WebControllerLog(description = "整体概况-新增/编辑", addDb = true)
-    @ApiOperation(value = "新增/编辑", notes = NOTE_STR)
+    @WebControllerLog(description = "整体概况-编辑", addDb = true)
+    @ApiOperation(value = "编辑", notes = NOTE_STR)
     @PostMapping("save")
     public Result save(@Valid @RequestBody BaseDto param) {
         return entityService.saveEntity(param);

+ 18 - 13
gis_cms/src/main/java/com/gis/cms/service/impl/EnergyServiceImpl.java

@@ -54,21 +54,26 @@ public class EnergyServiceImpl extends ServiceImpl<EnergyMapper, EnergyEntity> i
     @Override
     public Result saveEntity(BaseDto param) {
         Long id = param.getId();
-        EnergyEntity entity = null;
-        if (id == null){
-            entity = new EnergyEntity();
-        } else {
-            entity = this.getById(id);
-            if (entity == null){
-                String msg = "对象id不存在 ";
-                log.error(msg + id);
-                return Result.failure(msg);
-            }
-        }
+//        EnergyEntity entity = null;
+//        if (id == null){
+//            entity = new EnergyEntity();
+//        } else {
+//            entity = this.getById(id);
+//            if (entity == null){
+//                String msg = "对象id不存在 ";
+//                log.error(msg + id);
+//                return Result.failure(msg);
+//            }
+//        }
+        EnergyEntity entity = this.getById(id);
+        if (entity == null) {
+            String msg = "对象id不存在 ";
+            log.error(msg + id);
+            return Result.failure(msg);
 
+        }
         BeanUtils.copyProperties(param, entity);
-        this.saveOrUpdate(entity);
-
+        this.updateById(entity);
         return Result.success();
     }