瀏覽代碼

增加保存场站数据时 对装机容量进行的判断

王鸿臣 1 年之前
父節點
當前提交
8dc848e910
共有 1 個文件被更改,包括 9 次插入7 次删除
  1. 9 7
      backend/src/main/java/com/jiayue/ssi/controller/ElectricFieldController.java

+ 9 - 7
backend/src/main/java/com/jiayue/ssi/controller/ElectricFieldController.java

@@ -17,12 +17,12 @@ import org.springframework.web.bind.annotation.*;
 
 
 /**
-* 场站接口
-*
-* @author xsl
-* @since 2023/03/13
-*/
- @RestController
+ * 场站接口
+ *
+ * @author xsl
+ * @since 2023/03/13
+ */
+@RestController
 @RequestMapping("/electricField")
 @Slf4j
 public class ElectricFieldController {
@@ -76,7 +76,9 @@ public class ElectricFieldController {
 
 
             String pattern = "^[0-9]{1,8}+\\.{0,1}[0-9]{0,2}$";
-            if (!electricField.getCapacity().toString().matches(pattern)){
+            if (electricField.getCapacity() == null) {
+                return ResponseVO.fail("装机容量不能为空!");
+            } else if (!electricField.getCapacity().toString().matches(pattern)) {
                 return ResponseVO.fail("装机容量整数位不能超过8位,小数位不能超过2位!");
             }