Exemplo n.º 1
0
  public SysApplication findById(long id) {
    String cacheKey = "sys_app_" + id;

    if (SystemConfig.getBoolean("use_query_cache") && CacheFactory.getString(cacheKey) != null) {
      String text = CacheFactory.getString(cacheKey);
      com.alibaba.fastjson.JSONObject json = JSON.parseObject(text);
      SysApplication app = SysApplicationJsonFactory.jsonToObject(json);
      if (app != null && app.getNodeId() > 0) {
        SysTree node = sysTreeService.findById(app.getNodeId());
        app.setNode(node);
      }
      return app;
    }

    SysApplication app = sysApplicationMapper.getSysApplicationById(id);
    if (app != null && app.getNodeId() > 0) {
      SysTree node = sysTreeService.findById(app.getNodeId());
      app.setNode(node);
    }

    if (app != null && SystemConfig.getBoolean("use_query_cache")) {
      com.alibaba.fastjson.JSONObject json = app.toJsonObject();
      CacheFactory.put(cacheKey, json.toJSONString());
    }

    return app;
  }
Exemplo n.º 2
0
 @Transactional
 public boolean update(SysApplication bean) {
   String cacheKey = "sys_app_" + bean.getId();
   bean.setUpdateDate(new Date());
   if (StringUtils.isEmpty(bean.getCode())) {
     bean.setCode("app_" + bean.getId());
   }
   this.sysApplicationMapper.updateSysApplication(bean);
   CacheFactory.remove(cacheKey);
   if (bean.getNode() != null) {
     bean.getNode().setCode(bean.getCode());
     bean.getNode().setLocked(bean.getLocked());
     bean.getNode().setUpdateBy(bean.getUpdateBy());
     sysTreeService.update(bean.getNode());
     cacheKey = "sys_tree_" + bean.getNode().getId();
     CacheFactory.remove(cacheKey);
   }
   return true;
 }