package com.jeelowcode.tool.framework.operatelog.core.service;

import cn.hutool.core.bean.BeanUtil;
import com.jeelowcode.service.system.api.IApiOperateLogApi;
import com.jeelowcode.service.system.dto.OperateLogCreateReqDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;

/**
 * 操作日志 Framework Service 实现类
 *
 * 基于 {@link IApiOperateLogApi} 实现，记录操作日志
 *
 * @author 芋道源码
 */
@RequiredArgsConstructor
public class OperateLogFrameworkServiceImpl implements OperateLogFrameworkService {

    private final IApiOperateLogApi apiOperateLogApi;

    @Override
    @Async
    public void createOperateLog(OperateLog operateLog) {
        OperateLogCreateReqDTO reqDTO = BeanUtil.toBean(operateLog, OperateLogCreateReqDTO.class);
        apiOperateLogApi.createOperateLog(reqDTO);
    }

}
