diff --git a/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java b/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java index 900bd46..c699797 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java +++ b/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java @@ -2,7 +2,9 @@ package com.java3y.austin.web.controller; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.java3y.austin.common.constant.AustinConstant; +import com.java3y.austin.common.enums.AccountFormat; import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.support.domain.ChannelAccount; import com.java3y.austin.web.annotation.AustinAspect; @@ -48,6 +50,7 @@ public class ChannelAccountController { @PostMapping("/save") @ApiOperation("/保存数据") public ChannelAccount saveOrUpdate(@RequestBody ChannelAccount channelAccount) { + accountConfigPreCheck(channelAccount); if (loginUtils.needLogin() && StrUtil.isBlank(channelAccount.getCreator())) { throw new CommonException(RespStatusEnum.NO_LOGIN.getCode(), RespStatusEnum.NO_LOGIN.getMsg()); } @@ -99,4 +102,14 @@ public class ChannelAccountController { } } + /** + * 检查JSON格式是否正确 + */ + public void accountConfigPreCheck(ChannelAccount channelAccount) throws CommonException{ + try{ + JSON.parseObject(channelAccount.getAccountConfig(), Object.class); + }catch (Exception e){ + throw new CommonException(RespStatusEnum.CLIENT_BAD_PARAMETERS.getCode(), RespStatusEnum.CLIENT_BAD_PARAMETERS.getMsg()); + } + } }