package com.ruoyi.common.core.service.impl;

import com.easy.mongodb.core.biz.PageInfo;
import com.easy.mongodb.core.conditions.Wrapper;
import com.ruoyi.common.core.domain.entity.SysLogininfor;
import com.ruoyi.common.core.mapper.SysLogininforMapper;
import com.ruoyi.common.core.service.ISysLogininforService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 系统访问日志情况信息 服务层处理
 *
 * @author ruoyi
 */
@Service
public class SysLogininforServiceImpl implements ISysLogininforService {

    @Autowired
    private SysLogininforMapper logininforMapper;

    /**
     * 新增系统登录日志
     *
     * @param logininfor 访问日志对象
     */
    @Override
    public void insertLogininfor(SysLogininfor logininfor) {
        this.logininforMapper.insert(logininfor);
    }

    /**
     * 查询系统登录日志集合
     *
     * @param logininfor 访问日志对象
     * @return 登录记录集合
     */
    @Override
    public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) {
        return this.logininforMapper.selectList(logininfor);
    }

    @Override
    public PageInfo<SysLogininfor> page(Wrapper<SysLogininfor> wrapper, Integer pageNum, Integer pageSize) {
        return this.logininforMapper.page(wrapper, pageNum, pageSize);
    }

    /**
     * 批量删除系统登录日志
     *
     * @param infoIds 需要删除的登录日志ID
     * @return 结果
     */
    @Override
    public int deleteLogininforByIds(String[] infoIds) {
        return this.logininforMapper.deleteBatchIds(Arrays.asList(infoIds)).intValue();
    }

    /**
     * 清空系统登录日志
     */
    @Override
    public void cleanLogininfor() {
        this.logininforMapper.drop();
    }
}
