Ver Fonte

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

王鸿臣 há 1 ano atrás
pai
commit
8dc848e910

+ 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位!");
             }