package com.xhkjedu.smarking.controller.stupaper;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock;
import com.xhkjedu.smarking.service.stupaper.MsPaperStudentBlockService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.utils.PageUtil;
import com.xhkjedu.vo.PageResult;
import com.xhkjedu.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 阅卷试卷学生题块相关操作
 * @Author auto
 * @Date 2024-10-15
 */
@RestController
@RequestMapping("/msPaperStudentBlock")
public class MsPaperStudentBlockController {
    @Resource
    private MsPaperStudentBlockService msPaperStudentBlockService;

    /**
     * @Description 新增
     * @Param [msPaperStudentBlock]
     * @Author auto
     * @Date 2024-10-15
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/save")
    public ResultVo save(@RequestBody MsPaperStudentBlock msPaperStudentBlock) {
        msPaperStudentBlockService.add(msPaperStudentBlock);
        return new ResultVo(0, "保存成功！");
    }

    /**
     * @Description 列表
     * @Param [msPaperStudentBlock]
     * @Author auto
     * @Date 2024-10-15
     * @return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/list")
    public ResultVo queryList(@RequestBody MsPaperStudentBlock msPaperStudentBlock) {
        Integer page = msPaperStudentBlock.getPage();
        Integer size = msPaperStudentBlock.getPageSize();
        N_Utils.validation(new Object[]{page, "显示页码", 1, size, "显示条数", 1});
        PageHelper.startPage(page, size);
        List<MsPaperStudentBlock> list = msPaperStudentBlockService.queryList(msPaperStudentBlock);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
        return new ResultVo(0, "查询成功！", pageResult);
    }
}
