@POST @Consumes("application/json") @Produces("application/json") public Response saveUser(User user) { UserResponse response = new UserResponse(); response.message = dao.saveUser(user); return Response.status(201).entity(response).build(); }
@GET @Path("/{id}") @Produces("application/json") public Response getUser(@PathParam("id") String id) { User user = dao.findUserById(id); if (user == null) { return Response.status(404).build(); } return Response.ok(user).build(); }
@DELETE @Path("/{id}") public Response deleteUser(@PathParam("id") String id) { dao.deleteUserById(id); return Response.noContent().build(); }
@PUT @Consumes("application/json") public Response updateUser(User user) { dao.updateUser(user); return Response.noContent().build(); }
@GET @Produces("application/json") public Set<String> allUserIds() { return dao.getAllUserIds(); }