package com.xinyilu.web.controller.testActionDevelopmentInfo;

import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.common.core.page.TableDataInfo;
import com.xinyilu.common.exception.ServiceException;
import com.xinyilu.system.domain.vo.testActionDevelopment.TestActionDevelopmentVO;
import com.xinyilu.system.service.testActionDevelopmentInfo.Impl.TestActionDevelopmentServiceImpl;
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/10 17:08
 */
@RestController
@RequestMapping("/system/testActionDevelopment")
public class TestActionDevelopmentController extends BaseController {

    @Autowired
    private TestActionDevelopmentServiceImpl testActionDevelopmentService;

    /**
     * 动作发展检测列表
     *
     * @param studentId 学生id
     * @param batchCode 批次编号
     * @return TableDataInfo 列表信息
     */
    @PreAuthorize("@ss.hasPermi('system:testBodyScoreInfo:list')")
    @GetMapping("/listAction")
    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<TestActionDevelopmentVO> testItemScoreInfo = testActionDevelopmentService.selectTestActionDevelopmentList(studentId, batchCode);
        return getDataTable(testItemScoreInfo);
    }


    /**
     * 动作发展检测列表  匹配运动处方库数据表
     *
     * @param studentId 学生id
     * @param batchCode 批次编号
     * @return TableDataInfo 列表信息
     */
    @PreAuthorize("@ss.hasPermi('system:testBodyScoreInfo:selectThisActionDevelopmentVO')")
    @GetMapping("/selectThisActionDevelopmentVO")
    public AjaxResult selectThisActionDevelopmentVO(@Param("studentId") Long studentId, @Param("batchCode") String batchCode) {
        if (Objects.isNull(studentId)) {
            return AjaxResult.error("学生信息不能为空！");
        }
        if (Objects.isNull(batchCode)) {
            return AjaxResult.error("批次信息不能为空！");
        }
        return testActionDevelopmentService.selectThisActionDevelopmentVO(studentId, batchCode);
    }
}
