From f8d10f2702453e8273673750b6032a4c28d4974b Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Fri, 12 Aug 2022 10:36:46 +0800 Subject: [PATCH] =?UTF-8?q?App=E7=AB=AF=E8=AF=8A=E6=96=AD=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E4=B8=8A=E4=BC=A0JSON=E8=A7=A3=E6=9E=90=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TRecordServiceImpl.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java index 70043c4..72eb33c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.system.service.impl; +import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.exception.ServiceException; @@ -13,6 +14,8 @@ import com.ruoyi.system.domain.resp.TRecordResp; import com.ruoyi.system.mapper.TRecordMapper; import com.ruoyi.system.service.ITRecordService; import org.apache.commons.collections4.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -28,6 +31,8 @@ import java.util.stream.Collectors; @Service public class TRecordServiceImpl implements ITRecordService { + private static final Logger logger = LoggerFactory.getLogger(TRecordServiceImpl.class); + @Autowired private TRecordMapper tRecordMapper; @@ -78,13 +83,18 @@ public class TRecordServiceImpl implements ITRecordService public int updateTRecord(TRecord tRecord) { // 处理无图片信息 - if (tRecord.getAiResult() != null) { - JSONObject jsonObject = JSONObject.parseObject(tRecord.getAiResult()); - tRecord.setAiResult2(noPicture(jsonObject)); - } - if (tRecord.getUpdateResult() != null) { - JSONObject jsonObject = JSONObject.parseObject(tRecord.getUpdateResult()); - tRecord.setUpdateResult2(noPicture(jsonObject)); + try { + if (tRecord.getAiResult() != null) { + JSONObject jsonObject = JSONObject.parseObject(tRecord.getAiResult()); + tRecord.setAiResult2(noPicture(jsonObject)); + } + if (tRecord.getUpdateResult() != null) { + JSONObject jsonObject = JSONObject.parseObject(tRecord.getUpdateResult()); + tRecord.setUpdateResult2(noPicture(jsonObject)); + } + } catch (JSONException jsonException) { + logger.error("Json 解析异常,请检查入参。"); + throw new ServiceException("Json 解析异常,请检查入参。"); } tRecord.setUpdateTime(DateUtils.getNowDate()); return tRecordMapper.updateTRecord(tRecord);