From 25da9fe119998f7db260dc78ecec3e2eb569ada7 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Mon, 14 Apr 2025 22:09:18 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Anumber=E7=86=9F=E7=9F=A5=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E5=B0=8F=E6=95=B0=E7=82=B9=E5=90=8E=E7=9A=8400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/config/service/impl/ConfigServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java index 78a7b511..7be38a89 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java @@ -171,7 +171,13 @@ public class ConfigServiceImpl implements ConfigService { switch (param.getValueType().toLowerCase()) { case "number": try { - current.put(lastKey, Double.parseDouble(value)); + double doubleValue = Double.parseDouble(value); + // 如果数值是整数形式,则转换为Integer + if (doubleValue == (int) doubleValue) { + current.put(lastKey, (int) doubleValue); + } else { + current.put(lastKey, doubleValue); + } } catch (NumberFormatException e) { current.put(lastKey, value); }