package com.xinyilu.web.controller.childrenRanking;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.system.service.childrenRanking.ChildrenRankingService;
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 18:00:12
 * @Version 1.0
 */
@RestController
@RequestMapping("/children/ranking")
public class ChildrenRankingController extends BaseController {

    @Resource
    private ChildrenRankingService childrenRankingService;

    /**
     * 查询幼儿体质综合排名信息
     *
     * @param studentId 学生id
     * @param batchCode 批次编号
     * @return 排名信息
     */
    @PreAuthorize("@ss.hasPermi('children:ranking:analysis')")
    @GetMapping("/analysis")
    public AjaxResult getChildrenRankingInfo(Long studentId, String batchCode) {
        if (Objects.isNull(studentId)) {
            return AjaxResult.error("请选择学生信息！");
        }
        if (StringUtils.isBlank(batchCode)) {
            return AjaxResult.error("请选择所属批次！");
        }
        return childrenRankingService.getChildrenRankingInfo(studentId, batchCode);
    }
}
