package cn.iocoder.yudao.module.exam.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.exam.service.ExamBatchService;
import cn.iocoder.yudao.module.exam.vo.ExamBatchVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 考试批次")
@RestController
@RequestMapping("/examBatch")
@Validated
public class ExamBatchController {

    @Resource
    private ExamBatchService examBatchService;


    @GetMapping("/page")
    @Operation(summary = "获得考试批次分页")
    public CommonResult<IPage<?>> getPage(ExamBatchVO pageReqVO,
                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<ExamBatchVO> page = new Page<>(pageNo,pageSize);
        return success(examBatchService.queryListPage(pageReqVO,page));
    }

    @PostMapping("/create")
    @Operation(summary = "送考")
    public CommonResult<?> createObj( @RequestBody ExamBatchVO examBatchVO) {
        examBatchService.createObj(examBatchVO);
        return success(true);
    }

    @GetMapping("/getById")
    @Operation(summary = "查某一批次详情")
    public CommonResult<?> getById(String id) {
        return success(examBatchService.selectOneById(id));
    }


}