Пример #1
0
  @RequestMapping(value = "{source}/move", method = RequestMethod.GET)
  @PageableDefaults(sort = {"parentIds=asc", "weight=asc"})
  public String showMoveForm(
      HttpServletRequest request,
      @RequestParam(value = "async", required = false, defaultValue = "false") boolean async,
      @PathVariable("source") M source,
      Searchable searchable,
      Model model) {

    if (this.permissionList != null) {
      this.permissionList.assertHasEditPermission();
    }

    List<M> models = null;

    // 排除自己及子子孙孙
    searchable.addSearchFilter("id", SearchOperator.ne, source.getId());
    searchable.addSearchFilter(
        "parentIds", SearchOperator.notLike, source.makeSelfAsNewParentIds() + "%");

    if (!async) {
      models = baseService.findAllWithSort(searchable);
    } else {
      models = baseService.findRootAndChild(searchable);
    }

    model.addAttribute("trees", convertToZtreeList(request.getContextPath(), models, async, true));

    model.addAttribute(Constants.OP_NAME, "移动节点");

    return viewName("moveForm");
  }
Пример #2
0
  @RequestMapping(value = "ajax/load")
  @PageableDefaults(sort = {"parentIds=asc", "weight=asc"})
  @ResponseBody
  public Object load(
      HttpServletRequest request,
      @RequestParam(value = "async", defaultValue = "true") boolean async,
      @RequestParam(value = "asyncLoadAll", defaultValue = "false") boolean asyncLoadAll,
      @RequestParam(value = "searchName", required = false) String searchName,
      @RequestParam(value = "id", required = false) ID parentId,
      @RequestParam(value = "excludeId", required = false) ID excludeId,
      @RequestParam(value = "onlyCheckLeaf", required = false, defaultValue = "false")
          boolean onlyCheckLeaf,
      Searchable searchable) {

    M excludeM = baseService.findOne(excludeId);

    List<M> models = null;

    if (!StringUtils.isEmpty(searchName)) { // 按name模糊查
      searchable.addSearchParam("name_like", searchName);
      models = baseService.findAllByName(searchable, excludeM);
      if (!async || asyncLoadAll) { // 非异步模式 查自己及子子孙孙 但排除
        searchable.removeSearchFilter("name_like");
        List<M> children = baseService.findChildren(models, searchable);
        models.removeAll(children);
        models.addAll(children);
      } else { // 异步模式 只查匹配的一级

      }
    } else { // 根据有没有parentId加载

      if (parentId != null) { // 只查某个节点下的 异步
        searchable.addSearchFilter("parentId", SearchOperator.eq, parentId);
      }

      if (async && !asyncLoadAll) { // 异步模式下 且非异步加载所有
        // 排除自己 及 子子孙孙
        baseService.addExcludeSearchFilter(searchable, excludeM);
      }

      if (parentId == null && !asyncLoadAll) {
        models = baseService.findRootAndChild(searchable);
      } else {
        models = baseService.findAllWithSort(searchable);
      }
    }

    return convertToZtreeList(
        request.getContextPath(),
        models,
        async && !asyncLoadAll && parentId != null,
        onlyCheckLeaf);
  }
Пример #3
0
  @RequestMapping
  @PageableDefaults(value = 20, sort = "id=desc")
  public String list(@CurrentUser User user, Pageable pageable, Model model) {

    Searchable searchable = Searchable.newSearchable();
    searchable.addSearchFilter("userId", SearchOperator.eq, user.getId());

    Page<NotificationData> page = notificationDataService.findAll(pageable);

    model.addAttribute("page", page);
    if (pageable.getPageNumber() == 0) {
      notificationDataService.markReadAll(user.getId());
    }

    return viewName("list");
  }
Пример #4
0
  @RequestMapping(value = "{parent}/children", method = RequestMethod.GET)
  @PageableDefaults(sort = {"parentIds=asc", "weight=asc"})
  public String list(
      HttpServletRequest request,
      @PathVariable("parent") M parent,
      Searchable searchable,
      Model model)
      throws UnsupportedEncodingException {

    if (permissionList != null) {
      permissionList.assertHasViewPermission();
    }

    if (parent != null) {
      searchable.addSearchFilter("parentId", SearchOperator.eq, parent.getId());
    }

    model.addAttribute("page", baseService.findAll(searchable));

    return viewName("listChildren");
  }