From b4d3bc8088736fe64dfaadce25084d72db40968d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=BA=86=E5=90=89?= <51312040@qq.com> Date: Fri, 31 Dec 2021 10:21:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=B9=E6=B3=95=E3=80=81?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../log/enums/EbtpLogBusinessModule.java | 117 ++++++++++++++++-- .../log/service/OperationLogService.java | 31 ++++- .../service/impl/OperationLogServiceImpl.java | 51 +++++++- 3 files changed, 184 insertions(+), 15 deletions(-) diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/enums/EbtpLogBusinessModule.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/enums/EbtpLogBusinessModule.java index 55c0253..e9e63d4 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/enums/EbtpLogBusinessModule.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/enums/EbtpLogBusinessModule.java @@ -12,29 +12,122 @@ package com.chinaunicom.mall.ebtp.common.log.enums; public enum EbtpLogBusinessModule { /** - * 系统日志 + * 项目委托 */ - SYSTEM("system"), + PROJECT_ENTRUST_INIT("project_entrust_init"), + /** + * 询价项目委托 + */ + PROJECT_ENTRUST_INQUIRY_INIT("project_entrust_inquiry_init"), + /** + * 询价项目发布 + */ + PROJECT_INQUIRY_UPDATE("project_inquiry_update"), + /** + * 项目重评审批 + */ + PROJECT_RE_EVALUATION_TASK("project_re_evaluation_task"), + /** + * 项目异常项目失败 + */ + PROJECT_INVITATION_FAIL("project_invitation_fail"), + /** - * 应用程序日志 + * 审批 */ - APPLICATION("application"), + BID_APPROVE("bid_approve"), + /** + * 媒体发布 + */ + BID_SEND_TO_MEDIA("bid_send_to_media"), + /** + * 推送至公告中心 + */ + BID_PUSH_NOTICE_INFO("bid_push_notice_info"), + /** - * 拦截器日志 + * 供应商报名 */ - AOP("aop"), + TENDER_SAVE("tender_save"), + /** + * 修改中标状态 + */ + TENDER_BID_STATUS("tender_bid_status"), + /** + * 开启下一轮复制供应商 + */ + TENDER_COPY_ROUND("tender_copy_round"), + /** + * 招募报名 + */ + TENDER_RECRUIT_SAVE("tender_recruit_save"), + /** + * 招募修改中标状态 + */ + TENDER_RECRUIT_BID_STATUS("tender_recruit_bid_status"), + /** + * 下载记录 + */ + TENDER_UPLOAD_RECORD("tender_upload_record"), + /** + * 上传记录 + */ + TENDER_DOWNLOAD_RECORD("tender_download_record"), + /** + * 修改支付状态 + */ + TENDER_PAY_STATUS("tender_pay_status"), + /** - * 业务日志 + * 上传解压缩 */ - BUSINESS("business"), + DECRYPT_UPLOAD_UNZIP("decrypt_upload_unzip"), + /** + * 开标解密 + */ + DECRYPT("decrypt"), + /** + * 更新解密状态 + */ + DECRYPT_STATUS("decrypt_status"), /** - * 垃圾收集器日志 + * 招募更新解密状态 */ - GC("gc"), + DECRYPT_RECRUIT_STATUS("decrypt_recruit_status"), + + + /** + * 定标推送数据评审室/评审结果/推送通知 + */ + CALIBRATION_PUSH("calibration_push"), + /** + * 定标接收数据确认结果/冻结/终止 + */ + CALIBRATION_RECEIVE("calibration_receive"), + + + /** + * 询价报名 + */ + INQUIRY_REGISTER("inquiry_register"), + /** + * 询价报价 + */ + INQUIRY_OFFER("inquiry_offer"), + + + /** + * 支付请求/查询 + */ + PAY_PUSH("pay_push"), + /** + * 支付结果回调 + */ + PAY_RECEIVE("pay_receive"), /** * 其他 @@ -47,7 +140,7 @@ public enum EbtpLogBusinessModule { return value; } - EbtpLogBusinessModule(String s) { - this.value = s; + EbtpLogBusinessModule(String value) { + this.value = value; } } diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/OperationLogService.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/OperationLogService.java index ae3737e..4a96206 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/OperationLogService.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/OperationLogService.java @@ -28,9 +28,20 @@ public interface OperationLogService { * @param businessModule 所属模块 * @param type 类型 * @param detail 描述 + * @param transactionId 链路id */ - public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, EbtpLogType type, String detail); + public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, EbtpLogType type, String detail, String transactionId); + /** + * 保存日志 + * + * @param message 日志内容 + * @param result 执行结果 + * @param businessModule 所属模块 + * @param type 类型 + * @param transactionId 链路id + */ + public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, EbtpLogType type, String transactionId); /** * 保存日志 @@ -42,5 +53,23 @@ public interface OperationLogService { */ public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, EbtpLogType type); + /** + * 保存日志 + * + * @param message 日志内容 + * @param result 执行结果 + * @param businessModule 所属模块 + */ + public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule); + + /** + * 保存日志 + * + * @param message 日志内容 + * @param result 执行结果 + * @param businessModule 所属模块 + * @param transactionId 链路id + */ + public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, String transactionId); } \ No newline at end of file diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/impl/OperationLogServiceImpl.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/impl/OperationLogServiceImpl.java index 6575408..5ba0eb7 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/impl/OperationLogServiceImpl.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/impl/OperationLogServiceImpl.java @@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; +import java.util.Optional; import static com.chinaunicom.mall.ebtp.cloud.security.starter.common.Constants.AUTHORIZATION_HEADER; @@ -70,7 +71,7 @@ public class OperationLogServiceImpl implements OperationLogService { } operationLog.setId(PropertyUtils.getSnowflakeId()) - .setTransactionId(MDC.get(CommonConstants.TRANSACTION_ID)) + .setTransactionId(Optional.ofNullable(operationLog.getTransactionId()).orElseGet(() -> MDC.get(CommonConstants.TRANSACTION_ID))) .setServiceName(serviceName); kafkaProducer.send(JsonUtils.objectToJson(operationLog)); } @@ -80,17 +81,22 @@ public class OperationLogServiceImpl implements OperationLogService { * 保存日志 * * @param message 日志内容 + * @param result 执行结果 * @param businessModule 所属模块 * @param type 类型 * @param detail 描述 + * @param transactionId 链路id */ @Override - public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, EbtpLogType type, String detail) { + public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, EbtpLogType type, String detail, String transactionId) { this.addOperationLog(new OperationLog() .setCreateTime(DateUtil.now()) .setContent(message) + .setResult(result) + .setBusinessModule(businessModule.getValue()) .setLevel("business") .setDescribe(detail) + .setTransactionId(transactionId) .setOperationType(type.getValue())); } @@ -98,6 +104,21 @@ public class OperationLogServiceImpl implements OperationLogService { * 保存日志 * * @param message 日志内容 + * @param result 执行结果 + * @param businessModule 所属模块 + * @param type 类型 + * @param transactionId 链路id + */ + @Override + public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, EbtpLogType type, String transactionId) { + addOperationLog(message, result, businessModule, type, null, transactionId); + } + + /** + * 保存日志 + * + * @param message 日志内容 + * @param result 执行结果 * @param businessModule 所属模块 * @param type 类型 */ @@ -105,4 +126,30 @@ public class OperationLogServiceImpl implements OperationLogService { public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, EbtpLogType type) { addOperationLog(message, result, businessModule, type, null); } + + /** + * 保存日志 + * + * @param message 日志内容 + * @param result 执行结果 + * @param businessModule 所属模块 + */ + @Override + public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule) { + addOperationLog(message, result, businessModule, EbtpLogType.UNKNOWN); + } + + + /** + * 保存日志 + * + * @param message 日志内容 + * @param result 执行结果 + * @param businessModule 所属模块 + * @param transactionId 链路id + */ + @Override + public void addOperationLog(String message, boolean result, EbtpLogBusinessModule businessModule, String transactionId) { + addOperationLog(message, result, businessModule, EbtpLogType.UNKNOWN, transactionId); + } }