package com.zhongzheng.controller.recruit;

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

import com.zhongzheng.modules.recruit.bo.RecruitTemplateAddBo;
import com.zhongzheng.modules.recruit.bo.RecruitTemplateEditBo;
import com.zhongzheng.modules.recruit.bo.RecruitTemplateQueryBo;
import com.zhongzheng.modules.recruit.domain.RecruitTemplate;
import com.zhongzheng.modules.recruit.service.IRecruitTemplateService;
import com.zhongzheng.modules.recruit.vo.RecruitTemplateVo;
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.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-12
 */
@Api(value = "招聘模板控制器", tags = {"招聘模板管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/recruit/template")
public class RecruitTemplateController extends BaseController {

    private final IRecruitTemplateService iRecruitTemplateService;

    /**
     * 查询招聘模板列表
     */
    @ApiOperation("查询招聘模板列表")
    @PreAuthorize("@ss.hasPermi('recruit:template:list')")
    @GetMapping("/list")
    public TableDataInfo<RecruitTemplate> list(RecruitTemplateQueryBo bo) {
        startPage();
        List<RecruitTemplate> list = iRecruitTemplateService.queryRecruitTemplateList(bo);
        return getDataTable(list);
    }

    /**
     * 导出招聘模板列表
     */
    /*@ApiOperation("导出招聘模板列表")
    @PreAuthorize("@ss.hasPermi('recruit:template:export')")
    @Log(title = "招聘模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<RecruitTemplateVo> export(RecruitTemplateQueryBo bo) {
        List<RecruitTemplateVo> list = iRecruitTemplateService.queryList(bo);
        ExcelUtil<RecruitTemplateVo> util = new ExcelUtil<RecruitTemplateVo>(RecruitTemplateVo.class);
        return util.exportExcel(list, "招聘模板");
    }*/

    /**
     * 获取招聘模板详细信息
     */
    @ApiOperation("获取招聘模板详细信息")
    @PreAuthorize("@ss.hasPermi('recruit:template:query')")
    @GetMapping("/{id}")
    public AjaxResult<RecruitTemplateVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iRecruitTemplateService.queryById(id));
    }

    /**
     * 新增招聘模板
     */
    @ApiOperation("新增招聘模板")
    @PreAuthorize("@ss.hasPermi('recruit:template:add')")
    @Log(title = "招聘模板", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody RecruitTemplateAddBo bo) {
        return toAjax(iRecruitTemplateService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改招聘模板
     */
    @ApiOperation("修改招聘模板")
    @PreAuthorize("@ss.hasPermi('system:template:edit')")
    @Log(title = "招聘模板", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody RecruitTemplateEditBo bo) {
        return toAjax(iRecruitTemplateService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除招聘模板
     */
    /*@ApiOperation("删除招聘模板")
    @PreAuthorize("@ss.hasPermi('system:template:remove')")
    @Log(title = "招聘模板" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iRecruitTemplateService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }*/
}
