@PUT @Path("{id}") @Consumes(value = MediaType.APPLICATION_JSON) public Response update(@PathParam("id") Long id, @Valid UserForm user) { UserDetail saved = service.updateUser(id, user); return Response.noContent().build(); }
@POST @Consumes(value = MediaType.APPLICATION_JSON) public Response save(@Valid UserForm user) { UserDetail saved = service.createUser(user); return Response.created(uriInfo.getBaseUriBuilder().path("users/{id}").build(saved.getId())) .build(); }
@GET @Path("exists") @Produces(value = MediaType.APPLICATION_JSON) public Response get(@QueryParam("username") String username) { boolean exists = service.usernameExists(username); Map<String, Boolean> result = new HashMap<>(); result.put("result", exists); return Response.ok(result).build(); }
@DELETE @Path("{id}") public Response delete(@PathParam("id") Long id) { service.deleteUserById(id); return Response.noContent().build(); }
@GET @Path("{id}") @Produces(value = MediaType.APPLICATION_JSON) public Response get(@PathParam("id") Long id) { return Response.ok(service.findUserById(id)).build(); }
@GET() @Produces(value = MediaType.APPLICATION_JSON) public Response findAll(@QueryParam("q") String keyworkd) { return Response.ok(service.findByKeyword(keyworkd)).build(); }