package com.yida.data.attendance.controller.out;

import com.yida.data.attendance.service.EduAttendanceManagePushResultService;
import com.yida.data.attendance.service.EduAttendanceStasticService;
import com.yida.data.attendance.vo.StaRecordCountVO;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.attendance.EduAttendanceResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

@Api(tags = "考勤-考勤统计")
@RestController
@RequestMapping("/out/stastic")
@RequiredArgsConstructor
public class OutEduAttendanceStasticController {

    private final EduAttendanceStasticService eduAttendanceStasticService;
    private final EduAttendanceManagePushResultService eduAttendanceManagePushResultService;

    @ApiOperation("dashboard-考勤概况")
    @GetMapping("/staRecordCount")
    public ResultBean<StaRecordCountVO> staRecordCount(@ApiParam("yyyy-MM-dd") String startDate,
        @ApiParam("yyyy-MM-dd") String endDate, Long[] schoolIds) {
        return ResultBean
            .buildSuccess(eduAttendanceStasticService.staRecordCount(LocalDate.parse(startDate), LocalDate.parse(endDate),
                Arrays.asList(schoolIds)));
    }

    @ApiOperation("查询归寝报告")
    @GetMapping("/selectPushList")
    public ResultBean<List<EduAttendanceResult>> selectPushList(@RequestParam Long pushId) {
        return ResultBean.buildSuccess(eduAttendanceManagePushResultService.selectPushList(pushId));
    }
}
