コード例 #1
0
ファイル: AdminController.java プロジェクト: suevip/xes
 /** 系统设置统一跳转,设置产品code */
 @RequestMapping(value = "/sysCofig/{permissionId}")
 public String sysCofig(
     ModelMap model,
     @PathVariable Long permissionId,
     HttpServletRequest request,
     HttpServletResponse response) {
   String url = paramUtils.getParameter(request, "url", "");
   Permission permission = permissionManager.getById(permissionId);
   setSessionProductId(request, permission.getProductCode());
   if (!"".equals(url)) {
     return "redirect:" + url + "?AUTH_PERM_ID=" + permissionId;
   } else {
     return INDEX_ACTION;
   }
 }
コード例 #2
0
ファイル: AdminController.java プロジェクト: suevip/xes
 /**
  * 获得指定产品下权限json串
  *
  * @param userDetails
  * @param productCode
  * @param roleId
  * @return String
  */
 private String getPermissionJsonDatas(UserDetails userDetails, String productCode, Long roleId) {
   StringBuffer jsonObject = new StringBuffer("[");
   List<PermissionGroup> permissionGroupList =
       userManager.getPermissionGroups(roleId, productCode, userDetails);
   for (PermissionGroup group : permissionGroupList) {
     List<Permission> permList = userManager.getPermissions(roleId, group.getCode(), userDetails);
     // if(null!=permList && !permList.isEmpty()){
     jsonObject.append("{");
     jsonObject.append("\"name\":\"" + group.getName() + "\",");
     jsonObject.append("\"code\":\"" + group.getCode() + "\",");
     jsonObject.append("\"imgPath\":\"" + group.getImgPath() + "\",");
     jsonObject.append("\"id\":\"" + group.getId() + "\",");
     jsonObject.append("\"sortId\":\"" + group.getSortId() + "\",");
     if (null != permList && !permList.isEmpty()) {
       jsonObject.append("\"permList\":[");
       for (int j = 0; j < permList.size(); j++) {
         Permission perm = permList.get(j);
         jsonObject.append("{");
         jsonObject.append("\"name\":\"" + perm.getName() + "\",");
         jsonObject.append("\"code\":\"" + perm.getCode() + "\",");
         jsonObject.append("\"imgPath\":\"" + perm.getImgPath() + "\",");
         jsonObject.append("\"id\":\"" + perm.getId() + "\",");
         jsonObject.append("\"sortId\":\"" + perm.getSortId() + "\",");
         jsonObject.append("\"url\":\"" + perm.getUrl() + "\"");
         if (j < permList.size() - 1) {
           jsonObject.append("},");
         } else {
           jsonObject.append("}");
         }
       }
       jsonObject.append("]");
     }
     jsonObject.append("},");
     // }
   }
   String permJson = jsonObject.toString();
   if (permJson.endsWith(",")) {
     permJson = permJson.substring(0, permJson.length() - 1);
   }
   permJson += "]";
   return permJson;
 }
コード例 #3
0
ファイル: AdminController.java プロジェクト: suevip/xes
  @RequestMapping(value = "/permGroup/{permGroupId}")
  @PermissionAnnotation(name = "权限组列表", type = PermissionAnnotation.TYPE_TAG)
  public String permGroup(
      ModelMap model,
      @PathVariable java.lang.Long permGroupId,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException {
    Long roleId = getSessionRoleId(request);
    UserDetails userDetails = this.getAdminLoginUser(request);
    if (objectUtils.isEmpty(userDetails)) {
      return "redirect:/admin/login";
    }
    String result = "/admin/index";
    PermissionGroup permissionGroup = this.permissionGroupManager.getById(permGroupId);
    String permGroupCode = null == permissionGroup ? "" : permissionGroup.getCode();
    if (objectUtils.isNotEmpty(permGroupCode)) {
      List<Permission> permissionList =
          userManager.getPermissions(roleId, permGroupCode, userDetails);
      model.addAttribute("AUTH_PERMISSIONLIST", permissionList);
      model.addAttribute("permGroupId", permGroupId);

      model.addAttribute("currentProduct", getCurrentProduct(request));

      Permission permission = userManager.getFirstPermission(roleId, permGroupCode, userDetails);
      if (null != permission
          && null != permission.getUrl()
          && !permission.getUrl().trim().equals("")) {
        if (permission.getUrl().startsWith("http://")) {
          result = "redirect:" + permission.getUrl();
        } else if (permission.getUrl().startsWith("/") && permission.getUrl().indexOf("?") != -1) {
          result = "redirect:" + permission.getUrl() + "&AUTH_PERM_ID=" + permission.getId();
        } else if (permission.getUrl().startsWith("/") && permission.getUrl().indexOf("?") == -1) {
          result = "redirect:" + permission.getUrl() + "?AUTH_PERM_ID=" + permission.getId();
        } else {
          String url = request.getHeader("Referer");
          result = "redirect:" + url;
        }
      } else {
        String url = request.getHeader("Referer");
        result = "redirect:" + url;
      }
    }
    return result;
  }