package com.yanzhu.manage.controller;

import com.yanzhu.common.core.utils.poi.ExcelUtil;
import com.yanzhu.common.core.web.controller.BaseController;
import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.common.core.web.page.TableDataInfo;
import com.yanzhu.common.log.annotation.Log;
import com.yanzhu.common.log.enums.BusinessType;
import com.yanzhu.common.security.annotation.RequiresPermissions;
import com.yanzhu.manage.domain.BusExamInfoQues;
import com.yanzhu.manage.service.IBusExamInfoQuesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 试卷问题Controller
 * 
 * @author JiangYuQi
 * @date 2024-08-25
 */
@RestController
@RequestMapping("/busExamInfoQues")
public class BusExamInfoQuesController extends BaseController
{
    @Autowired
    private IBusExamInfoQuesService busExamInfoQuesService;

    /**
     * 查询试卷问题列表
     */
    @RequiresPermissions("manage:busExamInfoQues:list")
    @GetMapping("/list")
    public TableDataInfo list(BusExamInfoQues busExamInfoQues)
    {
        startPage();
        List<BusExamInfoQues> list = busExamInfoQuesService.selectBusExamInfoQuesList(busExamInfoQues);
        return getDataTable(list);
    }

    /**
     * 导出试卷问题列表
     */
    @RequiresPermissions("manage:busExamInfoQues:export")
    @Log(title = "试卷问题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusExamInfoQues busExamInfoQues)
    {
        List<BusExamInfoQues> list = busExamInfoQuesService.selectBusExamInfoQuesList(busExamInfoQues);
        ExcelUtil<BusExamInfoQues> util = new ExcelUtil<BusExamInfoQues>(BusExamInfoQues.class);
        util.exportExcel(response, list, "试卷问题数据");
    }

    /**
     * 获取试卷问题详细信息
     */
    @RequiresPermissions("manage:busExamInfoQues:query")
    @GetMapping(value = "/{examId}")
    public AjaxResult getInfo(@PathVariable("examId") Long examId)
    {
        return success(busExamInfoQuesService.selectBusExamInfoQuesByExamId(examId));
    }

    /**
     * 新增试卷问题
     */
    @RequiresPermissions("manage:busExamInfoQues:add")
    @Log(title = "试卷问题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusExamInfoQues busExamInfoQues)
    {
        return toAjax(busExamInfoQuesService.insertBusExamInfoQues(busExamInfoQues));
    }

    /**
     * 修改试卷问题
     */
    @RequiresPermissions("manage:busExamInfoQues:edit")
    @Log(title = "试卷问题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusExamInfoQues busExamInfoQues)
    {
        return toAjax(busExamInfoQuesService.updateBusExamInfoQues(busExamInfoQues));
    }

    /**
     * 删除试卷问题
     */
    @RequiresPermissions("manage:busExamInfoQues:remove")
    @Log(title = "试卷问题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examIds}")
    public AjaxResult remove(@PathVariable Long[] examIds)
    {
        return toAjax(busExamInfoQuesService.deleteBusExamInfoQuesByExamIds(examIds));
    }
}
