package com.ruoyi.app.controller.train;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.dto.EmployeeCourseExamDto;
import com.ruoyi.service.TrainService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: RuoYi-Vue-master
 * @description: 培训控制层
 * @author: niujie
 * @create: 2023-08-03 20:29
 */
@Api(tags = "培训APP")
@RestController
@RequestMapping("/app/train")
@Anonymous
@CrossOrigin
public class TrainAppController {
    @Autowired
    private TrainService trainService;

    /**
     * APP培训列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/queryTrainPlanPage")
    public AjaxResult queryTrainPlanPage(@RequestParam("pageNo") Integer pageNo,
                                         @RequestParam("pageSize") Integer pageSize) {
        return AjaxResult.success(trainService.queryTrainPlanPage(pageNo, pageSize));
    }

    /**
     * 通过培训计划ID获取课程
     * @param trainingPlanId
     * @return
     */
    @GetMapping("/queryCourseByTrainingPlanId")
    public AjaxResult queryCourseByTrainingPlanId(@RequestParam("trainingPlanId") String trainingPlanId) {
        return AjaxResult.success(trainService.queryCourseByTrainingPlanId(trainingPlanId));
    }

    /**
     * 通过培训计划ID获取试卷
     * @param trainingPlanId
     * @return
     */
    @GetMapping("/queryQuestionBankByTrainingPlanId")
    public AjaxResult queryQuestionBankByTrainingPlanId(@RequestParam("trainingPlanId") String trainingPlanId) {
        return trainService.queryQuestionBankByTrainingPlanId(trainingPlanId);
    }

    /**
     * 通过培训计划ID获取试卷前期校验
     * @param trainingPlanId
     * @return
     */
    @GetMapping("/queryQuestionBankByTrainingPlanIdValidate")
    public AjaxResult queryQuestionBankByTrainingPlanIdValidate(@RequestParam("trainingPlanId") String trainingPlanId) {
        return trainService.queryQuestionBankByTrainingPlanIdValidate(trainingPlanId);
    }

    /**
     * 考试题目提交
     * @param employeeCourseExamDtoList
     * @return
     */
    @PostMapping("/submitQuestionBank")
    public AjaxResult submitQuestionBank(@RequestBody List<EmployeeCourseExamDto> employeeCourseExamDtoList) {
        return trainService.submitQuestionBank(employeeCourseExamDtoList);
    }


    /**
     * 考试记录
     * 获取个人考试题列表
     * @return
     */
    @GetMapping("/queryQuestionBankList")
    public AjaxResult queryQuestionBankList(@RequestParam("pageNo") Integer pageNo,
                                            @RequestParam("pageSize") Integer pageSize) {
        return trainService.queryQuestionBankList(pageNo, pageSize);
    }

    /**
     * 获取考试详情
     * @return
     */
    @GetMapping("/queryQuestionBankDetail")
    public AjaxResult queryQuestionBankDetail(@RequestParam("id") String id) {
        return trainService.queryQuestionBankDetail(id);
    }
}
