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.TbExamFile;
import com.ruoyi.hezhi.service.ITbExamFileService;
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-14
 */
@RestController
@RequestMapping("/hezhi/examFile")
public class TbExamFileController extends BaseController
{
    @Autowired
    private ITbExamFileService tbExamFileService;

    /**
     * 查询考试拍摄文件列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examFile:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbExamFile tbExamFile)
    {
        startPage();
        List<TbExamFile> list = tbExamFileService.selectTbExamFileList(tbExamFile);
        return getDataTable(list);
    }

    /**
     * 导出考试拍摄文件列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examFile:export')")
    @Log(title = "考试拍摄文件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbExamFile tbExamFile)
    {
        List<TbExamFile> list = tbExamFileService.selectTbExamFileList(tbExamFile);
        ExcelUtil<TbExamFile> util = new ExcelUtil<TbExamFile>(TbExamFile.class);
        util.exportExcel(response, list, "考试拍摄文件数据");
    }

    /**
     * 获取考试拍摄文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examFile:query')")
    @GetMapping(value = "/{examFileId}")
    public AjaxResult getInfo(@PathVariable("examFileId") Long examFileId)
    {
        return success(tbExamFileService.selectTbExamFileByExamFileId(examFileId));
    }

    /**
     * 新增考试拍摄文件
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examFile:add')")
    @Log(title = "考试拍摄文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbExamFile tbExamFile)
    {
        return toAjax(tbExamFileService.insertTbExamFile(tbExamFile));
    }

    /**
     * 修改考试拍摄文件
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examFile:edit')")
    @Log(title = "考试拍摄文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbExamFile tbExamFile)
    {
        return toAjax(tbExamFileService.updateTbExamFile(tbExamFile));
    }

    /**
     * 删除考试拍摄文件
     */
    @PreAuthorize("@ss.hasPermi('hezhi:examFile:remove')")
    @Log(title = "考试拍摄文件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examFileIds}")
    public AjaxResult remove(@PathVariable Long[] examFileIds)
    {
        return toAjax(tbExamFileService.deleteTbExamFileByExamFileIds(examFileIds));
    }
}
