package com.ebts.system.service.impl;

import com.ebts.system.dao.OperLogDao;
import com.ebts.system.entity.OperLog;
import com.ebts.system.service.OperLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 操作日志 服务层处理
 *
 * @author binlin
 */
@Service
public class OperLogServiceImpl implements OperLogService {
    private Logger logger = LoggerFactory.getLogger(OperLogServiceImpl.class);

    @Autowired
    private OperLogDao operLogMapper;

    /**
     * 新增操作日志
     *
     * @param operLog 操作日志对象
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public void insertOperlog(OperLog operLog) {
            operLogMapper.insertOperlog(operLog);
    }

    /**
     * 查询系统操作日志集合
     *
     * @param operLog 操作日志对象
     * @return 操作日志集合
     */
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<OperLog> selectOperLogList(OperLog operLog) {
            return operLogMapper.selectOperLogList(operLog);
    }

    /**
     * 批量删除系统操作日志
     *
     * @param operIds 需要删除的操作日志ID
     * @return 结果
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public int deleteOperLogByIds(Long[] operIds) {
            return operLogMapper.deleteOperLogByIds(operIds);
    }

    /**
     * 查询操作日志详细
     *
     * @param operId 操作ID
     * @return 操作日志对象
     */
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public OperLog selectOperLogById(Long operId) {
            return operLogMapper.selectOperLogById(operId);
    }

    /**
     * 清空操作日志
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public void cleanOperLog() {
            operLogMapper.cleanOperLog();
    }
}
