package com.xinyilu.web.controller.kinderPhysiqueAnalysis;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.system.service.kinderPhysiqueAnalysis.KinderPhysiqueAnalysisService;
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 18:34:31
 * @Version 1.0
 */
@RestController
@RequestMapping("/kindergarten/physique")
public class KinderPhysiqueAnalysisController extends BaseController {

    @Resource
    private KinderPhysiqueAnalysisService kinderPhysiqueAnalysisService;

    /**
     * 根据幼儿园id和批次信息查询综合体质分析数据
     *
     * @param kindergartenId 幼儿园id
     * @param batchCode      批次编号
     * @param studentSex     性别
     * @return AjaxResult 综合体质分析数据
     * @throws Exception 异常信息
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:physique:analysis')")
    @GetMapping("/analysis")
    public AjaxResult getKinderPhysiqueAnalysis(Long kindergartenId, String batchCode, String studentSex) throws Exception {
        if (Objects.isNull(kindergartenId)) {
            return AjaxResult.error("请选择所属幼儿园信息！");
        }
        if (StringUtils.isBlank(batchCode)) {
            return AjaxResult.error("请选择所属批次！");
        }
        if (StringUtils.isBlank(studentSex)) {
            return AjaxResult.error("请选择学生性别！");
        }
        return kinderPhysiqueAnalysisService.getKinderPhysiqueAnalysis(kindergartenId, batchCode, studentSex);
    }
}
