From f225c678db097194de435851db553d78d17f0ed6 Mon Sep 17 00:00:00 2001 From: yaowanxin <3588231647@qq.com> Date: 星期一, 04 八月 2025 09:11:34 +0800 Subject: [PATCH] 调整方法返回格式 --- cnas-device/src/main/java/com/ruoyi/device/controller/WeightController.java | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cnas-device/src/main/java/com/ruoyi/device/controller/WeightController.java b/cnas-device/src/main/java/com/ruoyi/device/controller/WeightController.java index 8c3dfd0..4590de3 100644 --- a/cnas-device/src/main/java/com/ruoyi/device/controller/WeightController.java +++ b/cnas-device/src/main/java/com/ruoyi/device/controller/WeightController.java @@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSONArray; +import com.ruoyi.common.core.domain.Result; import com.ruoyi.common.utils.RedisUtil; import com.ruoyi.device.constant.DCResistanceMqttConstants; import com.ruoyi.device.dto.WeightRequestDto; @@ -19,21 +20,13 @@ public class WeightController { @PostMapping("/handleWeights") - public ResponseEntity<String> handleWeights(@RequestBody WeightRequestDto weightRequest) { - try { + public Result handleWeights(@RequestBody WeightRequestDto weightRequest) { List<Double> weightList = weightRequest.getWeights(); // 鍦ㄨ繖閲屾坊鍔犳暟鎹鐞嗛�昏緫锛屼緥濡傛墦鍗般�佸瓨鍌ㄥ埌鏁版嵁搴撶瓑 System.out.println("鎺ユ敹鍒扮殑鏁版嵁: " + weightList); processValueDataStream(weightList, WeightRequestDto.DENSITY); - - // 澶勭悊鎴愬姛杩斿洖 200 鐘舵�佺爜鍜屾秷鎭� - return ResponseEntity.ok("鏁版嵁澶勭悊鎴愬姛"); - } catch (Exception e) { - // 澶勭悊澶辫触杩斿洖 500 鐘舵�佺爜鍜岄敊璇秷鎭� - return ResponseEntity.internalServerError().body("鏁版嵁澶勭悊澶辫触: " + e.getMessage()); - } + return Result.success(); } - private void processValueDataStream(List<Double> weightList, String dataStream) { // 澶勭悊 weightList 涓� null 鐨勬儏鍐� if (weightList == null) { -- Gitblit v1.9.3