快码表类库DataDictionary

来源:互联网 发布:seo效果检测步骤包括 编辑:程序博客网 时间:2024/06/05 15:40

 代码没什么难度,主要是学习这种基础数据使用思想。

 

import java.util.HashMap;import java.util.List;import java.util.Map;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.web.context.ContextLoader;import org.springframework.web.context.WebApplicationContext;public class DataDictionary {private static final Logger logger = LoggerFactory.getLogger(DataDictionary.class);private static Map<String, Map<String, String>> dictionary = new HashMap<String, Map<String, String>>();static{loadDictionary();}private static void loadDictionary(){logger.debug("loadDictionary begin...");// 获取spring bean容器WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();ISysLookupTypeDao typedao = (ISysLookupTypeDao) wac.getBean("iSysLookupTypeDao");ISysLookupValueDao valuedao = (ISysLookupValueDao) wac.getBean("iSysLookupValueDao");List<SysLookupType> types = typedao.getAll();for(SysLookupType type : types){logger.debug(type.getLookupName() + "[" + type.getLookupCode() + "]:");Map<String, String> valuemap = new HashMap<String, String>();List<SysLookupValue> values = valuedao.getSysLookupValueByCode(type.getLookupCode());for(SysLookupValue value : values){logger.debug(value.getLookupValue() + " - " + value.getMeaning());valuemap.put(value.getLookupValue(), value.getMeaning());}dictionary.put(type.getLookupCode(), valuemap);}logger.debug("loadDictionary end...");}/** * 通过lookupcode 与 lookupvalue 检索 meaning *  * @param code * @param value * @return */public static String search(String code, String value){return dictionary.get(code).get(value);}public static void addOrUpdateToDictionary(String code, String value, String meaning){dictionary.get(code).put(value, meaning);}public static void removeFromDictionary(String code, String value){dictionary.get(code).remove(value);}}

 

SYS_LOOKUP_TYPE:

 

 

SYS_LOOKUP_VALUE:

 

 

 

 

原创粉丝点击