Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In the RoleService
- override def removeRoleFromUserById (uid: UserId, rid: RoleId): M[ValidatedNel[Error, Int]]= {
- roleRepo.removeRoleFromUserById(uid,rid).map{
- case 0 => invalidNel(NotFound(s"Nothing has been deleted"))
- case x => valid(x)
- }
- }
- In the RoleController
- def removeRoleFromUser(userId: Long, roleId: Long) = authorized(ROLE_DELETE).async { implicit req =>
- roleService.removeRoleFromUserById(UserId(userId), RoleId(roleId)) map {
- case Invalid(nel) => BadRequest(nel.toList.mkString(","))
- case Valid(r) => Ok(s"$r rows has been deleted")
- } recover {
- case NonFatal(ex) => InternalServerError(ex.toString)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement