EbookSnapshotService.java 1.3 KB
Newer Older
1 2
package io.github.yubincloud.fairywiki.service;

3
import io.github.yubincloud.fairywiki.dto.resp.StatisticRespDto;
4
import io.github.yubincloud.fairywiki.mapper.EbookSnapshotMapperCustom;
5 6 7
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
8
import java.util.List;
9 10 11 12 13

@Service
public class EbookSnapshotService {

    @Resource
14 15 16 17 18
    private EbookSnapshotMapperCustom ebookSnapshotMapperCustom;

    public void genSnapshots() {
        ebookSnapshotMapperCustom.genSnapshot();
    }
19 20 21 22 23

    /**
     * 获取首页数值数据:总阅读数、总点赞数、今日阅读数、今日点赞数、今日预计阅读数、今日预计阅读增长
     */
    public List<StatisticRespDto> getStatistic() {
24 25 26 27 28 29 30 31 32 33
        List<StatisticRespDto> statisticDataList = ebookSnapshotMapperCustom.getStatistic();
        if (statisticDataList.size() < 2) {
            if (statisticDataList.isEmpty()) {
                statisticDataList.add(null);
                statisticDataList.add(null);
            } else {
                statisticDataList.add(0, null);
            }
        }
        return statisticDataList;
34
    }
35 36 37 38 39 40 41

    /**
     * 30天数值统计
     */
    public List<StatisticRespDto> get30DayStatistic() {
        return ebookSnapshotMapperCustom.get30DayStatistic();
    }
42
}