package com.zhongzheng.controller.recruit;

import java.util.List;
import java.util.Arrays;

import com.zhongzheng.common.core.domain.model.LoginUser;
import com.zhongzheng.common.utils.ServletUtils;
import com.zhongzheng.framework.web.service.TokenService;
import com.zhongzheng.modules.recruit.vo.CalendarInterviewVo;
import com.zhongzheng.modules.recruit.vo.RecruitInterviewExcel;
import com.zhongzheng.modules.recruit.vo.RecruitInterviewUserVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.recruit.vo.RecruitInterviewVo;
import com.zhongzheng.modules.recruit.bo.RecruitInterviewQueryBo;
import com.zhongzheng.modules.recruit.bo.RecruitInterviewAddBo;
import com.zhongzheng.modules.recruit.bo.RecruitInterviewEditBo;
import com.zhongzheng.modules.recruit.service.IRecruitInterviewService;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 招聘面试关联Controller
 * 
 * @author ruoyi
 * @date 2021-08-18
 */
@Api(value = "招聘面试控制器", tags = {"招聘面试联管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/recruit/interview")
public class RecruitInterviewController extends BaseController {

    private final IRecruitInterviewService iRecruitInterviewService;

    @Autowired
    private TokenService tokenService;

    /**
     * 查询招聘面试关联列表
     */
    @ApiOperation("查询招聘面试日历列表")
    @PreAuthorize("@ss.hasPermi('modules.recruit:interview:list')")
    @GetMapping("/list")
    public AjaxResult<CalendarInterviewVo> list(RecruitInterviewQueryBo bo) {
        startPage();
        CalendarInterviewVo list = iRecruitInterviewService.queryListCalendar(bo);
        return  AjaxResult.success(list);
    }

    /**
     * 导出招聘面试关联列表
     */
    @ApiOperation("导出招聘面试关联列表")
    @PreAuthorize("@ss.hasPermi('modules.recruit:interview:export')")
    @Log(title = "招聘面试关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<RecruitInterviewVo> export(RecruitInterviewQueryBo bo) {
        List<RecruitInterviewExcel> list = iRecruitInterviewService.queryExcelsList(bo);
        ExcelUtil<RecruitInterviewExcel> util = new ExcelUtil<RecruitInterviewExcel>(RecruitInterviewExcel.class);
        return util.exportExcel(list, "招聘面试安排");
    }

 /*   *//**
     * 获取招聘面试关联详细信息
     *//*
    @ApiOperation("获取招聘面试关联详细信息")
    @PreAuthorize("@ss.hasPermi('modules.recruit:interview:query')")
    @GetMapping("/{interviewId}")
    public AjaxResult<RecruitInterviewVo> getInfo(@PathVariable("interviewId" ) Long interviewId) {
        return AjaxResult.success(iRecruitInterviewService.queryById(interviewId));
    }*/



    /**
     * 修改招聘面试关联
     */
    @ApiOperation("修改招聘面试关联")
    @PreAuthorize("@ss.hasPermi('modules.recruit:interview:edit')")
    @Log(title = "招聘面试关联", businessType = BusinessType.UPDATE)
    @PostMapping()
    public AjaxResult<Void> edit(@RequestBody RecruitInterviewEditBo bo) {
        return toAjax(iRecruitInterviewService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 查询招聘面试简历列表
     */
    @ApiOperation("查询招聘面试简历列表")
    @PreAuthorize("@ss.hasPermi('modules.recruit:interview:list')")
    @GetMapping("/listAll")
    public TableDataInfo<RecruitInterviewVo> listAll(RecruitInterviewQueryBo bo) {
        startPage();
        List<RecruitInterviewVo> list = iRecruitInterviewService.queryListAll(bo);
        return  getDataTable(list);
    }

    /**
     * 查询招聘面试简历列表
     */
    @ApiOperation("查询详情招聘面试简历")
    @PreAuthorize("@ss.hasPermi('modules.recruit:interview:query')")
    @GetMapping("/{interviewId}")
    public AjaxResult<RecruitInterviewUserVo> interviewUserId(@PathVariable("interviewId" ) Long interviewUserId) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        return AjaxResult.success(iRecruitInterviewService.interviewUserId(interviewUserId,loginUser));
    }

}
