package com.ruoyi.cms.controller.cms;

import java.util.List;

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

import javax.servlet.http.HttpServletResponse;

/**
 * 招聘会信息Controller
 * 
 * @author lishundong
 * @date 2024-09-04
 */
@RestController
@RequestMapping("/cms/fair")
@Api(tags = "后台：招聘会信息")
public class JobFairController extends BaseController
{
    @Autowired
    private IJobFairService jobFairService;


    /**
     * 查询招聘会信息列表
     */
    @ApiOperation("查询招聘会信息列表")
    @PreAuthorize("@ss.hasPermi('jobfair:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(JobFair jobFair)
    {
        startPage();
        List<JobFair> list = jobFairService.selectJobFairList(jobFair);
        return getDataTable(list);
    }

    /**
     * 导出招聘会信息列表
     */
    @ApiOperation("导出招聘会信息列表")
    @PreAuthorize("@ss.hasPermi('app:fair:export')")
    @Log(title = "招聘会信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JobFair jobFair)
    {
        List<JobFair> list = jobFairService.selectJobFairList(jobFair);
        ExcelUtil<JobFair> util = new ExcelUtil<JobFair>(JobFair.class);
        util.exportExcel(response, list, "招聘会信息数据");
    }

    /**
     * 获取招聘会信息详细信息
     */
    @ApiOperation("获取招聘会信息详细信息")
    @PreAuthorize("@ss.hasPermi('app:fair:query')")
    @GetMapping(value = "/{jobFairId}")
    public AjaxResult getInfo(@PathVariable("jobFairId") Long jobFairId)
    {
        return success(jobFairService.selectJobFairByJobFairId(jobFairId));
    }

    /**
     * 新增招聘会信息
     */
    @ApiOperation("新增招聘会信息")
    @PreAuthorize("@ss.hasPermi('app:fair:add')")
    @Log(title = "招聘会信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JobFair jobFair)
    {
        return toAjax(jobFairService.insertJobFair(jobFair));
    }

    /**
     * 修改招聘会信息
     */
    @ApiOperation("修改招聘会信息")
    @PreAuthorize("@ss.hasPermi('app:fair:edit')")
    @Log(title = "招聘会信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JobFair jobFair)
    {
        return toAjax(jobFairService.updateJobFair(jobFair));
    }

    /**
     * 删除招聘会信息
     */
    @ApiOperation("删除招聘会信息")
    @PreAuthorize("@ss.hasPermi('app:fair:remove')")
    @Log(title = "招聘会信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{jobFairIds}")
    public AjaxResult remove(@PathVariable Long[] jobFairIds)
    {
        return toAjax(jobFairService.deleteJobFairByJobFairIds(jobFairIds));
    }

}
