package com.sinata.appointment.service; import com.sinata.appointment.entity.BizOpLog; import com.sinata.appointment.mapper.BizOpLogMapper; import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.slf4j.MDC; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class OpLogApplicationService { public static final String MDC_TRACE = "traceId"; private final BizOpLogMapper bizOpLogMapper; @Async public void recordAsync( Long operatorUserId, String module, String action, String resourceType, String resourceId, String detailJson) { BizOpLog log = new BizOpLog(); log.setOperatorUserId(operatorUserId); log.setModule(module); log.setAction(action); log.setResourceType(resourceType); log.setResourceId(resourceId); log.setDetailJson(detailJson); log.setOpTime(LocalDateTime.now()); log.setTraceId(MDC.get(MDC_TRACE)); bizOpLogMapper.insert(log); } }