package com.ann.demo.service.impl;

import com.ann.demo.entity.interfaceEntity.ExamApply;
import com.ann.demo.repository.ExamApplyRepository;
import com.ann.demo.service.ExamApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: LeiJiaXin
 * @Date: 2019/8/22 16:20
 */
@Service
public class ExamApplyServiceImpl implements ExamApplyService {

    @Autowired
    ExamApplyRepository examApplyRepository;

    @Override
    public void save(ExamApply examApply) {
        examApplyRepository.save(examApply);
    }

    @Override
    public ExamApply findExamApply(String applyId) {
        return examApplyRepository.findByApplyIdAndIsValidAndIsOpenHisAndIsOpenOther(applyId,0,"E","E");
    }

    @Override
    public Integer countExamApply(String applyId) {
        return examApplyRepository.countExamApply(applyId);
    }

    @Override
    public boolean updateExamApplyIsValid(String applyId) {
        if (examApplyRepository.updateExamApplyIsValidById(applyId) > 0)
            return true;
        return false;
    }
}
