package com.ruoyi.cms.controller.cms;

import com.ruoyi.cms.domain.Job;
import com.ruoyi.cms.domain.JobApply;
import com.ruoyi.cms.domain.vo.CandidateVO;
import com.ruoyi.cms.service.IJobApplyService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/cms/jobApply")
@Api(tags = "后台：岗位申请")
public class JobApplyController extends BaseController {

    @Autowired
    IJobApplyService iJobApplyService;

    @GetMapping("/trendChart")
    public AjaxResult trendChart(JobApply jobApply)
    {
        HashMap<String,Integer> result = iJobApplyService.trendChart(jobApply);
        return success(result);
    }

    /**
     * 导出APP用户列表
     */
    @ApiOperation("导出岗位申请APP用户")
    @PreAuthorize("@ss.hasPermi('cms:jobApply:export')")
    @Log(title = "APP用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Job job)
    {
        List<CandidateVO> list = iJobApplyService.selectAppUserList(job);
        ExcelUtil<CandidateVO> util = new ExcelUtil<CandidateVO>(CandidateVO.class);
        util.exportExcel(response, list, "APP用户数据");
    }
}
