package com.xhkjedu.smarking.controller.paper;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhkjedu.smarking.model.paper.MsPaperBack;
import com.xhkjedu.smarking.service.paper.MsPaperBackService;
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("/msPaperBack")
public class MsPaperBackController {
    @Resource
    private MsPaperBackService msPaperBackService;

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

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