package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.dto.SeOnlineTimeDto;
import com.ruoyi.system.domain.dto.SeUserCountDto;
import com.ruoyi.system.service.IDailySysService;
import com.ruoyi.system.service.ISysUserStService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;


@Service
public class SysUserStServiceImpl implements ISysUserStService {

    @Autowired
    private ISysUserService sysUserService;

    @Autowired
    private IDailySysService dailySysService;

    // 计数当前用户系统用户的数量
    @Override
    public Long getUserCount() {
        Long userCount = sysUserService.getUserCount();
        return userCount;
    }

    // 返回近7天用户数量, 若返回长度不为7则说明当天用户数据为0,每天都插入数据的话不可能出现这个情况.
    @Override
    public List<SeUserCountDto> getSeUserCount() {
        LocalDate now = LocalDate.now();
        LocalDate startDate = now.minusDays(8);
        LocalDate endDate = now.minusDays(1);
        List<SeUserCountDto> seUserCount = dailySysService.getSeUserCount(startDate, endDate);

        return seUserCount;

    }

    @Override
    public List<SeUserCountDto> getUserCountByTime(LocalDate startDate, LocalDate endDate){
        List<SeUserCountDto> seUserCount = dailySysService.getSeUserCount(startDate, endDate);
        return seUserCount;
    }

    @Override
    public List<SeOnlineTimeDto> gettOnlineTime(LocalDate startDate, LocalDate endDate){
        return dailySysService.gettOnlineTime(startDate, endDate);
    }
}
