package com.xinyilu.web.controller.bodyShape;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.system.service.bodyShape.BodyShapeService;
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-10 09:53:17
 */
@RestController
@RequestMapping("/body/shape")
public class BodyShapeController extends BaseController {

    @Resource
    private BodyShapeService bodyShapeService;

    /**
     * 根据学习id查询学生身体形态测试数据分析
     *
     * @param studentId 学生id
     * @param batchCode 批次编号
     * @return 学生分析结果
     * @throws Exception 异常信息
     */
    @PreAuthorize("@ss.hasPermi('body:shape:analysis')")
    @GetMapping("/analysis")
    public AjaxResult getBodyShapeAnalysis(Long studentId, String batchCode) throws Exception {
        if (Objects.isNull(studentId)) {
            return AjaxResult.error("请选择学生信息！");
        }
        if (StringUtils.isBlank(batchCode)) {
            return AjaxResult.error("请选择所属批次！");
        }
        return bodyShapeService.getBodyShapeAnalysis(studentId, batchCode);
    }
}
