package com.xinyilu.web.controller.TestBodyScoreInfo;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.page.TableDataInfo;
import com.xinyilu.common.exception.ServiceException;
import com.xinyilu.system.domain.vo.TestBodyScoreInfoVO;
import com.xinyilu.system.service.TestBodyScoreInfo.ITestBodyScoreInfoService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;
import java.util.Objects;


/**
 * @author ljh
 * @version 1.0
 * Create by 2022/8/9 15:03
 * 身体素质测试
 */
@RestController
@RequestMapping("/system/testBodyScoreInfo")
public class TestBodyScoreInfoController extends BaseController {

    @Autowired
    private ITestBodyScoreInfoService testBodyScoreInfoService;

    /**
     * 身体素质测试列表
     */
    @PreAuthorize("@ss.hasPermi('system:testBodyScoreInfo:list')")
    @GetMapping("/listBody")
    public TableDataInfo list(@Param("studentId") Long studentId, @Param("batchCode") String batchCode) {
        if (Objects.isNull(studentId)) {
            throw new ServiceException("请选择学生信息！");
        }
        if (Objects.isNull(batchCode)) {
            throw new ServiceException("请选择所属批次！");
        }
        startPage();
        List<TestBodyScoreInfoVO> testBodyScoreInfos = testBodyScoreInfoService.selectTestBodyScoreList(studentId, batchCode);
        return getDataTable(testBodyScoreInfos);
    }

    /**
     * 查询级别信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:parentInfo:list')")
    @GetMapping("/listStandard")
    public TableDataInfo list(TestBodyScoreInfoVO testBodyScoreInfoVO) {
        startPage();
        List<TestBodyScoreInfoVO> testBodyStandardList = testBodyScoreInfoService.getTestBodyStandardList(testBodyScoreInfoVO);
        return getDataTable(testBodyStandardList);
    }

}
