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.BusExamUserResult;
import com.yanzhu.manage.service.IBusExamUserResultService;
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("/busExamUserResult")
public class BusExamUserResultController extends BaseController
{
    @Autowired
    private IBusExamUserResultService busExamUserResultService;

    /**
     * 查询用户试卷结果列表
     */
    @RequiresPermissions("manage:busExamUserResult:list")
    @GetMapping("/list")
    public TableDataInfo list(BusExamUserResult busExamUserResult)
    {
        startPage();
        List<BusExamUserResult> list = busExamUserResultService.selectBusExamUserResultList(busExamUserResult);
        return getDataTable(list);
    }

    /**
     * 导出用户试卷结果列表
     */
    @RequiresPermissions("manage:busExamUserResult:export")
    @Log(title = "用户试卷结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusExamUserResult busExamUserResult)
    {
        List<BusExamUserResult> list = busExamUserResultService.selectBusExamUserResultList(busExamUserResult);
        ExcelUtil<BusExamUserResult> util = new ExcelUtil<BusExamUserResult>(BusExamUserResult.class);
        util.exportExcel(response, list, "用户试卷结果数据");
    }

    /**
     * 获取用户试卷结果详细信息
     */
    @RequiresPermissions("manage:busExamUserResult:query")
    @GetMapping(value = "/{examUserId}")
    public AjaxResult getInfo(@PathVariable("examUserId") Long examUserId)
    {
        return success(busExamUserResultService.selectBusExamUserResultByExamUserId(examUserId));
    }

    /**
     * 新增用户试卷结果
     */
    @RequiresPermissions("manage:busExamUserResult:add")
    @Log(title = "用户试卷结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusExamUserResult busExamUserResult)
    {
        return toAjax(busExamUserResultService.insertBusExamUserResult(busExamUserResult));
    }

    /**
     * 修改用户试卷结果
     */
    @RequiresPermissions("manage:busExamUserResult:edit")
    @Log(title = "用户试卷结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusExamUserResult busExamUserResult)
    {
        return toAjax(busExamUserResultService.updateBusExamUserResult(busExamUserResult));
    }

    /**
     * 删除用户试卷结果
     */
    @RequiresPermissions("manage:busExamUserResult:remove")
    @Log(title = "用户试卷结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examUserIds}")
    public AjaxResult remove(@PathVariable Long[] examUserIds)
    {
        return toAjax(busExamUserResultService.deleteBusExamUserResultByExamUserIds(examUserIds));
    }
}
