コード例 #1
0
  public void update(int id, String roleName, String roleNote, String[] rolePermission) {

    Role role = new Role(roleName, roleNote);
    roleDaoImpl.update(role, id); // 更新角色信息

    rolePermissionDaoImpl.deleteRolePermissionWithRoleId(id); // 先删除RoleId对应的权限
    int permissionId = 1;
    for (String permission : rolePermission) {
      permissionId = Integer.parseInt(permission);
      rolePermissionDaoImpl.addRolePermission(id, permissionId); // 重新加入权限
    }
  }
コード例 #2
0
  public void addRole(String roleName, String roleNote, String[] rolePermissions) {

    Role role = new Role(roleName, roleNote);
    roleDaoImpl.addRole(role);

    int permissionID = -1;

    for (String permissionId : rolePermissions) {
      permissionID = Integer.parseInt(permissionId);
      rolePermissionDaoImpl.addRolePermission(role.getRoleId(), permissionID);
    }
  }
コード例 #3
0
  public List<Permission> getRolePermissions(int id) {

    List<Permission> permissionForRole = new ArrayList<Permission>(); // 角色拥有的权限
    List<RolePermission> rolePermissions = rolePermissionDaoImpl.getRolePermissions(id);
    Permission permission = null;
    for (RolePermission rolePermission : rolePermissions) {
      int permissionId = rolePermission.getPermissionId();
      permission = permissionDaoImpl.getPermission(permissionId);
      permissionForRole.add(permission);
    }

    return permissionForRole;
  }
コード例 #4
0
  public void delete(int roleId) {

    userRoleDaoImpl.deleteWithRoleId(roleId);
    rolePermissionDaoImpl.deleteRolePermissionWithRoleId(roleId);
    roleDaoImpl.delete(roleId);
  }