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

import cn.hutool.core.bean.BeanUtil;
import com.lideeyunji.service.system.api.IApiOperateLogApi;
import com.lideeyunji.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) {
        try{
            OperateLogCreateReqDTO reqDTO = BeanUtil.toBean(operateLog, OperateLogCreateReqDTO.class);
            apiOperateLogApi.createOperateLog(reqDTO);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
