package com.qmth.teachcloud.report.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
import com.qmth.teachcloud.report.business.entity.TBCloudExam;
import com.qmth.teachcloud.report.business.entity.TBExam;
import com.qmth.teachcloud.report.business.mapper.TBExamMapper;
import com.qmth.teachcloud.report.business.service.TBCloudExamService;
import com.qmth.teachcloud.report.business.service.TBExamService;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 教研分析基础考试信息表 服务实现类
 * </p>
 *
 * @author wangliang
 * @since 2021-06-01
 */
@Service
public class TBExamServiceImpl extends ServiceImpl<TBExamMapper, TBExam> implements TBExamService {
    @Resource
    private TBCloudExamService tbCloudExamService;

    @Override
    public TBExam findByCloudExamId(Long cloudExamId) {
        TBCloudExam tbCloudExam = tbCloudExamService.getById(cloudExamId);
        Long examId = tbCloudExam.getExamId();
        TBExam tbExam = this.getById(examId);
        if (Objects.isNull(tbExam)){
            throw ExceptionResultEnum.ERROR.exception("未找到教研分析基础考试信息");
        }
        return tbExam;
    }
}
