package com.fs.statistics.service.impl;

import com.fs.course.dto.WatchLogDTO;
import com.fs.course.mapper.FsCourseWatchLogMapper;
import com.fs.statistics.dto.WatchCourseStatisticsDTO;
import com.fs.statistics.mapper.StatisticsServiceMapper;
import com.fs.statistics.param.WatchCourseStatisticsParam;
import com.fs.statistics.service.IStatisticsService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StatisticsServiceImpl implements IStatisticsService {
    @Autowired
    private StatisticsServiceMapper statisticsServiceMapper;

    @Autowired
    private FsCourseWatchLogMapper FsCourseWatchLogMapper;


    @Override
    public WatchCourseStatisticsDTO queryWatchCourse(WatchCourseStatisticsParam param) {

        List<WatchLogDTO> data = null;
        // 七天
        if(ObjectUtils.equals(param.getType(),0)) {
            data = FsCourseWatchLogMapper.selectFsCourseWatchLog7Day(param.getQwExternalContactId());
        } else if(ObjectUtils.equals(param.getType(),1)){
            data = FsCourseWatchLogMapper.selectFsCourseWatchLog30DayByExtId(param.getQwExternalContactId());
        }

        WatchCourseStatisticsDTO watchCourseStatisticsDTO = new WatchCourseStatisticsDTO();
        watchCourseStatisticsDTO.setData(data);

        return watchCourseStatisticsDTO;
    }
}
