package com.xinyilu.web.controller.testItemAvgScoreinfo;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.system.service.testItemAvgScoreinfo.ITestItemAvgScoreService;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @author ljh
 * @version 1.0
 * Create by 2022/8/15 16:02
 */

@RestController
@RequestMapping("/system/testItemAvgScore")
public class TestItemAvgScoreController extends BaseController {

    @Resource
    private ITestItemAvgScoreService testItemAvgScoreService;

    /**
     * @param classId        班级id
     * @param kindergartenId 幼儿园id
     * @param batchCode      批次编号
     * @return com.xinyilu.common.core.domain.AjaxResult
     * @date 11:41
     * @author ljh
     * @description 根据幼儿园查询某班级各项目的平均分
     **/
    @PreAuthorize("@ss.hasPermi('system:testItemAvgScore:list')")
    @GetMapping("/ClassList")
    public AjaxResult classList(@Param("classId") Long classId, @Param("kindergartenId") Long kindergartenId, @Param("batchCode") String batchCode) {
        if (Objects.isNull(kindergartenId)) {
            return AjaxResult.error("请选择所属幼儿园信息！");
        }
        if (Objects.isNull(classId)) {
            return AjaxResult.error("请选择所属班级信息！");
        }
        if (Objects.isNull(batchCode)) {
            return AjaxResult.error("请选择所属批次！");
        }
        return testItemAvgScoreService.selectTestItemAvgScoreList(classId, kindergartenId, batchCode);
    }

}
