package com.ann.demo.service.impl;

import com.ann.demo.entity.normalEntity.EMRDictionary;
import com.ann.demo.repository.DepartmentRepository;
import com.ann.demo.repository.EMRDictionaryRepository;
import com.ann.demo.service.EMRDictionaryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: LeiJiaXin
 * @Date: 2019/9/21 16:08
 */
@Service
public class EMRDictionaryServiceImpl implements EMRDictionaryService {

    static final Logger logger = LoggerFactory.getLogger(EMRDictionaryServiceImpl.class);

    @Autowired
    EMRDictionaryRepository emrDictionaryRepository;

    @Override
    public void save(EMRDictionary emrDictionary) {
        //打日志信息
        try {
            emrDictionaryRepository.save(emrDictionary);
        } catch (Exception e) {
            logger.error("出错咯！错误信息:" + e);
        }
    }

    @Override
    public void delete(EMRDictionary emrDictionary) {
        //打日志信息
        try {
            emrDictionaryRepository.delete(emrDictionary);
        } catch (Exception e) {
            logger.error("出错咯！错误信息:" + e);
        }
    }

    @Override
    public EMRDictionary findEMRDictionary(String code) {
        // ------------------确认 isValid 0是正常 1是停用
        return emrDictionaryRepository.findEMRDictionaryByCodeAndIsValid(code, 0);
    }
}
