package com.cool.store.controller;

import com.cool.store.dto.partner.EnterInterviewDto;
import com.cool.store.dto.partner.LineQueryInterviewDto;
import com.cool.store.dto.partner.PartnerGetPassLetterDetailDto;
import com.cool.store.dto.partner.PartnerQueryInterviewDto;
import com.cool.store.exception.ApiException;
import com.cool.store.request.CreateAppointmentReq;
import com.cool.store.request.ModifyInterviewTimeReq;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.InterviewService;
import com.cool.store.service.PartnerInterviewService;
import com.cool.store.vo.EnterInterviewVO;
import com.cool.store.vo.PartnerInterviewInfoVO;
import com.cool.store.vo.PartnerPassLetterDetailVO;
import com.cool.store.vo.interview.CreateAppointmentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "加盟商资格面试")
@RestController
@RequestMapping("/interview")
@CrossOrigin
public class InterviewController {

    @Autowired
    private PartnerInterviewService interviewService;

    @Autowired
    private InterviewService interviewBaseService;

//    @PostMapping("/queryByPartnerId")
//    @ApiOperation("根据用户id查询面试信息")
//    public ResponseResult<PartnerInterviewInfoVO> queryByPartnerId(@RequestBody PartnerQueryInterviewDto dto) {
//        return ResponseResult.success(interviewService.queryByPartnerId(dto.getPartnerId()));
//    }

    @PostMapping("/queryByPartnerLineId")
    @ApiOperation("根据线索id查询面试信息")
    public ResponseResult<PartnerInterviewInfoVO> queryByPartnerLineId(@RequestBody LineQueryInterviewDto dto) throws ApiException {
        return ResponseResult.success(interviewService.queryByPartnerLineId(dto));
    }


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

    @PostMapping("/passLetter/detail")
    @ApiOperation("通过函详情")
    public ResponseResult<PartnerPassLetterDetailVO> passLetterDetail(@RequestBody PartnerGetPassLetterDetailDto dto) throws ApiException {
        return ResponseResult.success(interviewService.passLetterDetail(dto.getInterviewPlanId()));
    }

    @PostMapping("/appointment/submit")
    @ApiOperation("预约面试")
    public ResponseResult<CreateAppointmentVO> createAppointment(@RequestBody CreateAppointmentReq request) throws ApiException {
        return ResponseResult.success(interviewBaseService.createAppointment(request));
    }

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

}
