package com.xhkjedu.smarking.controller.report;

import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
import com.xhkjedu.smarking.service.report.reportother.MsrReportparamService;
import com.xhkjedu.smarking.vo.report.reportother.ReportParams;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @Description：考试报告参数
 * @Author: WN
 * @Date: 2024/12/9 15:08:10
 **/
@RestController
@RequestMapping("/rpe")
public class MsrReportparamController {
    @Resource
    MsrReportparamService msrReportparamService;
    /*
     * @Description 考试参数-保存
     * @Date 2024/12/9 15:10:45
     * @Author WN
     * @Param [reportparam]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/save")
    public ResultVo save(@RequestBody ReportParams reportparam) {
        N_Utils.validation(new Object[]{reportparam.getExamid(), "考试id", 1,reportparam.getRpbelong(),"归属菜单",2});

        if(reportparam.getParams() == null || reportparam.getParams().isEmpty()){
            return new ResultVo(1, "参数不能为空");
        }

        msrReportparamService.saveReportparam(reportparam);
        return new ResultVo(0, "保存成功");
    }

    /*
     * @Description 保存参数
     * @Date 2024/12/9 15:12:07
     * @Author WN
     * @Param [gradeparam]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/detail")
    public ResultVo detail(@RequestBody ReportParams gradeparam) {
        N_Utils.validation(new Object[]{gradeparam.getExamid(), "考试id", 1,gradeparam.getRpbelong(),"归属菜单",2});
        List<MsrReportparam> rtnParams = msrReportparamService.listReportparamByRpbelong(gradeparam);
        return new ResultVo(0, "获取成功",rtnParams);
    }
}
