package com.ann.demo.service.impl;

import com.ann.demo.entity.filing.ArchiveDetail;
import com.ann.demo.entity.interfaceEntity.ArchiveMaster;
import com.ann.demo.repository.ArchiveDetailRepository;
import com.ann.demo.service.ArchiveDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: LeiJiaXin
 * @Date: 2019/7/12 9:12
 */
@Service
public class ArchiveDetailServiceImpl implements ArchiveDetailService {

    @Autowired
    ArchiveDetailRepository archiveDetailRepository;

    @Override
    public void save(ArchiveDetail archiveDetail) {
        archiveDetailRepository.save(archiveDetail);
    }

    @Override
    public void delete(String id) {
        archiveDetailRepository.deleteById(id);
    }

    @Override
    public ArchiveDetail isExit(String id, String type, String source, String applyId) throws Exception {
        if (archiveDetailRepository.countByMasterIDAndAssortIDAndSourceAndApplyId(id, type, source, applyId) > 0)
            return archiveDetailRepository.findByMasterIDAndAssortIDAndSourceAndApplyId(id, type, source, applyId);
        return null;
    }

//    @Override
//    public ArchiveMaster findByInpNoAndVisitIdAndIsValid(String inpNo, String visitId, Integer valid) {
//        return archiveDetailRepository.findByInpNoAndVisitIdAndIsValid(inpNo,visitId,valid);
//    }
}
