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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
import com.qmth.teachcloud.report.business.entity.TBPaper;
import com.qmth.teachcloud.report.business.mapper.TBPaperMapper;
import com.qmth.teachcloud.report.business.service.TBPaperService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 试卷基础信息表（赋分系数、试卷类型、满分、及格分等） 服务实现类
 * </p>
 *
 * @author wangliang
 * @since 2021-06-01
 */
@Service
public class TBPaperServiceImpl extends ServiceImpl<TBPaperMapper, TBPaper> implements TBPaperService {
    @Override
    public TBPaper findByForeignKey(Long examId, String courseCode, String courseName, String paperType) {
        List<TBPaper> tbPaperList = this.list(new QueryWrapper<TBPaper>().lambda()
                .eq(TBPaper::getExamId,examId)
                .eq(TBPaper::getCourseCode,courseCode)
                .eq(TBPaper::getCourseName,courseName)
                .eq(TBPaper::getPaperType,paperType));
        if (tbPaperList.size() != 1){
            throw ExceptionResultEnum.ERROR.exception("基础试卷信息异常");
        }
        return tbPaperList.get(0);
    }
}
