DictionaryEntriesService.java 1.48 KB
package com.erry.iclear.dateInterface.service;

import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.DictionaryEntries;
import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author Administrator
 */
@Service
@Slf4j
public class DictionaryEntriesService {

    @Autowired
    private DictionaryEntriesRepository dictionaryEntriesRepository;

    public List<DictionaryEntries> getAllDictionaryEntries(){
        List<DictionaryEntries> result = new ArrayList<DictionaryEntries>();
        try {
            result=dictionaryEntriesRepository.findAllDictionaryEntries();
        }catch (Exception e){
            log.error("getAllDictionaryEntries() error:"+e.getMessage());
        }
        return result;
    }


    /**
     * 初始化AppInfo
     */
    public void initDictionaryEntries() {
        try {
            List<DictionaryEntries> dictionaryEntriesList = this.getAllDictionaryEntries();
            for (DictionaryEntries dictionaryEntries : dictionaryEntriesList) {
                Constant.dictionaryEntriesCache.put(dictionaryEntries.getCode(),dictionaryEntries);
            }
        } catch (Exception e) {
            log.error("initAppInfo() error" + e.getMessage());
        }
    }



}