package com.ebts.system.service.impl;

import com.ebts.system.dao.LogininforDao;
import com.ebts.system.entity.Logininfor;
import com.ebts.system.service.LogininforService;
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 LogininforServiceImpl implements LogininforService {
    private Logger logger = LoggerFactory.getLogger(LogininforServiceImpl.class);

    @Autowired
    private LogininforDao logininforMapper;

    /**
     * 新增系统登录日志
     *
     * @param logininfor 访问日志对象
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void insertLogininfor(Logininfor logininfor) {
        logininforMapper.insertLogininfor(logininfor);
    }

    /**
     * 查询系统登录日志集合
     *
     * @param logininfor 访问日志对象
     * @return 登录记录集合
     */
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<Logininfor> selectLogininforList(Logininfor logininfor) {
        return logininforMapper.selectLogininforList(logininfor);
    }

    /**
     * 批量删除系统登录日志
     *
     * @param infoIds 需要删除的登录日志ID
     * @return
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public int deleteLogininforByIds(Long[] infoIds) {
        return logininforMapper.deleteLogininforByIds(infoIds);
    }

    /**
     * 清空系统登录日志
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void cleanLogininfor() {
        logininforMapper.cleanLogininfor();
    }
}
