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.TbExamSubjectAnswer;
import com.ruoyi.hezhi.service.ITbExamSubjectAnswerService;
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-04
 */
@RestController
@RequestMapping("/hezhi/examSubjectAnswer")
public class TbExamSubjectAnswerController extends BaseController
{
    @Autowired
    private ITbExamSubjectAnswerService tbExamSubjectAnswerService;

    /**
     * 查询考试题目答案选项列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectAnswer:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbExamSubjectAnswer tbExamSubjectAnswer)
    {
        startPage();
        List<TbExamSubjectAnswer> list = tbExamSubjectAnswerService.selectTbExamSubjectAnswerList(tbExamSubjectAnswer);
        return getDataTable(list);
    }

    /**
     * 导出考试题目答案选项列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectAnswer:export')")
    @Log(title = "考试题目答案选项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbExamSubjectAnswer tbExamSubjectAnswer)
    {
        List<TbExamSubjectAnswer> list = tbExamSubjectAnswerService.selectTbExamSubjectAnswerList(tbExamSubjectAnswer);
        ExcelUtil<TbExamSubjectAnswer> util = new ExcelUtil<TbExamSubjectAnswer>(TbExamSubjectAnswer.class);
        util.exportExcel(response, list, "考试题目答案选项数据");
    }

    /**
     * 获取考试题目答案选项详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectAnswer:query')")
    @GetMapping(value = "/{examSubjectAnswerId}")
    public AjaxResult getInfo(@PathVariable("examSubjectAnswerId") Long examSubjectAnswerId)
    {
        return success(tbExamSubjectAnswerService.selectTbExamSubjectAnswerByExamSubjectAnswerId(examSubjectAnswerId));
    }

    /**
     * 新增考试题目答案选项
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectAnswer:add')")
    @Log(title = "考试题目答案选项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbExamSubjectAnswer tbExamSubjectAnswer)
    {
        return toAjax(tbExamSubjectAnswerService.insertTbExamSubjectAnswer(tbExamSubjectAnswer));
    }

    /**
     * 修改考试题目答案选项
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectAnswer:edit')")
    @Log(title = "考试题目答案选项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbExamSubjectAnswer tbExamSubjectAnswer)
    {
        return toAjax(tbExamSubjectAnswerService.updateTbExamSubjectAnswer(tbExamSubjectAnswer));
    }

    /**
     * 删除考试题目答案选项
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examSubjectAnswer:remove')")
    @Log(title = "考试题目答案选项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examSubjectAnswerIds}")
    public AjaxResult remove(@PathVariable Long[] examSubjectAnswerIds)
    {
        return toAjax(tbExamSubjectAnswerService.deleteTbExamSubjectAnswerByExamSubjectAnswerIds(examSubjectAnswerIds));
    }
}
