コード例 #1
0
 @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();
 }
コード例 #2
0
 @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();
 }
コード例 #3
0
 @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();
 }
コード例 #4
0
 @DELETE
 @Path("{id}")
 public Response delete(@PathParam("id") Long id) {
   service.deleteUserById(id);
   return Response.noContent().build();
 }
コード例 #5
0
 @GET
 @Path("{id}")
 @Produces(value = MediaType.APPLICATION_JSON)
 public Response get(@PathParam("id") Long id) {
   return Response.ok(service.findUserById(id)).build();
 }
コード例 #6
0
 @GET()
 @Produces(value = MediaType.APPLICATION_JSON)
 public Response findAll(@QueryParam("q") String keyworkd) {
   return Response.ok(service.findByKeyword(keyworkd)).build();
 }