package com.xinyilu.web.controller.physiqueAnalysis;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.system.service.physiqueAnalysis.PhysiqueAnalysisService;
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-11 09:24:13
 * @Version 1.0
 */
@RestController
@RequestMapping("/physique/analysis")
public class PhysiqueAnalysisController extends BaseController {
    @Resource
    private PhysiqueAnalysisService physiqueAnalysisService;

    /**
     * 根据学生id和批次编号统计学生体质综合分析数据
     *
     * @param studentId 学生id
     * @param batchCode 批次编码
     * @return 分析数据结果
     * @throws Exception 异常信息
     */
    @PreAuthorize("@ss.hasPermi('physique:analysis:synthesize')")
    @GetMapping("/synthesize")
    public AjaxResult getPhysiqueAnalysisInfo(Long studentId, String batchCode) throws Exception {
        if (Objects.isNull(studentId)) {
            return AjaxResult.error("请选择学生信息！");
        }
        if (StringUtils.isBlank(batchCode)) {
            return AjaxResult.error("请选择所属批次！");
        }
        return physiqueAnalysisService.getPhysiqueAnalysisInfo(studentId, batchCode);
    }
}
