Пример #1
0
  /**
   * 查询所有单位树节点
   *
   * @param session
   * @return
   */
  @RequestMapping(value = "/findAllCompany")
  @ResponseBody
  public List<CompanyTreeNode> findAllCompany(HttpSession session) {
    List<CompanyTreeNode> tree = new ArrayList<CompanyTreeNode>();

    Map<String, String> companys = new HashMap<String, String>();
    if (isSuperAdmin(session)) {
      companys = companyService.findAllInSelect();
    } else {
      User user = getCurrentUser(session);
      if (user != null) {
        companys.put(
            String.valueOf(user.getCompany().getCompanyId()), user.getCompany().getCompanyName());
      }
    }

    for (String s : companys.keySet()) {
      CompanyTreeNode companyTreeNode = new CompanyTreeNode();
      companyTreeNode.setCompanyId(s);
      companyTreeNode.setName(companys.get(s));
      companyTreeNode.setIcon(
          ResourcePathExposer.getResourceRoot()
              + "/dwz/themes/default/images/dialog/award_star_gold_2.png");
      tree.add(companyTreeNode);
    }

    return tree;
  }
Пример #2
0
  /**
   * 查询区域树节点
   *
   * @param regionId 区域ID
   * @return
   */
  @RequestMapping(value = "/findRegionTreeNode")
  @ResponseBody
  public List<TRegion> findRegionTreeNode(String regionId, HttpSession session) {

    List<TRegion> data = new ArrayList<TRegion>();

    User user = (User) session.getAttribute(UserService.USER_CODE);
    if (user == null) {
      return data;
    }

    if (user.isSuperAdmin()) { // 超级管理员,可查看所有正常状态的区域信息
      if (StringUtils.isBlank(regionId)) { // 第一次加载
        data.addAll(regionService.findAllTopInNormal());
      } else {
        data.addAll(regionService.findChildrenByRegionIdInNormal(NumberUtils.toInt(regionId)));
      }
    } else {
      if (StringUtils.isBlank(regionId)) { // 第一次加载,获取当前登录用户归属公司的所在区域
        data.addAll(regionService.findByCompanyIdForTree(user.getCompanyId()));
      } else {
        data.addAll(regionService.findChildrenByRegionIdForTree(NumberUtils.toInt(regionId)));
      }
    }

    return data;
  }