package de.altenerding.biber.pinkie.user.bounday;

import de.altenerding.biber.pinkie.user.entity.User;

import javax.inject.Inject;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
import java.util.Optional;


@Path("/users")
@Produces(MediaType.APPLICATION_JSON)
public class UserResource {
    @Inject
    UserService userService;

    @GET
    public Response getUsers() {
        List<User> users = userService.getUsers();
        return Response.ok(users).build();
    }

    @GET
    @Path("{id}")
    public Response getUser(@PathParam("id") long id) {
        Optional<User> user = userService.getUser(id);

        if (!user.isPresent()) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        return Response.ok(user.get()).build();
    }

    @POST
    @Path("/login")
    public Response login(@FormParam("name") String name, @FormParam("password") String password) {
        return Response.ok().build();
    }
}

@@ -149,65 +149,10 @@
 .rs.
-FormParam;%0Aimport javax.ws.rs.GET;%0Aimport javax.ws.rs.POS
+GE
 T;%0Ai
@@ -933,182 +933,7 @@
    %7D
-%0A%0A    @POST%0A    @Path(%22/login%22)%0A    public Response login(@FormParam(%22name%22) String name, @FormParam(%22password%22) String password) %7B%0A        return Response.ok().build();%0A    %7D
 %0A%7D%0A

Remove login call