package com.yida.data.school.leave.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.CurrentUser;
import com.yida.data.common.core.entity.leave.EduLeaveRequest;
import com.yida.data.common.core.entity.user.EduStaff;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.school.leave.service.EduLeaveRequestService;
import com.yida.data.school.vo.leave.FindPageLeaveListVO;
import com.yida.data.user.dto.ListStaffDTO;
import com.yida.data.user.feign.RemoteStaffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ccl
 */
@Slf4j
@Validated
@RestController
@RequestMapping("request/web/leaveRequest")
@AllArgsConstructor
@Api(tags = "请假条-web-请假管理")
public class EduLeaveWebController {
    private final EduLeaveRequestService eduLeaveRequestService;
    private final RemoteStaffService remoteStaffService;

    @ApiOperation("分页查询请假列表")
    @GetMapping("findPageLeaveList")
    public ResultBean<Page<FindPageLeaveListVO>> findPageLeaveList(@RequestParam(required = false) @ApiParam("学生名字") String studentName,
                                                                   @RequestParam(required = false) @ApiParam("是否审批,0为未审批，1为已审批") Integer status,
                                                                   @RequestParam(required = false) @ApiParam("0为全部，1为审核通过，2为审核不通过") Integer reviewStatus,
                                                                   @RequestParam(required = false) @ApiParam("学段id") Long sectionId,
                                                                   @RequestParam(required = false) @ApiParam("学校id") Long schoolId,
                                                                   @RequestParam(required = false) @ApiParam("年级id") Long gradeId,
                                                                   @RequestParam(required = false) @ApiParam("学区id") Long campsId,
                                                                   @RequestParam(required = false) @ApiParam("教师名字") String teacherName,
                                                                   @RequestParam(defaultValue = "1") Long pageNum,
                                                                   @RequestParam(defaultValue = "10") Long pageSize) {
        Page<FindPageLeaveListVO> page = new Page<>();
        page.setSize(pageSize);
        page.setCurrent(pageNum);
        return ResultBean.buildSuccess(eduLeaveRequestService.findPageLeaveList(page, status, sectionId, gradeId,  studentName,reviewStatus,teacherName,campsId,schoolId));
    }

    @ApiOperation("查询请假条详情")
    @GetMapping("findLeaveRequest")
    public ResultBean<FindPageLeaveListVO> findLeaveRequest(@ApiParam("假条id") @RequestParam Long id){

        return ResultBean.buildSuccess(eduLeaveRequestService.findLeaveRequest(id));
    }
}
