Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.67 KB | None | 0 0
  1. In the RoleService
  2. override def removeRoleFromUserById (uid: UserId, rid: RoleId): M[ValidatedNel[Error, Int]]= {
  3.     roleRepo.removeRoleFromUserById(uid,rid).map{
  4.       case 0 => invalidNel(NotFound(s"Nothing has been deleted"))
  5.       case x => valid(x)
  6.     }
  7.   }
  8.  
  9. In the RoleController
  10. def removeRoleFromUser(userId: Long, roleId: Long) = authorized(ROLE_DELETE).async { implicit req =>
  11.     roleService.removeRoleFromUserById(UserId(userId), RoleId(roleId)) map {
  12.       case Invalid(nel) => BadRequest(nel.toList.mkString(","))
  13.       case Valid(r) => Ok(s"$r rows has been deleted")
  14.     } recover {
  15.       case NonFatal(ex) => InternalServerError(ex.toString)
  16.     }
  17.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement