mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 09:03:54 +08:00
fix:参数管理保存json类型出错bug
This commit is contained in:
@@ -39,7 +39,7 @@ public class SysParamsDTO implements Serializable {
|
|||||||
|
|
||||||
@Schema(description = "值类型")
|
@Schema(description = "值类型")
|
||||||
@NotBlank(message = "{sysparams.valuetype.require}", groups = DefaultGroup.class)
|
@NotBlank(message = "{sysparams.valuetype.require}", groups = DefaultGroup.class)
|
||||||
@Pattern(regexp = "^(string|number|boolean|array)$", message = "{sysparams.valuetype.pattern}", groups = DefaultGroup.class)
|
@Pattern(regexp = "^(string|number|boolean|array|json)$", message = "{sysparams.valuetype.pattern}", groups = DefaultGroup.class)
|
||||||
private String valueType;
|
private String valueType;
|
||||||
|
|
||||||
@Schema(description = "备注")
|
@Schema(description = "备注")
|
||||||
|
|||||||
+6
@@ -127,6 +127,12 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||||||
break;
|
break;
|
||||||
case "json":
|
case "json":
|
||||||
try {
|
try {
|
||||||
|
// 首先检查是否以 { 开头,以 } 结尾
|
||||||
|
String trimmedValue = paramValue.trim();
|
||||||
|
if (!trimmedValue.startsWith("{") || !trimmedValue.endsWith("}")) {
|
||||||
|
throw new RenException(ErrorCode.PARAM_JSON_INVALID);
|
||||||
|
}
|
||||||
|
// 然后尝试解析JSON
|
||||||
JsonUtils.parseObject(paramValue, Object.class);
|
JsonUtils.parseObject(paramValue, Object.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RenException(ErrorCode.PARAM_JSON_INVALID);
|
throw new RenException(ErrorCode.PARAM_JSON_INVALID);
|
||||||
|
|||||||
Reference in New Issue
Block a user