package com.ruoyi.hezhi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.hezhi.domain.TbExamNotice;
import com.ruoyi.hezhi.service.ITbExamNoticeService;
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.List;

/**
 * 考试通知Controller
 *
 * @author ruoyi
 * @date 2024-10-16
 */
@RestController
@RequestMapping("/hezhi/examNotice")
public class TbExamNoticeController extends BaseController
{
    @Autowired
    private ITbExamNoticeService tbExamNoticeService;

    /**
     * 查询考试通知列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examNotice:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbExamNotice tbExamNotice)
    {
        startPage();
        List<TbExamNotice> list = tbExamNoticeService.selectTbExamNoticeList(tbExamNotice);
        return getDataTable(list);
    }

    /**
     * 导出考试通知列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examNotice:export')")
    @Log(title = "考试通知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbExamNotice tbExamNotice)
    {
        List<TbExamNotice> list = tbExamNoticeService.selectTbExamNoticeList(tbExamNotice);
        ExcelUtil<TbExamNotice> util = new ExcelUtil<TbExamNotice>(TbExamNotice.class);
        util.exportExcel(response, list, "考试通知数据");
    }

    /**
     * 获取考试通知详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examNotice:query')")
    @GetMapping(value = "/{examNoticeId}")
    public AjaxResult getInfo(@PathVariable("examNoticeId") Long examNoticeId)
    {
        return success(tbExamNoticeService.selectTbExamNoticeByExamNoticeId(examNoticeId));
    }

    /**
     * 新增考试通知
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examNotice:add')")
    @Log(title = "考试通知", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbExamNotice tbExamNotice)
    {
        return toAjax(tbExamNoticeService.insertTbExamNotice(tbExamNotice));
    }

    /**
     * 修改考试通知
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examNotice:edit')")
    @Log(title = "考试通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbExamNotice tbExamNotice)
    {
        return toAjax(tbExamNoticeService.updateTbExamNotice(tbExamNotice));
    }

    /**
     * 删除考试通知
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examNotice:remove')")
    @Log(title = "考试通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examNoticeIds}")
    public AjaxResult remove(@PathVariable Long[] examNoticeIds)
    {
        return toAjax(tbExamNoticeService.deleteTbExamNoticeByExamNoticeIds(examNoticeIds));
    }
}
