package com.yida.data.attendance.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yida.data.attendance.dto.ListStaffResultDTO;
import com.yida.data.attendance.service.EduAttendanceStaffResultService;
import com.yida.data.attendance.vo.ListStaffResultPageVO;
import com.yida.data.attendance.vo.StaffDateTimeResultInfo;
import com.yida.data.attendance.vo.StaffTimeResultInfo;
import com.yida.data.common.core.common.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 教职工考勤-考勤结果 Controller
 *
 * @author ZYJ
 * @date 2021-09-27 18:56:23
 */
@Api(tags = "考勤-教职工-考勤结果")
@Slf4j
@Validated
@RestController
@RequestMapping("/staffResult")
@RequiredArgsConstructor
public class EduAttendanceStaffResultController {

    private final EduAttendanceStaffResultService eduAttendanceStaffResultService;


    @ApiOperation("查询各时段考勤结果")
    @GetMapping("/listTimeResult")
    public ResultBean<List<StaffTimeResultInfo>> listTimeResult(@ApiParam("教职工id") Long staffId,
        @ApiParam("日期，yyyy-MM-dd") String date) {
        return ResultBean.buildSuccess(eduAttendanceStaffResultService.listTimeResult(staffId, date));
    }

    @ApiOperation("查询各天各时段考勤结果")
    @GetMapping("/listDateTimeResult")
    public ResultBean<List<StaffDateTimeResultInfo>> listDateTimeResult(@ApiParam("教职工id") Long staffId,
        @ApiParam("年月，yyyy-MM") String yearMonth) {
        return ResultBean.buildSuccess(eduAttendanceStaffResultService.listDateTimeResult(staffId, yearMonth));
    }

    @ApiOperation("分页查询考勤结果列表 ")
    @GetMapping("/listResultPage")
    public ResultBean<IPage<ListStaffResultPageVO>> listResultPage(ListStaffResultDTO dto) {
        return ResultBean.buildSuccess(eduAttendanceStaffResultService.listResultPage(dto));
    }
}
