package com.cool.store.controller;

import com.cool.store.dto.partner.EnterInterviewDto;
import com.cool.store.exception.ApiException;
import com.cool.store.request.*;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.InterviewService;
import com.cool.store.vo.EnterInterviewVO;
import com.cool.store.vo.interview.InterviewVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: young.yu
 * @Date: 2023-06-06  15:22
 * @Description:
 */
@RestController
@RequestMapping("/interview")
@Api(tags = "面试信息")
public class InterviewController {

    @Autowired
    private InterviewService interviewService;

    @PostMapping("/list")
    @ApiOperation("获取面试信息列表")
    public ResponseResult<PageInfo<InterviewVO>> getInterviewList(@RequestBody GetInterviewListReq request) {
        PageHelper.startPage(request.getPageNum(), request.getPageSize());
        List<InterviewVO> interviewList = interviewService.getInterviewList(request);
        return ResponseResult.success(new PageInfo<>(interviewList));
    }

    @PostMapping("/queryByInterviewPlanId")
    @ApiOperation("根据面试会议计划id查询面试信息")
    public ResponseResult<InterviewVO> queryByInterviewPlanId(@RequestBody QueryByInterviewPlanIdReq request) throws ApiException {
        InterviewVO interviewVO = interviewService.getInterviewInfo(request);
        return ResponseResult.success(interviewVO);
    }

    @PostMapping("/entrustOthers")
    @ApiOperation("委托他人")
    public ResponseResult entrustOthers(@RequestBody EntrustOthersReq request) throws ApiException {
        interviewService.entrustOthers(request);
        return ResponseResult.success();
    }

    @PostMapping("/modifyInterviewTime")
    @ApiOperation("修改面试时间")
    public ResponseResult modifyInterviewTime(@RequestBody ModifyInterviewTimeReq request) throws ApiException {
        interviewService.modifyInterviewTime(request);
        return ResponseResult.success();
    }

    @PostMapping("/finish")
    @ApiOperation("结束面试")
    public ResponseResult finishInterview(@RequestBody FinishInterviewReq request) throws ApiException {
        interviewService.finishInterview(request);
        return ResponseResult.success();
    }

    @PostMapping("/enter")
    @ApiOperation("进入面试房间")
    public ResponseResult<EnterInterviewVO> enterInterviewRoom(@RequestBody EnterInterviewDto dto) throws ApiException {
        return ResponseResult.success(interviewService.enterInterviewRoom(dto));
    }

    @PostMapping("/appointment/approve")
    @ApiOperation("同意面试预约")
    public ResponseResult approveAppointment(@RequestBody ApproveAppointmentReq request) throws ApiException {
        interviewService.approveAppointment(request);
        return ResponseResult.success();
    }

    @PostMapping("/reInterview")
    @ApiOperation("重新面试")
    public ResponseResult reInterview(@RequestBody ReInterviewReq request) throws ApiException {
        interviewService.reInterview(request);
        return ResponseResult.success();
    }

//    @PostMapping("/reject")
//    @ApiOperation("拒绝面试")
//    public ResponseResult reInterview(@RequestBody RejectInterviewReq request) throws ApiException {
//        interviewService.rejectInterview(request);
//        return ResponseResult.success();
//    }
}
