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.TbExamSubjectFormal;
import com.ruoyi.hezhi.service.ITbExamSubjectFormalService;
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-11-13
 */
@RestController
@RequestMapping("/hezhi/examSubjectFormal")
public class TbExamSubjectFormalController extends BaseController
{
    @Autowired
    private ITbExamSubjectFormalService tbExamSubjectFormalService;

    /**
     * 查询正式考试题目列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectFormal:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbExamSubjectFormal tbExamSubjectFormal)
    {
        startPage();
        List<TbExamSubjectFormal> list = tbExamSubjectFormalService.selectTbExamSubjectFormalList(tbExamSubjectFormal);
        return getDataTable(list);
    }

    /**
     * 导出正式考试题目列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectFormal:export')")
    @Log(title = "正式考试题目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbExamSubjectFormal tbExamSubjectFormal)
    {
        List<TbExamSubjectFormal> list = tbExamSubjectFormalService.selectTbExamSubjectFormalList(tbExamSubjectFormal);
        ExcelUtil<TbExamSubjectFormal> util = new ExcelUtil<TbExamSubjectFormal>(TbExamSubjectFormal.class);
        util.exportExcel(response, list, "正式考试题目数据");
    }

    /**
     * 获取正式考试题目详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectFormal:query')")
    @GetMapping(value = "/{examSubjectFormalId}")
    public AjaxResult getInfo(@PathVariable("examSubjectFormalId") Long examSubjectFormalId)
    {
        return success(tbExamSubjectFormalService.selectTbExamSubjectFormalByExamSubjectFormalId(examSubjectFormalId));
    }

    /**
     * 新增正式考试题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectFormal:add')")
    @Log(title = "正式考试题目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbExamSubjectFormal tbExamSubjectFormal)
    {
        return toAjax(tbExamSubjectFormalService.insertTbExamSubjectFormal(tbExamSubjectFormal));
    }

    /**
     * 修改正式考试题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectFormal:edit')")
    @Log(title = "正式考试题目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbExamSubjectFormal tbExamSubjectFormal)
    {
        return toAjax(tbExamSubjectFormalService.updateTbExamSubjectFormal(tbExamSubjectFormal));
    }

    /**
     * 删除正式考试题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectFormal:remove')")
    @Log(title = "正式考试题目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examSubjectFormalIds}")
    public AjaxResult remove(@PathVariable Long[] examSubjectFormalIds)
    {
        return toAjax(tbExamSubjectFormalService.deleteTbExamSubjectFormalByExamSubjectFormalIds(examSubjectFormalIds));
    }
}
