Esempio n. 1
0
 @Transactional
 @CachePut(value = "sysDic")
 public void updateDic(SysDic record) {
   record.setUpdateTime(new Date());
   if (StringUtils.isBlank(record.getId())) {
     record.setId(createId("SysDic"));
     record.setCreateTime(new Date());
     dicMapper.insert(record);
   } else {
     dicMapper.updateById(record);
   }
 }
Esempio n. 2
0
  @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;
  }