mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-25 00:31:53 +08:00
【功能修复】框架:操作日志异步记录时,丢失 request 的问题
This commit is contained in:
parent
c8ebad91dd
commit
12ce87b305
@ -11,7 +11,6 @@ import com.mzt.logapi.service.ILogRecordService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -29,7 +28,6 @@ public class LogRecordServiceImpl implements ILogRecordService {
|
||||
private OperateLogApi operateLogApi;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void record(LogRecord logRecord) {
|
||||
OperateLogCreateReqDTO reqDTO = new OperateLogCreateReqDTO();
|
||||
try {
|
||||
@ -42,7 +40,7 @@ public class LogRecordServiceImpl implements ILogRecordService {
|
||||
fillRequestFields(reqDTO);
|
||||
|
||||
// 2. 异步记录日志
|
||||
operateLogApi.createOperateLog(reqDTO);
|
||||
operateLogApi.createOperateLogAsync(reqDTO);
|
||||
} catch (Throwable ex) {
|
||||
// 由于 @Async 异步调用,这里打印下日志,更容易跟进
|
||||
log.error("[record][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
|
||||
|
@ -92,7 +92,7 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
|
||||
List<Map<String, Object>> result = selectMaps(new QueryWrapper<CrmReceivableDO>()
|
||||
.select("contract_id, SUM(price) AS total_price")
|
||||
.in("audit_status", CrmAuditStatusEnum.DRAFT.getStatus(), // 草稿 + 审批中 + 审批通过
|
||||
CrmAuditStatusEnum.PROCESS, CrmAuditStatusEnum.APPROVE.getStatus())
|
||||
CrmAuditStatusEnum.PROCESS.getStatus(), CrmAuditStatusEnum.APPROVE.getStatus())
|
||||
.groupBy("contract_id")
|
||||
.in("contract_id", contractIds));
|
||||
// 获得金额
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogPageReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogRespDTO;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
/**
|
||||
* 操作日志 API 接口
|
||||
@ -20,6 +21,16 @@ public interface OperateLogApi {
|
||||
*/
|
||||
void createOperateLog(@Valid OperateLogCreateReqDTO createReqDTO);
|
||||
|
||||
/**
|
||||
* 【异步】创建操作日志
|
||||
*
|
||||
* @param createReqDTO 请求
|
||||
*/
|
||||
@Async
|
||||
default void createOperateLogAsync(OperateLogCreateReqDTO createReqDTO) {
|
||||
createOperateLog(createReqDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定模块的指定数据的操作日志分页
|
||||
*
|
||||
|
@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
|
||||
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
|
||||
import com.fhs.core.trans.anno.TransMethodResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -26,7 +25,6 @@ public class OperateLogApiImpl implements OperateLogApi {
|
||||
private OperateLogService operateLogService;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void createOperateLog(OperateLogCreateReqDTO createReqDTO) {
|
||||
operateLogService.createOperateLog(createReqDTO);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user