package jnpf.cultivate.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.cultivate.mapper.FtbCultivateLearnTaskExamMapper;
import jnpf.cultivate.service.FtbCultivateLearnTaskExamService;
import jnpf.model.cultivate.po.learn.FtbCultivateLearnTaskExam;
import jnpf.model.cultivate.resp.TaskRelationExamVo;
import jnpf.model.cultivate.v2.task.vo.FtbCultivateLearnTaskExamVo;
import org.springframework.stereotype.Service;

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

/**
 * @Author: peng.hao
 * @create: 2024/9/9:11:05
 */
@Service
public class FtbCultivateLearnTaskExamServiceImpl extends ServiceImpl<FtbCultivateLearnTaskExamMapper, FtbCultivateLearnTaskExam> implements FtbCultivateLearnTaskExamService {

    @Resource
    private FtbCultivateLearnTaskExamMapper ftbCultivateLearnTaskExamMapper;

    /**
     * 批量查询任务考试信息
     *
     * @param taskIds 任务ID集合
     * @return
     */
    @Override
    public List<TaskRelationExamVo> queryExamBaseInfo(List<String> taskIds) {
        return ftbCultivateLearnTaskExamMapper.queryExamBaseInfo(taskIds);
    }

    @Override
    public List<FtbCultivateLearnTaskExamVo> listByTaskId(String taskId) {
        return ftbCultivateLearnTaskExamMapper.listByTaskIdWithExam(taskId);
    }

    @Override
    public List<FtbCultivateLearnTaskExamVo> listByTaskIdAndPhaseId(String taskId, String phaseId) {
        return ftbCultivateLearnTaskExamMapper.listByTaskIdAndPhaseId(taskId, phaseId);
    }

    /**
     * 检查考试是否被学习任务绑定（关联任务主表）
     *
     * @param examId 考试ID
     * @return true-已绑定 false-未绑定
     */
    @Override
    public Boolean checkExamBinding(String examId) {
        Integer count = ftbCultivateLearnTaskExamMapper.checkExamBinding(examId);
        return count != null && count > 0;
    }
}