示例#1
0
 @SuppressWarnings("unchecked")
 public Role addRole_save(Role role, List<String> functionsIds) {
   Set<SystemFunctions> functionsSet = new HashSet();
   for (Iterator iterator = functionsIds.iterator(); iterator.hasNext(); ) {
     String rightstr = (String) iterator.next();
     int functionId = Integer.valueOf(rightstr);
     SystemFunctions f = systemDAO.getSystemFunctionById(functionId);
     f.getRoles().add(role);
     functionsSet.add(f);
   }
   role.setSystemFunctions(functionsSet);
   systemDAO.saveRole(role);
   System.out.println("添加12");
   return role;
 }
示例#2
0
 @SuppressWarnings("unchecked")
 public Role editRole_save(Role role, List<String> functionsIds) {
   // 老用户角色不变
   Role role0 = systemDAO.getRoleById(role.getId());
   role.setUsers(role0.getUsers());
   // 加上新的权限列表
   Set<SystemFunctions> functionsSet = new HashSet();
   for (Iterator iterator = functionsIds.iterator(); iterator.hasNext(); ) {
     String rightstr = (String) iterator.next();
     int functionId = Integer.valueOf(rightstr);
     SystemFunctions f = systemDAO.getSystemFunctionById(functionId);
     f.getRoles().add(role);
     functionsSet.add(f);
   }
   role.setSystemFunctions(functionsSet);
   systemDAO.saveRole(role);
   return role;
 }