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.TbExamSubjectSimulate;
import com.ruoyi.hezhi.service.ITbExamSubjectSimulateService;
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-08
 */
@RestController
@RequestMapping("/hezhi/examSubjectSimulate")
public class TbExamSubjectSimulateController extends BaseController
{
    @Autowired
    private ITbExamSubjectSimulateService tbExamSubjectSimulateService;

    /**
     * 查询模拟考试题目列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectSimulate:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbExamSubjectSimulate tbExamSubjectSimulate)
    {
        startPage();
        List<TbExamSubjectSimulate> list = tbExamSubjectSimulateService.selectTbExamSubjectSimulateList(tbExamSubjectSimulate);
        return getDataTable(list);
    }

    /**
     * 导出模拟考试题目列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectSimulate:export')")
    @Log(title = "模拟考试题目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbExamSubjectSimulate tbExamSubjectSimulate)
    {
        List<TbExamSubjectSimulate> list = tbExamSubjectSimulateService.selectTbExamSubjectSimulateList(tbExamSubjectSimulate);
        ExcelUtil<TbExamSubjectSimulate> util = new ExcelUtil<TbExamSubjectSimulate>(TbExamSubjectSimulate.class);
        util.exportExcel(response, list, "模拟考试题目数据");
    }

    /**
     * 获取模拟考试题目详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectSimulate:query')")
    @GetMapping(value = "/{examSubjectSimulateId}")
    public AjaxResult getInfo(@PathVariable("examSubjectSimulateId") Long examSubjectSimulateId)
    {
        return success(tbExamSubjectSimulateService.selectTbExamSubjectSimulateByExamSubjectSimulateId(examSubjectSimulateId));
    }

    /**
     * 新增模拟考试题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectSimulate:add')")
    @Log(title = "模拟考试题目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbExamSubjectSimulate tbExamSubjectSimulate)
    {
        return toAjax(tbExamSubjectSimulateService.insertTbExamSubjectSimulate(tbExamSubjectSimulate));
    }

    /**
     * 修改模拟考试题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectSimulate:edit')")
    @Log(title = "模拟考试题目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbExamSubjectSimulate tbExamSubjectSimulate)
    {
        return toAjax(tbExamSubjectSimulateService.updateTbExamSubjectSimulate(tbExamSubjectSimulate));
    }

    /**
     * 删除模拟考试题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectSimulate:remove')")
    @Log(title = "模拟考试题目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examSubjectSimulateIds}")
    public AjaxResult remove(@PathVariable Long[] examSubjectSimulateIds)
    {
        return toAjax(tbExamSubjectSimulateService.deleteTbExamSubjectSimulateByExamSubjectSimulateIds(examSubjectSimulateIds));
    }
}
