package com.qmth.teachcloud.mark.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.teachcloud.mark.entity.ScanAnswerCardSubject;
import com.qmth.teachcloud.mark.mapper.ScanAnswerCardSubjectMapper;
import com.qmth.teachcloud.mark.service.ScanAnswerCardSubjectService;

/**
 * <p>
 * 卡格式科目关联关系 服务实现类
 * </p>
 *
 * @author xf
 * @since 2023-09-22
 */
@Service
public class ScanAnswerCardSubjectServiceImpl extends ServiceImpl<ScanAnswerCardSubjectMapper, ScanAnswerCardSubject>
		implements ScanAnswerCardSubjectService {

	@Override
	public boolean checkSubject(Long examId, Integer number, String coursePaperId) {
		ScanAnswerCardSubject a = this.findByExamAndNumberAndSubject(examId, number, coursePaperId);
		return a != null;
	}

	@Override
	public ScanAnswerCardSubject findByExamAndNumberAndSubject(Long examId, Integer number, String coursePaperId) {
		QueryWrapper<ScanAnswerCardSubject> wrapper = new QueryWrapper<>();
		LambdaQueryWrapper<ScanAnswerCardSubject> lw = wrapper.lambda();
		lw.eq(ScanAnswerCardSubject::getExamId, examId);
		lw.eq(ScanAnswerCardSubject::getCardNumber, number);
		lw.eq(ScanAnswerCardSubject::getCoursePaperId, coursePaperId);
		return baseMapper.selectOne(wrapper);
	}

}
