package com.qmth.themis.business.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.themis.business.cache.ExamBreakCacheUtil;
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
import com.qmth.themis.business.dao.TOeExamBreakHistoryMapper;
import com.qmth.themis.business.entity.TOeExamBreakHistory;
import com.qmth.themis.business.enums.VerifyExceptionEnum;
import com.qmth.themis.business.service.TOeExamBreakHistoryService;
import com.qmth.themis.common.exception.BusinessException;

/**
 * @Description: 考试断点记录 服务实现类
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/25
 */
@Service
public class TOeExamBreakHistoryServiceImpl extends ServiceImpl<TOeExamBreakHistoryMapper, TOeExamBreakHistory> implements TOeExamBreakHistoryService {
	
	/**保存验证信息
	 * @param recordId
	 * @param entryAuthenticationId
	 * @param entryAuthenticationResult
	 */
	@Override
	public void saveAuthenticationResult(Long recordId,Long entryAuthenticationId,VerifyExceptionEnum entryAuthenticationResult) {
		Long examBreakId=ExamRecordCacheUtil.getLastBreakId(recordId);
		if(examBreakId==null) {
			throw new BusinessException("未找到断点ID");
		}
		if(ExamBreakCacheUtil.getExamRecordId(examBreakId)==null) {
			throw new BusinessException("未找到断点信息");
		}
		ExamBreakCacheUtil.setEntryAuthenticationId(examBreakId, entryAuthenticationId); 
		ExamBreakCacheUtil.setEntryAuthenticationResult(examBreakId, entryAuthenticationResult);
	}
}
