From fca26309987919e7acfe7c5417b2e6d38f4dfb32 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Mon, 13 Apr 2026 15:48:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=92=8C=E8=AE=BE=E5=A4=87=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0=20JSON?= =?UTF-8?q?=20=E6=A0=BC=E5=BC=8F=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiot/controller/AiAlgorithmController.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/controller/AiAlgorithmController.java b/src/main/java/com/genersoft/iot/vmp/aiot/controller/AiAlgorithmController.java index 794303ce1..e4b2f0eb4 100644 --- a/src/main/java/com/genersoft/iot/vmp/aiot/controller/AiAlgorithmController.java +++ b/src/main/java/com/genersoft/iot/vmp/aiot/controller/AiAlgorithmController.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.aiot.controller; +import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.aiot.bean.AiAlgorithm; import com.genersoft.iot.vmp.aiot.bean.AiRoiAlgoBind; import com.genersoft.iot.vmp.aiot.service.IAiAlgorithmService; @@ -65,6 +66,14 @@ public class AiAlgorithmController { @PostMapping("/global-params/{algoCode}") public void saveGlobalParams(@PathVariable String algoCode, @RequestBody Map body) { String globalParams = body.get("globalParams"); + if (globalParams == null || globalParams.isBlank()) { + throw new IllegalArgumentException("参数不能为空"); + } + try { + JSON.parseObject(globalParams); + } catch (Exception e) { + throw new IllegalArgumentException("参数不是合法的 JSON: " + e.getMessage()); + } algorithmService.saveGlobalParams(algoCode, globalParams); } @@ -80,6 +89,14 @@ public class AiAlgorithmController { @PathVariable String algoCode, @RequestBody Map body) { String params = body.get("params"); + if (params == null || params.isBlank()) { + throw new IllegalArgumentException("参数不能为空"); + } + try { + JSON.parseObject(params); + } catch (Exception e) { + throw new IllegalArgumentException("参数不是合法的 JSON: " + e.getMessage()); + } algorithmService.updateDeviceAlgoParams(deviceId, algoCode, params); } }