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.BusExamInfo;
import com.yanzhu.manage.service.IBusExamInfoService;
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("/busExamInfo")
public class BusExamInfoController extends BaseController
{
    @Autowired
    private IBusExamInfoService busExamInfoService;

    /**
     * 查询基础试卷列表
     */
    @RequiresPermissions("manage:busExamInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(BusExamInfo busExamInfo)
    {
        startPage();
        List<BusExamInfo> list = busExamInfoService.selectBusExamInfoList(busExamInfo);
        return getDataTable(list);
    }

    /**
     * 导出基础试卷列表
     */
    @RequiresPermissions("manage:busExamInfo:export")
    @Log(title = "基础试卷", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusExamInfo busExamInfo)
    {
        List<BusExamInfo> list = busExamInfoService.selectBusExamInfoList(busExamInfo);
        ExcelUtil<BusExamInfo> util = new ExcelUtil<BusExamInfo>(BusExamInfo.class);
        util.exportExcel(response, list, "基础试卷数据");
    }

    /**
     * 获取基础试卷详细信息
     */
    @RequiresPermissions("manage:busExamInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busExamInfoService.selectBusExamInfoById(id));
    }

    /**
     * 新增基础试卷
     */
    @RequiresPermissions("manage:busExamInfo:add")
    @Log(title = "基础试卷", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusExamInfo busExamInfo)
    {
        return toAjax(busExamInfoService.insertBusExamInfo(busExamInfo));
    }

    /**
     * 修改基础试卷
     */
    @RequiresPermissions("manage:busExamInfo:edit")
    @Log(title = "基础试卷", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusExamInfo busExamInfo)
    {
        return toAjax(busExamInfoService.updateBusExamInfo(busExamInfo));
    }

    /**
     * 删除基础试卷
     */
    @RequiresPermissions("manage:busExamInfo:remove")
    @Log(title = "基础试卷", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busExamInfoService.deleteBusExamInfoByIds(ids));
    }
}
