package com.ningdatech.carapi.archives.controller;

import javax.validation.Valid;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.archives.manage.ExaminationPaperManage;
import com.ningdatech.carapi.archives.model.po.ReqExamPaperListPO;
import com.ningdatech.carapi.archives.model.po.ReqExamRulePO;
import com.ningdatech.carapi.archives.model.po.ReqSaveExamPaperPO;
import com.ningdatech.carapi.archives.model.po.ReqSaveExamRulePO;
import com.ningdatech.carapi.archives.model.vo.ResExamPaperListVO;
import com.ningdatech.carapi.archives.model.vo.ResExamPaperVO;
import com.ningdatech.carapi.archives.model.vo.ResExamRuleVO;
import com.ningdatech.log.annotation.WebLog;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

/**
 * @author liuxinxin
 * @date 2022/10/17 下午4:07
 */
@RequestMapping("/api/v1/exam-paper")
@Validated
@RestController
@Api(tags = "培训试卷")
@RequiredArgsConstructor
public class ExaminationPaperController {

    private final ExaminationPaperManage examinationPaperManage;

    @PostMapping("/save")
    @ApiOperation("保存培训试卷")
    @WebLog
    public void saveExamPaper(@Valid @RequestBody ReqSaveExamPaperPO po) {
        examinationPaperManage.saveExamPaper(po);
    }

    @PostMapping("/get/{examPaperId}")
    @ApiOperation("获取培训试卷")
    public ResExamPaperVO getExamPaperId(@Valid @PathVariable Long examPaperId) {
        return examinationPaperManage.getExamPaperId(examPaperId);
    }

    @PostMapping("/list")
    @ApiOperation("培训试卷列表")
    public PageVo<ResExamPaperListVO> listExamPaper(@Valid @RequestBody ReqExamPaperListPO request) {
        return examinationPaperManage.listExamPaper(request);
    }

    @PostMapping("/save/exam-rule")
    @ApiOperation("保存试卷规则-全局配置")
    @WebLog
    public void saveExamRule(@Valid @RequestBody ReqSaveExamRulePO request) {
        examinationPaperManage.saveExamRule(request);
    }

    @PostMapping("/get/exam-rule")
    @ApiOperation("获取试卷规则-全局配置")
    public ResExamRuleVO getExamRule(@Valid @RequestBody ReqExamRulePO request) {
        return examinationPaperManage.getExamRule(request);
    }

    @PostMapping("/delete/{id}")
    @ApiOperation("删除试卷")
    @WebLog
    public void deleteExamPaper(@PathVariable("id") Long id) {
        examinationPaperManage.deleteExamPaper(id);
    }

}
