package com.usky.system.service.impl;


import com.ruoyi.common.datascope.annotation.DataScope;
import com.usky.common.core.util.StringUtils;
import com.usky.common.mybatis.core.AbstractCrudService;
import com.usky.common.security.utils.SecurityUtils;
import com.usky.system.domain.SysLogininfor;
import com.usky.system.mapper.SysLogininforMapper;
import com.usky.system.service.ISysLogininforService;
import com.usky.system.service.vo.SysLoginExportVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Objects;


/**
 * 系统访问日志情况信息 服务层处理
 * 
 * @author yq
 */
@Service
public class SysLogininforServiceImpl extends AbstractCrudService<SysLogininforMapper, SysLogininfor> implements ISysLogininforService
{

    @Autowired
    private SysLogininforMapper logininforMapper;

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

    /**
     * 查询系统登录日志集合
     * 
     * @param logininfor 访问日志对象
     * @return 登录记录集合
     */
    @DataScope(deptAlias = "d",userAlias = "d")
    @Override
    public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor)
    {
        logininfor.setTenantId(SecurityUtils.getTenantId());
        return logininforMapper.selectLogininforList(logininfor);
    }

    /**
     * 查询系统登录日志集合-导出
     *
     * @param logininfor 访问日志对象
     * @return 登录记录导出集合
     */
    @Override
    @DataScope(deptAlias = "d",userAlias = "d")
    public List<SysLoginExportVO> selectLogininforListExport(SysLogininfor logininfor)
    {
        logininfor.setTenantId(SecurityUtils.getTenantId());
        return logininforMapper.selectLogininforListExport(logininfor);
    }

    /**
     * 批量删除系统登录日志
     * 
     * @param infoIds 需要删除的登录日志ID
     * @return
     */
    @Override
    public int deleteLogininforByIds(Long[] infoIds)
    {
        return logininforMapper.deleteLogininforByIds(infoIds);
    }

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