From 7452400add9b626046603841656c687f90007201 Mon Sep 17 00:00:00 2001 From: liulu Date: Mon, 28 Oct 2024 16:06:28 +0800 Subject: [PATCH] fix --- .../java/com/sunyard/chsm/enums/KeyUsage.java | 2 +- .../impl/CryptoServiceServiceImpl.java | 3 ++ .../service/impl/DeviceGroupServiceImpl.java | 2 ++ .../chsm/service/impl/DeviceServiceImpl.java | 3 +- .../service/impl/KeyTemplateServiceImpl.java | 2 ++ .../exception/GlobalExceptionResolver.java | 32 ++----------------- .../serviceimpl/LogDownloadServiceImpl.java | 2 +- .../src/main/resources/application.yml | 5 +-- .../src/main/resources/logback.xml | 26 +++++++-------- 9 files changed, 30 insertions(+), 47 deletions(-) diff --git a/chsm-common/src/main/java/com/sunyard/chsm/enums/KeyUsage.java b/chsm-common/src/main/java/com/sunyard/chsm/enums/KeyUsage.java index 34bfe49..341012a 100644 --- a/chsm-common/src/main/java/com/sunyard/chsm/enums/KeyUsage.java +++ b/chsm-common/src/main/java/com/sunyard/chsm/enums/KeyUsage.java @@ -56,7 +56,7 @@ public enum KeyUsage { public static boolean hasUsage(int nowUsage, KeyUsage usage) { - return (nowUsage & usage.value) == 1; + return (nowUsage & usage.value) > 0; } } diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/CryptoServiceServiceImpl.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/CryptoServiceServiceImpl.java index 94d3eeb..c3172a6 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/CryptoServiceServiceImpl.java +++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/CryptoServiceServiceImpl.java @@ -2,6 +2,7 @@ package com.sunyard.chsm.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.sunyard.chsm.dto.CryptoServiceDTO; import com.sunyard.chsm.enums.ApiFunEnum; @@ -105,6 +106,7 @@ public class CryptoServiceServiceImpl implements CryptoServiceService { checkName(save.getName()); CryptoService service = new CryptoService(); + service.setId(IdWorker.getId()); service.setName(save.getName()); DeviceGroup deviceGroup = spDeviceGroupMapper.selectById(save.getDeviceGroupId()); @@ -180,6 +182,7 @@ public class CryptoServiceServiceImpl implements CryptoServiceService { .filter(it -> apiList.contains(it.getCode())) .map(it -> { CryptoServiceApi serviceApi = new CryptoServiceApi(); + serviceApi.setId(IdWorker.getId()); serviceApi.setCryptoServiceId(serviceId); serviceApi.setApiGroup(it.getGroup().getCode()); serviceApi.setApiCode(it.getCode()); diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceGroupServiceImpl.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceGroupServiceImpl.java index ac96407..053ea10 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceGroupServiceImpl.java +++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceGroupServiceImpl.java @@ -2,6 +2,7 @@ package com.sunyard.chsm.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.sunyard.chsm.dto.DeviceGroupDTO; import com.sunyard.chsm.mapper.SpDeviceGroupMapper; @@ -84,6 +85,7 @@ public class DeviceGroupServiceImpl implements DeviceGroupService { checkName(save.getName()); DeviceGroup add = new DeviceGroup(); + add.setId(IdWorker.getId()); add.setName(save.getName()); add.setRemark(save.getRemark()); add.setCreateTime(LocalDateTime.now()); diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceServiceImpl.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceServiceImpl.java index 7211fff..2658e0c 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceServiceImpl.java +++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceServiceImpl.java @@ -2,6 +2,7 @@ package com.sunyard.chsm.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.sunyard.chsm.dto.DeviceDTO; import com.sunyard.chsm.enums.ManufacturerEnum; @@ -123,7 +124,7 @@ public class DeviceServiceImpl implements DeviceService { Device device = new Device(); BeanUtils.copyProperties(save, device); - device.setId(null); + device.setId(IdWorker.getId()); device.setGroupId(0L); device.setGroupName(""); device.setWeight(1); diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/KeyTemplateServiceImpl.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/KeyTemplateServiceImpl.java index ea2143f..38af98d 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/KeyTemplateServiceImpl.java +++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/KeyTemplateServiceImpl.java @@ -2,6 +2,7 @@ package com.sunyard.chsm.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.sunyard.chsm.dto.KeyTemplateDTO; import com.sunyard.chsm.enums.KeyAlg; @@ -78,6 +79,7 @@ public class KeyTemplateServiceImpl implements KeyTemplateService { checkCode(save.getCode()); KeyTemplate add = mapToEntity(save); + add.setId(IdWorker.getId()); add.setCreateTime(LocalDateTime.now()); keyTemplateMapper.insert(add); diff --git a/chsm-web-manage/src/main/java/com/sunyard/ssp/common/exception/GlobalExceptionResolver.java b/chsm-web-manage/src/main/java/com/sunyard/ssp/common/exception/GlobalExceptionResolver.java index 327ff4c..1081f2a 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/ssp/common/exception/GlobalExceptionResolver.java +++ b/chsm-web-manage/src/main/java/com/sunyard/ssp/common/exception/GlobalExceptionResolver.java @@ -1,10 +1,7 @@ package com.sunyard.ssp.common.exception; import com.sunyard.chsm.model.R; -import com.sunyard.ssp.common.Result; -import com.sunyard.ssp.utils.ResultUtil; import lombok.extern.slf4j.Slf4j; -import org.mybatis.spring.MyBatisSystemException; import org.springframework.validation.BindException; import org.springframework.validation.FieldError; import org.springframework.web.bind.MethodArgumentNotValidException; @@ -31,38 +28,15 @@ import java.util.Optional; @RestControllerAdvice public class GlobalExceptionResolver { - /** - * 处理所有不可知异常 - * - * @param e 异常 - * @return json结果 - */ -// @ExceptionHandler(Exception.class) -// @ResponseBody -// public Result handleException(Exception e) { -// // 打印异常堆栈信息 -// return new ResultUtil().setErrorMsg(e.getMessage()); -// } - - /** - * 数据持久层 - */ - @ExceptionHandler(MyBatisSystemException.class) - @ResponseBody - public Result handleMyBatisSystemException(MyBatisSystemException e) { - log.info("数据持久层"); - return new ResultUtil().setErrorMsg(e.getLocalizedMessage()); - } - /** * 校验器 */ @ExceptionHandler(BindException.class) @ResponseBody - public Result handleBindException(BindException e) { - log.info("校验器"); + public R handleBindException(BindException e) { + log.info("校验器异常", e); FieldError fieldError = e.getBindingResult().getFieldError(); - return new ResultUtil().setErrorMsg(fieldError.getDefaultMessage()); + return R.error(400, fieldError.getDefaultMessage()); } @ExceptionHandler(MethodArgumentNotValidException.class) diff --git a/chsm-web-manage/src/main/java/com/sunyard/ssp/modules/monitor/log/serviceimpl/LogDownloadServiceImpl.java b/chsm-web-manage/src/main/java/com/sunyard/ssp/modules/monitor/log/serviceimpl/LogDownloadServiceImpl.java index c23c312..41fe17e 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/ssp/modules/monitor/log/serviceimpl/LogDownloadServiceImpl.java +++ b/chsm-web-manage/src/main/java/com/sunyard/ssp/modules/monitor/log/serviceimpl/LogDownloadServiceImpl.java @@ -17,7 +17,7 @@ import java.util.zip.ZipOutputStream; @Service public class LogDownloadServiceImpl implements LogDownloadService { - private static final String LOG_BASE_PATH = "/app/log/"; + private static final String LOG_BASE_PATH = "./log/"; private static final DateTimeFormatter folderFormatter = DateTimeFormatter.ofPattern("yyyy-MM"); // 用于遍历月份的目录格式 private static final DateTimeFormatter fileFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 用于解析文件名中的日期格式 diff --git a/chsm-web-manage/src/main/resources/application.yml b/chsm-web-manage/src/main/resources/application.yml index c92811f..f943dde 100644 --- a/chsm-web-manage/src/main/resources/application.yml +++ b/chsm-web-manage/src/main/resources/application.yml @@ -62,7 +62,7 @@ mybatis-plus: # 数据库相关配置 db-config: #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID",ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; - id-type: ASSIGN_ID + id-type: AUTO #驼峰下划线转换 table-underline: true #是否开启大写命名,默认不开启 @@ -124,9 +124,10 @@ ignored: - /status/set - /test/setALL #logging: -# config: classpath:log4j2.xml # level: +# root: debug # org.springframework.web: trace +# config: classpath:log4j2.xml monitorSwitch: diff --git a/chsm-web-manage/src/main/resources/logback.xml b/chsm-web-manage/src/main/resources/logback.xml index 6420d3d..0def50d 100644 --- a/chsm-web-manage/src/main/resources/logback.xml +++ b/chsm-web-manage/src/main/resources/logback.xml @@ -19,11 +19,11 @@ ${LOG_HOME}/info.log - ${LOG_HOME}/his/info.%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/%d{yyyy-MM}/INFO-%d{yyyy-MM-dd}_%i.log - 200MB + 10MB - 700 + 30 20GB @@ -37,14 +37,14 @@ - - ${LOG_HOME}/warn.log + + ${LOG_HOME}/debug.log - ${LOG_HOME}/his/warn.%d{yyyy-MM-dd}.%i.log + ${LOG_HOME}/%d{yyyy-MM}/sspweb-DEBUG-%d{yyyy-MM-dd}_%i.log - 200MB + 10MB - 700 + 30 20GB @@ -54,18 +54,18 @@ UTF-8 - WARN + DEBUG ${LOG_HOME}/error.log - ${LOG_HOME}/his/error.%d{yyyy-MM-dd }.%i.log + ${LOG_HOME}/%d{yyyy-MM}/ERROR-%d{yyyy-MM-dd}_%i.log - 200MB + 10MB - 700 + 30 20GB @@ -81,7 +81,7 @@ - +