WIP page
This commit is contained in:
parent
53eb700afb
commit
9bd03daf0e
@ -19,6 +19,7 @@ import javax.ws.rs.PUT;
|
|||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@ -27,6 +28,8 @@ import com.covas.Classes.Hash;
|
|||||||
import com.covas.Entity.UsersEntity;
|
import com.covas.Entity.UsersEntity;
|
||||||
import com.covas.Json.UserSingle;
|
import com.covas.Json.UserSingle;
|
||||||
|
|
||||||
|
import io.quarkus.panache.common.Page;
|
||||||
|
|
||||||
import org.eclipse.microprofile.jwt.Claims;
|
import org.eclipse.microprofile.jwt.Claims;
|
||||||
import org.eclipse.microprofile.jwt.JsonWebToken;
|
import org.eclipse.microprofile.jwt.JsonWebToken;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
@ -66,13 +69,19 @@ public class UsersRessources {
|
|||||||
/// GET
|
/// GET
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("Admin")
|
@RolesAllowed("Admin")
|
||||||
public Response getUsers(@CookieParam("user") String userCookie, @Context SecurityContext ctx) {
|
public Response getUsers(@CookieParam("user") String userCookie, @Context SecurityContext ctx, @QueryParam("page") Integer page, @QueryParam("nbPages") Integer nbPages) {
|
||||||
|
if(nbPages == null){
|
||||||
|
nbPages = 20;
|
||||||
|
}
|
||||||
|
if(page == null){
|
||||||
|
page = 1;
|
||||||
|
}
|
||||||
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
|
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
|
||||||
UsersEntity user = UsersEntity.findById(kid);
|
UsersEntity user = UsersEntity.findById(kid);
|
||||||
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
||||||
Response responseHttp = Response.status(status).build();
|
Response responseHttp = Response.status(status).build();
|
||||||
if (status.equals(Response.Status.OK)) {
|
if (status.equals(Response.Status.OK)) {
|
||||||
responseHttp = Response.ok(UsersEntity.listAll()).build();
|
responseHttp = Response.ok(UsersEntity.findAll().page(Page.of(page, nbPages)).list()).build();
|
||||||
}
|
}
|
||||||
return responseHttp;
|
return responseHttp;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user