diff --git a/src/main/java/com/covas/Entity/UsersEntity.java b/src/main/java/com/covas/Entity/UsersEntity.java index 8ea7694..08843f7 100644 --- a/src/main/java/com/covas/Entity/UsersEntity.java +++ b/src/main/java/com/covas/Entity/UsersEntity.java @@ -26,6 +26,9 @@ import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @NamedQuery(name = "Users.byUUIDandRoles", query = "from UsersEntity u where u.id = :id and u.roles = :roles"), @NamedQuery(name = "Users.byUUIDandStatus", query = "from UsersEntity u where u.id = :id and u.status = :status"), @NamedQuery(name = "Users.byUUIDandRolesandStatus", query = "from UsersEntity u where u.id = :id and u.roles = :roles and u.status = :status"), + @NamedQuery(name = "Users.byRoles", query = "from UsersEntity u where u.roles = :roles"), + @NamedQuery(name = "Users.byStatus", query = "from UsersEntity u where u.status = :status"), + @NamedQuery(name = "Users.byRolesandStatus", query = "from UsersEntity u where u.roles = :roles and u.status = :status"), @NamedQuery(name = "Users.byEmailandRoles", query = "from UsersEntity u where u.email = :email and u.roles = :roles"), @NamedQuery(name = "Users.byEmailandStatus", query = "from UsersEntity u where u.email = :email and u.status = :status"), @NamedQuery(name = "Users.byEmailandRolesandStatus", query = "from UsersEntity u where u.email = :email and u.roles = :roles and u.status = :status"), diff --git a/src/main/java/com/covas/Resources/UsersRessources.java b/src/main/java/com/covas/Resources/UsersRessources.java index f48d260..e2e4199 100644 --- a/src/main/java/com/covas/Resources/UsersRessources.java +++ b/src/main/java/com/covas/Resources/UsersRessources.java @@ -89,7 +89,18 @@ public class UsersRessources { Response.Status statusHttp = getResponseCheck(ctx, userCookie, user); Response responseHttp = Response.status(statusHttp).build(); if (statusHttp.equals(Response.Status.OK)) { - responseHttp = Response.ok(UsersEntity.findAll().page(Page.of(page, nbPages)).list()).build(); + List listUsers = UsersEntity.findAll().page(Page.of(page, nbPages)).list(); + + if((roles != null) && (status == null)){ + listUsers = UsersEntity.find("#Users.byRoles", Parameters.with("roles",roles)).page(Page.of(page, nbPages)).list(); + } + if((roles == null) && (status != null)){ + listUsers = UsersEntity.find("#Users.byStatus", Parameters.with("status",status)).page(Page.of(page, nbPages)).list(); + } + if((roles != null) && (status != null)){ + listUsers = UsersEntity.find("#Users.byRolesandStatus", Parameters.with("roles",roles).and("status", status)).page(Page.of(page, nbPages)).list(); + } + responseHttp = Response.ok(listUsers).build(); if(uuid != null){ UsersEntity userSingle = UsersEntity.findById(UUID.fromString(uuid)); if((roles != null) && (status == null)){