package com.xinyilu.web.controller.kindergartenSideAnalysis;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.system.service.kindergartenSideAnalysis.KindergartenSideAnalysisService;
import org.apache.commons.lang3.StringUtils;
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;

/**
 * @Description  幼儿园体侧项目各年龄段人数分布以及达标率控制器
 * @Author 纪寒
 * @Date 2022-08-13 15:15:55
 * @Version 1.0
 */
@RestController
@RequestMapping("/kindergarten/side")
public class KindergartenSideAnalysisController extends BaseController {

    @Resource
    private KindergartenSideAnalysisService kindergartenSideAnalysisService;

    /**
     * 查询幼儿园下测试项目某个批次的数据分析信息
     *
     * @param kindergartenId 幼儿园id
     * @param batchCode      批次号
     * @return 数据分析
     * @throws Exception 异常信息
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:side:analysis')")
    @GetMapping("/analysis")
    public AjaxResult getKindergartenSideAnalysisInfo(Long kindergartenId, String batchCode) throws Exception {
        if (Objects.isNull(kindergartenId)) {
            return AjaxResult.error("请选择所属幼儿园信息！");
        }
        if (StringUtils.isBlank(batchCode)) {
            return AjaxResult.error("请选择所属批次！");
        }
        return kindergartenSideAnalysisService.getKindergartenSideAnalysisInfo(kindergartenId, batchCode);
    }
}
