コード例 #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);
   }
 }
コード例 #2
0
 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);
 }
コード例 #3
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;
  }
コード例 #4
0
 @Cacheable(value = "sysDic")
 public SysDic queryDicById(String id) {
   return dicMapper.selectById(id);
 }
コード例 #5
0
 @Transactional
 @CacheEvict(value = "sysDic")
 public void deleteDic(String id) {
   dicMapper.deleteById(id);
 }