From 15960e93d95cf4c278db08066f6be63740afda0d Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Sat, 6 May 2023 23:58:36 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=907.6.0=E3=80=91=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E5=BC=95=E7=94=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../log/file/FileLogManagerServiceImpl.java | 16 ++++++++-------- .../scanner/devops/DefaultDevOpsReportImpl.java | 8 ++++---- .../service/impl/SysSmsInfoServiceImpl.java | 11 +++++------ 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/kernel-d-log/log-sdk-file/src/main/java/cn/stylefeng/roses/kernel/log/file/FileLogManagerServiceImpl.java b/kernel-d-log/log-sdk-file/src/main/java/cn/stylefeng/roses/kernel/log/file/FileLogManagerServiceImpl.java index 379209de0..cb469c7e8 100644 --- a/kernel-d-log/log-sdk-file/src/main/java/cn/stylefeng/roses/kernel/log/file/FileLogManagerServiceImpl.java +++ b/kernel-d-log/log-sdk-file/src/main/java/cn/stylefeng/roses/kernel/log/file/FileLogManagerServiceImpl.java @@ -32,6 +32,7 @@ import cn.stylefeng.roses.kernel.auth.api.context.LoginContext; import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; import cn.stylefeng.roses.kernel.log.api.LogManagerApi; import cn.stylefeng.roses.kernel.log.api.exception.LogException; +import cn.stylefeng.roses.kernel.log.api.exception.enums.LogExceptionEnum; import cn.stylefeng.roses.kernel.log.api.pojo.manage.LogManagerRequest; import cn.stylefeng.roses.kernel.log.api.pojo.record.LogRecordDTO; import com.alibaba.fastjson.JSON; @@ -49,7 +50,6 @@ import static cn.stylefeng.roses.kernel.log.api.constants.LogConstants.DEFAULT_B import static cn.stylefeng.roses.kernel.log.api.constants.LogConstants.DEFAULT_PAGE_SIZE; import static cn.stylefeng.roses.kernel.log.api.constants.LogFileConstants.FILE_CONTRACT_SYMBOL; import static cn.stylefeng.roses.kernel.log.api.constants.LogFileConstants.FILE_SUFFIX; -import static cn.stylefeng.roses.kernel.log.api.exception.enums.LogExceptionEnum.*; /** * 文件日志读取管理实现类 @@ -84,12 +84,12 @@ public class FileLogManagerServiceImpl implements LogManagerApi { // 文件日志,必须有AppName,否则文件太多太大 if (ObjectUtil.isEmpty(logManagerParam.getAppName())) { - throw new LogException(APP_NAME_NOT_EXIST); + throw new LogException(LogExceptionEnum.APP_NAME_NOT_EXIST); } // 文件日志,必须有开始时间,否则文件太多太大 if (ObjectUtil.isEmpty(logManagerParam.getBeginDate())) { - throw new LogException(BEGIN_DATETIME_NOT_EXIST); + throw new LogException(LogExceptionEnum.BEGIN_DATETIME_NOT_EXIST); } // 获取文件路径 @@ -127,17 +127,17 @@ public class FileLogManagerServiceImpl implements LogManagerApi { // 删除操作,必须有appName if (ObjectUtil.isEmpty(logManagerParam.getAppName())) { - throw new LogException(APP_NAME_NOT_EXIST); + throw new LogException(LogExceptionEnum.APP_NAME_NOT_EXIST); } // 删除操作,必须有appName if (ObjectUtil.isEmpty(logManagerParam.getBeginDate())) { - throw new LogException(BEGIN_DATETIME_NOT_EXIST); + throw new LogException(LogExceptionEnum.BEGIN_DATETIME_NOT_EXIST); } // 文件日志,必须有结束时间,否则文件太多太大 if (ObjectUtil.isEmpty(logManagerParam.getEndDate())) { - throw new LogException(END_DATETIME_NOT_EXIST); + throw new LogException(LogExceptionEnum.END_DATETIME_NOT_EXIST); } // 计算开始和结束两个时间之间的所有日期 @@ -161,12 +161,12 @@ public class FileLogManagerServiceImpl implements LogManagerApi { // 文件日志,必须有AppName,否则文件太多太大 if (ObjectUtil.isEmpty(logManagerRequest.getAppName())) { - throw new LogException(APP_NAME_NOT_EXIST); + throw new LogException(LogExceptionEnum.APP_NAME_NOT_EXIST); } // 文件日志,必须有开始时间,否则文件太多太大 if (ObjectUtil.isEmpty(logManagerRequest.getBeginDate())) { - throw new LogException(BEGIN_DATETIME_NOT_EXIST); + throw new LogException(LogExceptionEnum.BEGIN_DATETIME_NOT_EXIST); } // 获取文件路径 diff --git a/kernel-d-scanner/scanner-sdk-scanner/src/main/java/cn/stylefeng/roses/kernel/scanner/devops/DefaultDevOpsReportImpl.java b/kernel-d-scanner/scanner-sdk-scanner/src/main/java/cn/stylefeng/roses/kernel/scanner/devops/DefaultDevOpsReportImpl.java index 9acfdcc8b..ea7d8dfa4 100644 --- a/kernel-d-scanner/scanner-sdk-scanner/src/main/java/cn/stylefeng/roses/kernel/scanner/devops/DefaultDevOpsReportImpl.java +++ b/kernel-d-scanner/scanner-sdk-scanner/src/main/java/cn/stylefeng/roses/kernel/scanner/devops/DefaultDevOpsReportImpl.java @@ -10,6 +10,7 @@ import cn.stylefeng.roses.kernel.jwt.JwtTokenOperator; import cn.stylefeng.roses.kernel.jwt.api.pojo.config.JwtConfig; import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData; import cn.stylefeng.roses.kernel.scanner.api.DevOpsReportApi; +import cn.stylefeng.roses.kernel.scanner.api.constants.ScannerConstants; import cn.stylefeng.roses.kernel.scanner.api.exception.ScannerException; import cn.stylefeng.roses.kernel.scanner.api.exception.enums.DevOpsExceptionEnum; import cn.stylefeng.roses.kernel.scanner.api.pojo.devops.DevOpsReportProperties; @@ -20,7 +21,6 @@ import com.alibaba.fastjson.JSON; import java.util.HashMap; import java.util.List; -import static cn.stylefeng.roses.kernel.scanner.api.constants.ScannerConstants.*; /** * 运维平台资源汇报过程 @@ -40,14 +40,14 @@ public class DefaultDevOpsReportImpl implements DevOpsReportApi { } // 组装请求DevOps平台的地址 - String devopsReportUrl = serverHost + DEVOPS_REQUEST_PATH; + String devopsReportUrl = serverHost + ScannerConstants.DEVOPS_REQUEST_PATH; // jwt token生成 String projectInteractionSecretKey = devOpsReportProperties.getProjectInteractionSecretKey(); Long tokenValidityPeriodSeconds = devOpsReportProperties.getTokenValidityPeriodSeconds(); JwtConfig jwtConfig = new JwtConfig(); jwtConfig.setJwtSecret(projectInteractionSecretKey); - jwtConfig.setExpiredSeconds(ObjectUtil.isNotEmpty(tokenValidityPeriodSeconds) ? tokenValidityPeriodSeconds : DEVOPS_REPORT_TIMEOUT_SECONDS); + jwtConfig.setExpiredSeconds(ObjectUtil.isNotEmpty(tokenValidityPeriodSeconds) ? tokenValidityPeriodSeconds : ScannerConstants.DEVOPS_REPORT_TIMEOUT_SECONDS); JwtTokenOperator jwtTokenOperator = new JwtTokenOperator(jwtConfig); String jwtToken = jwtTokenOperator.generateToken(new HashMap<>()); @@ -58,7 +58,7 @@ public class DefaultDevOpsReportImpl implements DevOpsReportApi { // 进行post请求,汇报资源 HttpRequest httpRequest = HttpUtil.createPost(devopsReportUrl); httpRequest.body(JSON.toJSONString(devOpsReportResourceParam)); - httpRequest.setConnectionTimeout(Convert.toInt(DEVOPS_REPORT_CONNECTION_TIMEOUT_SECONDS * 1000)); + httpRequest.setConnectionTimeout(Convert.toInt(ScannerConstants.DEVOPS_REPORT_CONNECTION_TIMEOUT_SECONDS * 1000)); ResponseData responseData = null; HttpResponse execute = httpRequest.execute(); String body = execute.body(); diff --git a/kernel-d-sms/sms-business-validation/src/main/java/cn/stylefeng/roses/kernel/sms/modular/service/impl/SysSmsInfoServiceImpl.java b/kernel-d-sms/sms-business-validation/src/main/java/cn/stylefeng/roses/kernel/sms/modular/service/impl/SysSmsInfoServiceImpl.java index 2fa055df5..c7b64e95a 100644 --- a/kernel-d-sms/sms-business-validation/src/main/java/cn/stylefeng/roses/kernel/sms/modular/service/impl/SysSmsInfoServiceImpl.java +++ b/kernel-d-sms/sms-business-validation/src/main/java/cn/stylefeng/roses/kernel/sms/modular/service/impl/SysSmsInfoServiceImpl.java @@ -24,7 +24,6 @@ */ package cn.stylefeng.roses.kernel.sms.modular.service.impl; -import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; @@ -35,6 +34,7 @@ import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; import cn.stylefeng.roses.kernel.security.api.ImageCaptchaApi; import cn.stylefeng.roses.kernel.sms.api.SmsSenderApi; import cn.stylefeng.roses.kernel.sms.api.exception.SmsException; +import cn.stylefeng.roses.kernel.sms.api.exception.enums.SmsExceptionEnum; import cn.stylefeng.roses.kernel.sms.api.expander.SmsConfigExpander; import cn.stylefeng.roses.kernel.sms.modular.entity.SysSms; import cn.stylefeng.roses.kernel.sms.modular.enums.SmsSendStatusEnum; @@ -60,7 +60,6 @@ import java.util.List; import java.util.Map; import static cn.stylefeng.roses.kernel.sms.api.constants.SmsConstants.SMS_CODE_PARAM_NAME; -import static cn.stylefeng.roses.kernel.sms.api.exception.enums.SmsExceptionEnum.*; /** * 系统短信接口实现类 @@ -177,7 +176,7 @@ public class SysSmsInfoServiceImpl extends ServiceImpl imp // 如果找不到记录,提示验证失败 if (ObjectUtil.isEmpty(sysSmsList)) { - throw new SmsException(SMS_VALIDATE_ERROR_NOT_EXISTED_RECORD); + throw new SmsException(SmsExceptionEnum.SMS_VALIDATE_ERROR_NOT_EXISTED_RECORD); } // 获取最近发送的第一条 @@ -185,18 +184,18 @@ public class SysSmsInfoServiceImpl extends ServiceImpl imp // 先判断状态是不是失效的状态 if (SmsSendStatusEnum.INVALID.getCode().equals(sysSms.getStatusFlag())) { - throw new SmsException(SMS_VALIDATE_ERROR_INVALIDATE_STATUS); + throw new SmsException(SmsExceptionEnum.SMS_VALIDATE_ERROR_INVALIDATE_STATUS); } // 如果验证码和传过来的不一致 if (!sysSmsVerifyParam.getCode().equals(sysSms.getValidateCode())) { - throw new SmsException(SMS_VALIDATE_ERROR_INVALIDATE_CODE); + throw new SmsException(SmsExceptionEnum.SMS_VALIDATE_ERROR_INVALIDATE_CODE); } // 判断是否超时 Date invalidTime = sysSms.getInvalidTime(); if (ObjectUtil.isEmpty(invalidTime) || new Date().after(invalidTime)) { - throw new SmsException(SMS_VALIDATE_ERROR_INVALIDATE_TIME); + throw new SmsException(SmsExceptionEnum.SMS_VALIDATE_ERROR_INVALIDATE_TIME); } // 验证成功把短信设置成失效