package com.xhkjedu.smarking.controller.wholeparam;

import com.xhkjedu.smarking.model.wholeparam.MspReportparam;
import com.xhkjedu.smarking.service.wholeparam.MspReportparamService;
import com.xhkjedu.smarking.vo.wholeparam.GradeParams;
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/2 16:46:46
 **/
@RestController
@RequestMapping("/rparam")
public class MspReportparamController {
    @Resource
    private MspReportparamService mspReportparamService;

    /*
     * @Description 保存
     * @Date 2024/12/2 17:02:16
     * @Author WN
     * @Param [mspGradeparam]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/save")
    public ResultVo save(@RequestBody GradeParams gradeparam) {
        N_Utils.validation(new Object[]{gradeparam.getSchoolid(), "学校id", 1,gradeparam.getRpbelong(),"归属菜单",2});
        if(gradeparam.getGradeid() == null){
            return new ResultVo(1, "年级不能为空");
        }
        if(gradeparam.getParams() == null || gradeparam.getParams().isEmpty()){
            return new ResultVo(1, "参数不能为空");
        }

        mspReportparamService.saveGradeparam(gradeparam);
        return new ResultVo(0, "保存成功",gradeparam);
    }

    /* 获取详情
     * @Description
     * @Date 2024/12/2 17:04:11
     * @Author WN
     * @Param [mspGradeparam]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/detail")
    public ResultVo detail(@RequestBody GradeParams gradeparam) {
        N_Utils.validation(new Object[]{gradeparam.getSchoolid(), "学校id", 1,gradeparam.getRpbelong(),"归属菜单",2});
        if(gradeparam.getGradeid() == null){
            return new ResultVo(1, "年级不能为空");
        }
        List<MspReportparam> rtnParams = mspReportparamService.getMspGradeparam(gradeparam);
        return new ResultVo(0, "保存成功",rtnParams);
    }



}
