package com.ruoyi.web.controller.school.course;

import com.ruoyi.common.page.RespPage;
import com.ruoyi.core.api.APIResponse;
import com.ruoyi.school.course.domain.ScClaTime;
import com.ruoyi.school.course.domain.ScClaTimeVo;
import com.ruoyi.school.course.domain.req.time.ReqSearchClaTime;
import com.ruoyi.school.course.domain.resp.time.RespBusinessClaTimeCalendar;
import com.ruoyi.school.course.domain.resp.time.RespClaTime;
import com.ruoyi.school.course.domain.resp.time.RespClaTimeCalendar;
import com.ruoyi.school.course.service.BusinessClaTimeService;
import com.ruoyi.school.student.domain.req.ReqClaTimeAttend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：zhangbaoyu
 * @date ：Created in 2020/9/18 14:40
 */
@RestController
@RequestMapping("/api/sc/cla/time")
public class ScClaTimeController {

    @Autowired
    private BusinessClaTimeService claTimeService;

    /**
     * 按周获取课表
     *
     * @param reqSearchClaTime
     * @return 周课表 {@link RespBusinessClaTimeCalendar}
     */
    @GetMapping("/list/searchListForCalendar")
    public APIResponse searchListForCalendar(ReqSearchClaTime reqSearchClaTime) {
        return claTimeService.searchListForCalendar(reqSearchClaTime);
    }

    @GetMapping("/list/searchListForCalendarByMemberId")
    public APIResponse searchListForCalendarByMemberId(ReqSearchClaTime reqSearchClaTime) {
        return claTimeService.searchMemberId(reqSearchClaTime);
    }



    /**
     * 获取最近几天的排课日程
     *
     * @param reqSearchClaTime
     * @return
     */
    @GetMapping("/list/searchRecentDayTimeList")
    public APIResponse searchRecentDayTimeList(ReqSearchClaTime reqSearchClaTime) {
        List<RespClaTimeCalendar> respClaTimeList = claTimeService.searchRecentDayTimeList(reqSearchClaTime);
        return APIResponse.toAPIResponse(respClaTimeList);
    }

    /**
     * 获取上课记录
     *
     * @param reqSearchClaTime
     * @return
     */
    @GetMapping("/list/selectListForAttend")
    public APIResponse selectListForAttend(ReqSearchClaTime reqSearchClaTime) {
        RespPage<RespClaTime> respPage = claTimeService.selectListForAttend(reqSearchClaTime);
        return APIResponse.toAPIResponse(respPage);
    }

    /**
     * 添加
     *
     * @param scClaTime
     * @return
     */
    @PostMapping("/add/addScClaTime")
    public APIResponse addScClaTime(@RequestBody ScClaTime scClaTime) {
        return claTimeService.addClaTime(scClaTime);
    }

    /**
     * 详情
     *
     * @param courseTimeId
     * @return
     */
    @GetMapping("/info/detailById/{courseTimeId}")
    public APIResponse detailById(@PathVariable("courseTimeId") Long courseTimeId) {
        return claTimeService.detailById(courseTimeId);
    }

    /**
     * 修改
     *
     * @param scClaTime
     * @return
     */
    @PutMapping("/update/updateScClaTime")
    public APIResponse updateScClaTime(@RequestBody ScClaTimeVo scClaTime) {
        return claTimeService.updateClaTime(scClaTime);
    }

    /**
     * 删除
     *
     * @param courseTimeId
     * @return
     */
    @DeleteMapping("/delete/deleteById/{courseTimeId}")
    public APIResponse deleteById(@PathVariable("courseTimeId") Long courseTimeId) {
        return claTimeService.deleteById(courseTimeId);
    }

    /**
     * 记上课 信息
     * @param reqClaTimeAttend
     * @return
     */
    @PostMapping("/update/confirmCla")
    public APIResponse confirmCla(@RequestBody ReqClaTimeAttend reqClaTimeAttend) {
        return claTimeService.confirmCla(reqClaTimeAttend);
    }

    /**
     * 查询已经预约签到的会员
     * @param
     * @return
     */
    @GetMapping("/list/searchCourseClaStudent")
    public APIResponse searchCourseClaStudent(ReqSearchClaTime reqSearchClaTime) {
        return claTimeService.searchCourseClaStudent(reqSearchClaTime);
    }

}
