package com.ruoyi.hezhi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.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.hezhi.domain.TbExamBatch;
import com.ruoyi.hezhi.service.ITbExamBatchService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试批次Controller
 *
 * @author ruoyi
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/hezhi/hezhi")
public class TbExamBatchController extends BaseController
{
    @Autowired
    private ITbExamBatchService tbExamBatchService;

    /**
     * 查询考试批次列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:hezhi:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbExamBatch tbExamBatch)
    {
        startPage();
        List<TbExamBatch> list = tbExamBatchService.selectTbExamBatchList(tbExamBatch);
        return getDataTable(list);
    }

    /**
     * 导出考试批次列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:hezhi:export')")
    @Log(title = "考试批次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbExamBatch tbExamBatch)
    {
        List<TbExamBatch> list = tbExamBatchService.selectTbExamBatchList(tbExamBatch);
        ExcelUtil<TbExamBatch> util = new ExcelUtil<TbExamBatch>(TbExamBatch.class);
        util.exportExcel(response, list, "考试批次数据");
    }

    /**
     * 获取考试批次详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:hezhi:query')")
    @GetMapping(value = "/{examBatchId}")
    public AjaxResult getInfo(@PathVariable("examBatchId") Long examBatchId)
    {
        return success(tbExamBatchService.selectTbExamBatchByExamBatchId(examBatchId));
    }

    /**
     * 新增考试批次
     */
    @PreAuthorize("@ss.hasPermi('hezhi:hezhi:add')")
    @Log(title = "考试批次", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbExamBatch tbExamBatch)
    {
        return toAjax(tbExamBatchService.insertTbExamBatch(tbExamBatch));
    }

    /**
     * 修改考试批次
     */
    @PreAuthorize("@ss.hasPermi('hezhi:hezhi:edit')")
    @Log(title = "考试批次", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbExamBatch tbExamBatch)
    {
        return toAjax(tbExamBatchService.updateTbExamBatch(tbExamBatch));
    }

    /**
     * 删除考试批次
     */
    @PreAuthorize("@ss.hasPermi('hezhi:hezhi:remove')")
    @Log(title = "考试批次", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examBatchIds}")
    public AjaxResult remove(@PathVariable Long[] examBatchIds)
    {
        return toAjax(tbExamBatchService.deleteTbExamBatchByExamBatchIds(examBatchIds));
    }
}
