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.BusExamQuestionResult;
import com.yanzhu.manage.service.IBusExamQuestionResultService;
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("/busExamQuestionResult")
public class BusExamQuestionResultController extends BaseController
{
    @Autowired
    private IBusExamQuestionResultService busExamQuestionResultService;

    /**
     * 查询题库问题列表
     */
    @RequiresPermissions("manage:busExamQuestionResult:list")
    @GetMapping("/list")
    public TableDataInfo list(BusExamQuestionResult busExamQuestionResult)
    {
        startPage();
        List<BusExamQuestionResult> list = busExamQuestionResultService.selectBusExamQuestionResultList(busExamQuestionResult);
        return getDataTable(list);
    }

    /**
     * 导出题库问题列表
     */
    @RequiresPermissions("manage:busExamQuestionResult:export")
    @Log(title = "题库问题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusExamQuestionResult busExamQuestionResult)
    {
        List<BusExamQuestionResult> list = busExamQuestionResultService.selectBusExamQuestionResultList(busExamQuestionResult);
        ExcelUtil<BusExamQuestionResult> util = new ExcelUtil<BusExamQuestionResult>(BusExamQuestionResult.class);
        util.exportExcel(response, list, "题库问题数据");
    }

    /**
     * 获取题库问题详细信息
     */
    @RequiresPermissions("manage:busExamQuestionResult:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busExamQuestionResultService.selectBusExamQuestionResultById(id));
    }

    /**
     * 新增题库问题
     */
    @RequiresPermissions("manage:busExamQuestionResult:add")
    @Log(title = "题库问题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusExamQuestionResult busExamQuestionResult)
    {
        return toAjax(busExamQuestionResultService.insertBusExamQuestionResult(busExamQuestionResult));
    }

    /**
     * 修改题库问题
     */
    @RequiresPermissions("manage:busExamQuestionResult:edit")
    @Log(title = "题库问题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusExamQuestionResult busExamQuestionResult)
    {
        return toAjax(busExamQuestionResultService.updateBusExamQuestionResult(busExamQuestionResult));
    }

    /**
     * 删除题库问题
     */
    @RequiresPermissions("manage:busExamQuestionResult:remove")
    @Log(title = "题库问题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busExamQuestionResultService.deleteBusExamQuestionResultByIds(ids));
    }
}
