package com.xindazhou.business.service.logger;

import com.xindazhou.framework.common.pojo.PageResult;
import com.xindazhou.framework.common.util.object.BeanUtils;
import com.xindazhou.framework.common.biz.system.logger.dto.OperateLogCreateReqDTO;
import com.xindazhou.business.api.logger.dto.OperateLogPageReqDTO;
import com.xindazhou.business.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
import com.xindazhou.business.dal.dataobject.logger.OperateLogDO;
import com.xindazhou.business.dal.mysql.logger.OperateLogMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * 操作日志 Service 实现类
 *
 * @author hmy
 */
@Service
@Validated
@Slf4j
public class OperateLogServiceImpl implements OperateLogService {

    @Resource
    private OperateLogMapper operateLogMapper;

    @Override
    public void createOperateLog(OperateLogCreateReqDTO createReqDTO) {
        OperateLogDO log = BeanUtils.toBean(createReqDTO, OperateLogDO.class);
        operateLogMapper.insert(log);
    }

    @Override
    public OperateLogDO getOperateLog(Long id) {
        return operateLogMapper.selectById(id);
    }

    @Override
    public PageResult<OperateLogDO> getOperateLogPage(OperateLogPageReqVO pageReqVO) {
        return operateLogMapper.selectPage(pageReqVO);
    }

    @Override
    public PageResult<OperateLogDO> getOperateLogPage(OperateLogPageReqDTO pageReqDTO) {
        return operateLogMapper.selectPage(pageReqDTO);
    }

}
