package com.xinyilu.web.controller.averageHeightAndWeight;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.system.service.averageHeightAndWeight.AverageHeightAndWeightService;
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-15 14:13:11
 * @Version 1.0
 */
@RestController
@RequestMapping("/average/heightAndWeight")
public class AverageHeightAndWeightController extends BaseController {

    @Resource
    private AverageHeightAndWeightService averageHeightAndWeightService;

    /**
     * 根据幼儿id和批次编号查询各年级平均身高和平均成绩信息
     *
     * @param kindergartenId 幼儿园id
     * @param batchCode      批次编号
     * @return 平均身高和平均体重信息
     */
    @PreAuthorize("@ss.hasPermi('average:heightAndWeight:analysis')")
    @GetMapping("/analysis")
    public AjaxResult getHeightAndWeightAvgScoreInfo(Long kindergartenId, String batchCode) {
        if (Objects.isNull(kindergartenId)) {
            return AjaxResult.error("请选择所属幼儿园信息！");
        }
        if (StringUtils.isBlank(batchCode)) {
            return AjaxResult.error("请选择所属批次！");
        }
        return averageHeightAndWeightService.getHeightAndWeightAvgScoreInfo(kindergartenId, batchCode);
    }
}
