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


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.school.secondClass.EduSecondClassVenueGuide;
import com.yida.data.common.core.entity.school.secondClass.EduSecondClassVenueGuideSchedule;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.common.core.vo.NameValueVO;
import com.yida.data.school.dto.secondClass.ListVenueExhibitDTO;
import com.yida.data.school.dto.secondClass.ListVenueGuideDTO;
import com.yida.data.school.secondClass.service.EduSecondClassVenueGuideScheduleService;
import com.yida.data.school.secondClass.service.EduSecondClassVenueGuideService;
import com.yida.data.school.vo.secondClass.VenueGuideVO;
import com.yida.data.school.vo.secondClass.VunueGuideScheduleVO;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * Controller
 *
 * @author zhanghaijun
 * @date 2022-04-21 10:10:35
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/secondClass/venue/guide")
@RequiredArgsConstructor
public class EduSecondClassVenueGuideController {

    private final EduSecondClassVenueGuideService eduSecondClassVenueGuideService;
    private final EduSecondClassVenueGuideScheduleService eduSecondClassVenueGuideScheduleService;


    @ApiOperation("分页查询讲解员")
    @GetMapping("/listGuidePage")
    public ResultBean<IPage<VenueGuideVO>> listGuidePage(ListVenueGuideDTO dto) {
        return ResultBean.buildSuccess(eduSecondClassVenueGuideService.listGuidePage(dto));
    }

    @ApiOperation("保存讲解员")
    @PostMapping("/saveGuide")
    public ResultBean saveGuide(@RequestBody EduSecondClassVenueGuide guide) {
        guide.setDeptId(FebsUtil.getTopDeptId());
        eduSecondClassVenueGuideService.saveGuide(guide);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("改变工作状态")
    @GetMapping("/changeStatus")
    public ResultBean changeStatus(Long id, Integer status) {
        eduSecondClassVenueGuideService.changeStatus(id, status);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("查询详情")
    @GetMapping("/getInfo")
    public ResultBean<VenueGuideVO> getInfo(Long id) {
        return ResultBean.buildSuccess(eduSecondClassVenueGuideService.getInfo(id));
    }

    @ApiOperation("删除")
    @GetMapping("/delGuide")
    public ResultBean delGuide(Long id) {
        eduSecondClassVenueGuideService.delGuide(id);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("保存讲解员排班")
    @PostMapping("/saveSchedule")
    public ResultBean saveSchedule(@RequestBody List<EduSecondClassVenueGuideSchedule> scheduleList) {
        eduSecondClassVenueGuideScheduleService.saveSchedule(scheduleList);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("查询讲解员排班表")
    @GetMapping("/getSchedule")
    public ResultBean<List<List<String>>> getSchedule(Long guideId) {
        return ResultBean.buildSuccess(eduSecondClassVenueGuideScheduleService.getSchedule(guideId));
    }

}
