public Page<SysDicIndex> queryDicIndex(Map<String, Object> params) { Page<String> idPage = this.getPage(params); List<String> ids = dicIndexMapper.selectIdByMap(idPage, params); Page<SysDicIndex> page = new Page<SysDicIndex>(idPage.getCurrent(), idPage.getSize()); page.setTotal(idPage.getTotal()); if (ids != null) { ISysDicProvider provider = InstanceUtil.getBean(getClass()); List<SysDicIndex> records = InstanceUtil.newArrayList(); for (String id : ids) { records.add(provider.queryDicIndexById(id)); } page.setRecords(records); } return page; }
public void deleteDicIndex(String id) { Map<String, Object> params = InstanceUtil.newHashMap(); params.put("index_id", id); List<String> ids = dicMapper.selectIdByMap(params); if (ids.size() > 0) { throw new BusinessException(); } dicIndexMapper.deleteById(id); }
@Cacheable(value = "sysDics") public Map<String, Map<String, String>> getAllDic() { List<String> records = dicIndexMapper.selectIdByMap(Collections.<String, Object>emptyMap()); Map<String, String> dicIndexMap = InstanceUtil.newHashMap(); for (String id : records) { dicIndexMap.put(id, dicIndexMapper.selectById(id).getKeyValue()); } records = dicMapper.selectIdByMap(Collections.<String, Object>emptyMap()); Page<String> idPage = new Page<String>(1, records.size()); idPage.setRecords(records); Page<SysDic> sysDics = getPage(idPage, SysDic.class); Map<String, Map<String, String>> resultMap = InstanceUtil.newHashMap(); for (SysDic sysDic : sysDics.getRecords()) { String key = dicIndexMap.get(sysDic.getIndexId()); if (resultMap.get(key) == null) { Map<String, String> dicMap = InstanceUtil.newHashMap(); resultMap.put(key, dicMap); } resultMap.get(key).put(sysDic.getCode(), sysDic.getCodeText()); } return resultMap; }
@Cacheable(value = "sysDicMap") public Map<String, String> queryDicByDicIndexKey(String key) { return InstanceUtil.getBean(ISysDicProvider.class).getAllDic().get(key); }