package com.cool.store.controller;

import com.cool.store.dto.inspection.interview.InspectionRevocationDTO;
import com.cool.store.dto.inspection.interview.InspectionSubmissionDTO;
import com.cool.store.exception.ApiException;
import com.cool.store.request.GetInterviewInspectionListReq;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.InterviewInspectionService;
import com.cool.store.vo.interview.GetInterviewInspectionHistoryListVO;
import com.cool.store.vo.interview.InterviewInspectionHistoryInfo;
import com.cool.store.vo.interview.InterviewInspectionInfo;
import com.cool.store.vo.interview.InterviewInspectionVO;
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.*;

import java.util.List;

/**
 * @author Fun Li
 * @version 1.0
 * @date 2023/7/19 16:48
 */
@RestController
@RequestMapping("/inspection/interview")
@Api(tags = "面试稽核")
public class InterviewInspectionController {

    @Autowired
    private InterviewInspectionService interviewInspectionService;

    @PostMapping("/submission")
    @ApiOperation("提交稽核结果")
    public ResponseResult interviewInspectionSubmit(@RequestBody InspectionSubmissionDTO dto) throws ApiException {
        interviewInspectionService.submit(dto);
        return ResponseResult.success();
    }

    @PostMapping("/revocation")
    @ApiOperation("撤销稽核结果")
    public ResponseResult interviewInspectionRevoke(@RequestBody InspectionRevocationDTO dto) throws ApiException {
        interviewInspectionService.revoke(dto);
        return ResponseResult.success();
    }


    /**
     * 获取面试稽核列表
     *
     * @param request
     * @return
     */
    @PostMapping("/getList")
    @ApiOperation("获取面试稽核列表")
    public ResponseResult<PageInfo<InterviewInspectionVO>> interviewInspectionGetList(@RequestBody GetInterviewInspectionListReq request) {
        List<InterviewInspectionVO> interviewInspectionVOList = interviewInspectionService.interviewInspectionGetList(request);
        return ResponseResult.success(new PageInfo<>(interviewInspectionVOList));
    }


    /**
     * 获取面试稽核详情信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getDetail")
    @ApiOperation("获取面试稽核详情信息")
    public ResponseResult<InterviewInspectionInfo> interviewInspectionGetDetail(@RequestParam("id") Long id) {
        InterviewInspectionInfo interviewInspectionInfo = interviewInspectionService.interviewInspectionGetDetail(id);
        return ResponseResult.success(interviewInspectionInfo);
    }

    /**
     * 面试稽核历史结果查看
     *
     * @param id
     * @return
     */
    @GetMapping("/getHistoryDetail")
    @ApiOperation("稽核历史结果查看")
    public ResponseResult<GetInterviewInspectionHistoryListVO> interviewInspectionGetHistoryDetail(@RequestParam("id") Long id) {
        List<InterviewInspectionHistoryInfo> interviewInspectionHistoryInfos = interviewInspectionService.interviewInspectionGetHistoryDetail(id);
        return ResponseResult.success(new GetInterviewInspectionHistoryListVO().setInterviewInspectionHistoryInfos(interviewInspectionHistoryInfos));
    }


}
