Exemple #1
0
 /**
  * 请求报表权限页面
  *
  * @param roleId
  * @param model
  * @return
  */
 @RequestMapping(value = "/authReport{userId}")
 public String authReport(@PathVariable int userId, Model model) {
   List<ReportDesign> reportList = reportService.listAllReport();
   User user = userService.getUserById(userId);
   // 获得用户的角色权限
   if (user != null) {
     int roleId = user.getRoleId();
     Role role = roleService.getRoleById(roleId);
     String roleRights = role.getReportRights();
     String reportRights = user.getReportRights();
     if (reportList != null && reportList.size() > 0 && Tools.notEmpty(reportRights)) {
       reportChecked(reportList, reportRights);
       // 角色权限
       // roleReportChecked(reportList, roleRights);
     }
   }
   // if (Tools.notEmpty(reportRights)) {
   // reportChecked(reportList, reportRights);
   // }
   JSONArray arr = JSONArray.fromObject(reportList);
   String json = arr.toString();
   json =
       json.replaceAll("reportId", "id")
           .replaceAll("reportName", "name")
           .replaceAll("subReport", "nodes")
           .replaceAll("hasReport", "checked");
   model.addAttribute("zTreeNodes", json);
   model.addAttribute("userId", userId);
   return "user/authorizationReport";
 }
Exemple #2
0
 /**
  * 请求用户授权页面
  *
  * @param userId
  * @param model
  * @return
  */
 @RequestMapping(value = "/auth{userId}")
 public String auth(@PathVariable int userId, Model model) {
   List<Menu> menuList = menuService.listAllMenu();
   User user = userService.getUserById(userId);
   String userRights = "";
   if (user != null) {
     userRights = user.getRights();
   }
   if (Tools.notEmpty(userRights) && menuList != null && menuList.size() > 0) {
     for (Menu menu : menuList) {
       menu.setHasMenu(RightsHelper.testRights(userRights, menu.getMenuId()));
       if (menu.isHasMenu()) {
         List<Menu> subRightsList = menu.getSubMenu();
         for (Menu sub : subRightsList) {
           sub.setHasMenu(RightsHelper.testRights(userRights, sub.getMenuId()));
         }
       }
     }
   }
   JSONArray arr = JSONArray.fromObject(menuList);
   String json = arr.toString();
   json =
       json.replaceAll("menuId", "id")
           .replaceAll("menuName", "name")
           .replaceAll("subMenu", "nodes")
           .replaceAll("hasMenu", "checked");
   model.addAttribute("zTreeNodes", json);
   model.addAttribute("userId", userId);
   return "user/authorization";
 }
Exemple #3
0
 /**
  * 递归选中报表权限
  *
  * @param reportList
  * @param reportRights
  * @return
  */
 private List<ReportDesign> reportChecked(List<ReportDesign> reportList, String reportRights) {
   if (reportList != null && reportList.size() > 0 && Tools.notEmpty(reportRights)) {
     for (ReportDesign report : reportList) {
       report.setHasReport(RightsHelper.testRights(reportRights, report.getReportId()));
       if (null != report.getSubReport()) {
         reportChecked(report.getSubReport(), reportRights);
       }
     }
   }
   return reportList;
 }