package com.bonus.sgzb.app.service.impl;

import com.bonus.sgzb.app.domain.AppVersion;
import com.bonus.sgzb.app.domain.CriticalData;
import com.bonus.sgzb.app.domain.ToDoList;
import com.bonus.sgzb.app.mapper.AppMapper;
import com.bonus.sgzb.app.service.AppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @author c liu
 * @date 2023/12/11
 */
@Service("AppService")
public class AppServiceImpl implements AppService {
    @Autowired
    private AppMapper mapper;


    @Override
    public CriticalData getCriticalData() {
        CriticalData data = new CriticalData();
        LocalDate currentDate = LocalDate.now();
        String startTime = currentDate + " 00:00:00";
        String endTime = currentDate + " 23:59:59";
        int dayLeaseNum = mapper.getDayLeaseNum(startTime,endTime);
        int dayBackNum = mapper.getDayBackNum(startTime,endTime);
        int dayInputNum = mapper.getDayInputNum(startTime,endTime);
        int dayOutNum = mapper.getDayOutNum(startTime,endTime);
        data.setDayLeaseNum(dayLeaseNum);
        data.setDayBackNum(dayBackNum);
        data.setDayInputNum(dayInputNum);
        data.setDayOutNum(dayOutNum);
        return data;
    }

    @Override
    public ToDoList getToDoList() {
        ToDoList data = new ToDoList();
        int leaseNum = mapper.getLeaseNum();
        int backNum = mapper.getBackNum();
        int scrapNum = mapper.getScrapNum();
        int trialNum = mapper.getTrialNum();
        data.setLeaseNum(leaseNum);
        data.setBackNum(backNum);
        data.setScrapNum(scrapNum);
        data.setTrialNum(trialNum);
        return data;
    }

    /**
     * 获取app版本信息
     */
    @Override
    public List<AppVersion> getVersion() {
        return mapper.getVersion();
    }
}
