コード例 #1
0
  public List<SysApplication> getAccessAppList(long parentId, SysUser user) {
    long parentAppId = parentId;
    SysApplication parentApp = findById(parentId);
    if (parentApp != null) {
      parentAppId = parentApp.getNode().getId();
    }

    logger.debug("parent node:" + parentAppId);

    SysApplicationQuery query = new SysApplicationQuery();
    query.parentId(parentAppId);
    query.setLocked(0);
    List<Long> nodeIds = new java.util.ArrayList<Long>();
    nodeIds.add(-1L);

    List<SysApplication> apps = sysApplicationMapper.getSysApplicationByUserId(user.getId());
    if (apps != null && !apps.isEmpty()) {
      for (SysApplication app : apps) {
        nodeIds.add(app.getNodeId());
      }
    }
    query.nodeIds(nodeIds);

    return this.list(query);
  }
コード例 #2
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;
  }
コード例 #3
0
 @Transactional
 public void deleteById(Long appId) {
   if (appId != null && appId > 0) {
     sysAccessMapper.deleteSysAccessByAppId(appId);
     sysApplicationMapper.deleteSysApplicationById(appId);
     SysApplication app = this.getSysApplication(appId);
     if (app != null) {
       sysTreeMapper.deleteSysTreeById(app.getNodeId());
     }
   }
 }
コード例 #4
0
 @Transactional
 public boolean create(SysApplication bean) {
   boolean ret = false;
   if (bean.getId() == 0) {
     bean.setId(idGenerator.nextId());
   }
   if (StringUtils.isEmpty(bean.getCode())) {
     bean.setCode("app_" + bean.getId());
   }
   if (bean.getNode() != null) {
     bean.getNode().setCode(bean.getCode());
     bean.getNode().setDiscriminator("A");
     bean.getNode().setCreateBy(bean.getCreateBy());
     sysTreeService.create(bean.getNode());
     bean.setNodeId(bean.getNode().getId());
   }
   bean.setSort((int) bean.getId()); // 设置排序号为刚插入的id值
   bean.setCreateDate(new Date());
   sysApplicationMapper.insertSysApplication(bean);
   ret = true;
   return ret;
 }
コード例 #5
0
 public int count(SysApplicationQuery query) {
   return sysApplicationMapper.getSysApplicationCount(query);
 }
コード例 #6
0
 public List<SysApplication> list(SysApplicationQuery query) {
   List<SysApplication> list = sysApplicationMapper.getSysApplications(query);
   return list;
 }
コード例 #7
0
 public int getSysApplicationCountByQueryCriteria(SysApplicationQuery query) {
   return sysApplicationMapper.getSysApplicationCount(query);
 }
コード例 #8
0
 public List<RealmInfo> getRealmInfos() {
   Map<String, Object> params = new java.util.HashMap<String, Object>();
   return sysApplicationMapper.getRealmInfos(params);
 }