package cn.iocoder.yudao.module.exam.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.exam.service.ExamBatchItemService;
import cn.iocoder.yudao.module.exam.service.ExamBatchService;
import cn.iocoder.yudao.module.exam.vo.ExamBatchItemNewVO;
import cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO;
import cn.iocoder.yudao.module.exam.vo.ExamVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @Description: 小程序-考试批次
 * @Author: 86187
 * @Date: 2025/03/31 10:54
 * @Version: 1.0
 */
@Tag(name = "小程序 - 考试批次")
@RestController
@RequestMapping("/examBatch")
@Validated
public class AppExamBatchController {

    @Resource
    private ExamBatchService examBatchService;
    @Autowired
    private ExamBatchItemService examBatchItemService;

    /**
     * 根据学生id和教练ID查询考试记录
     *
     * @param userId  学生ID
     * @param coachId 教练ID，可能为空
     * @return java.util.List<cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO>
     * @author vinjor-M
     * @date 16:38 2025/2/10
     **/
    @GetMapping("/selectExamByUserIdAndCoachId")
    @TenantIgnore
    public CommonResult<List<ExamVO>> selectExamByUserIdAndCoachId(Long userId, Long coachId) {
        List<ExamVO> examList = examBatchItemService.selectExamByUserIdAndCoachId(userId, coachId);
        return CommonResult.success(examList);
    }

    /**
     * 录入学生考试成绩
     * @param examBatchVO
     * @return
     */
    @PutMapping("/update")
    @Operation(summary = "录入考试成绩")
    @TenantIgnore
    public CommonResult<?> updateObj( @RequestBody ExamBatchItemNewVO examBatchVO) {
        examBatchItemService.updateObjNew(examBatchVO);
        return success(true);
    }
}
