package com.ruoyi.sim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.sim.service.impl.RealExamCollectionDeptService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sim.domain.RealExamCollectionDept;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试集合班级关联Controller
 *
 * @author tom
 * @date 2024-12-13
 */
@RestController
@RequestMapping("/sim/real-exam-collection-dept")
public class RealExamCollectionDeptController extends BaseController {
    @Autowired
    private RealExamCollectionDeptService realExamCollectionDeptService;

    /**
     * 查询考试集合班级关联列表
     */
    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection-dept:list')")
    @GetMapping("/list")
    public TableDataInfo list(RealExamCollectionDept realExamCollectionDept) {
        startPage();
        List<RealExamCollectionDept> list = realExamCollectionDeptService.selectRealExamCollectionDeptList(realExamCollectionDept);
        return getDataTable(list);
    }

    /**
     * 导出考试集合班级关联列表
     */
    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection-dept:export')")
    @Log(title = "考试集合班级关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RealExamCollectionDept realExamCollectionDept) {
        List<RealExamCollectionDept> list = realExamCollectionDeptService.selectRealExamCollectionDeptList(realExamCollectionDept);
        ExcelUtil<RealExamCollectionDept> util = new ExcelUtil<RealExamCollectionDept>(RealExamCollectionDept.class);
        util.exportExcel(response, list, "考试集合班级关联数据");
    }

    /**
     * 获取考试集合班级关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection-dept:query')")
    @GetMapping(value = "/{relId}")
    public AjaxResult getInfo(@PathVariable("relId") Long relId) {
        return success(realExamCollectionDeptService.selectRealExamCollectionDeptByRelId(relId));
    }

    /**
     * 新增考试集合班级关联
     */
    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection-dept:add')")
    @Log(title = "考试集合班级关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RealExamCollectionDept realExamCollectionDept) {
        return toAjax(realExamCollectionDeptService.insertRealExamCollectionDept(realExamCollectionDept));
    }

    /**
     * 修改考试集合班级关联
     */
    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection-dept:edit')")
    @Log(title = "考试集合班级关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RealExamCollectionDept realExamCollectionDept) {
        return toAjax(realExamCollectionDeptService.updateRealExamCollectionDept(realExamCollectionDept));
    }

    /**
     * 删除考试集合班级关联
     */
    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection-dept:remove')")
    @Log(title = "考试集合班级关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{relIds}")
    public AjaxResult remove(@PathVariable Long[] relIds) {
        return toAjax(realExamCollectionDeptService.deleteRealExamCollectionDeptByRelIds(relIds));
    }
}
