fix find by namedqueries
This commit is contained in:
parent
2866e15129
commit
9892959b36
@ -73,7 +73,11 @@ public class UsersRessources {
|
||||
/// GET
|
||||
@GET
|
||||
@RolesAllowed("Admin")
|
||||
public Response getUsers(@CookieParam("user") String userCookie, @Context SecurityContext ctx, @QueryParam("page") Integer page, @QueryParam("nbPages") Integer nbPages, @QueryParam("status") Integer status, @QueryParam("roles") String roles, @QueryParam("email") String email, @QueryParam("search") String search, @QueryParam("uuid") String uuid) {
|
||||
public Response getUsers(@CookieParam("user") String userCookie, @Context SecurityContext ctx,
|
||||
@QueryParam("page") Integer page, @QueryParam("nbPages") Integer nbPages,
|
||||
@QueryParam("status") Short status, @QueryParam("roles") String roles,
|
||||
@QueryParam("email") String email, @QueryParam("search") String search,
|
||||
@QueryParam("uuid") String uuid) {
|
||||
if(nbPages == null){
|
||||
nbPages = 20;
|
||||
}
|
||||
@ -89,13 +93,13 @@ public class UsersRessources {
|
||||
if(uuid != null){
|
||||
UsersEntity userSingle = UsersEntity.findById(UUID.fromString(uuid));
|
||||
if((roles != null) && (status == null)){
|
||||
userSingle = UsersEntity.find("Users.byUUIDandRoles", Parameters.with("id", UUID.fromString(uuid)).and("roles",roles)).firstResult();
|
||||
userSingle = UsersEntity.find("#Users.byUUIDandRoles", Parameters.with("id", UUID.fromString(uuid)).and("roles",roles)).firstResult();
|
||||
}
|
||||
if((roles == null) && (status != null)){
|
||||
userSingle = UsersEntity.find("Users.byUUIDandStatus", Parameters.with("id", UUID.fromString(uuid)).and("status",status)).firstResult();
|
||||
userSingle = UsersEntity.find("#Users.byUUIDandStatus", Parameters.with("id", UUID.fromString(uuid)).and("status",status)).firstResult();
|
||||
}
|
||||
if((roles != null) && (status != null)){
|
||||
userSingle = UsersEntity.find("Users.byUUIDandRolesandStatus", Parameters.with("id", UUID.fromString(uuid)).and("status",status).and("roles", roles)).firstResult();
|
||||
userSingle = UsersEntity.find("#Users.byUUIDandRolesandStatus", Parameters.with("id", UUID.fromString(uuid)).and("status",status).and("roles", roles)).firstResult();
|
||||
}
|
||||
responseHttp = Response.ok(userSingle).build();
|
||||
|
||||
@ -103,26 +107,26 @@ public class UsersRessources {
|
||||
if(email != null){
|
||||
UsersEntity userSingle = UsersEntity.findByEmail(email);
|
||||
if((roles != null) && (status == null)){
|
||||
userSingle = UsersEntity.find("Users.byEmailandRoles", Parameters.with("email", email).and("roles",roles)).firstResult();
|
||||
userSingle = UsersEntity.find("#Users.byEmailandRoles", Parameters.with("email", email).and("roles",roles)).firstResult();
|
||||
}
|
||||
if((roles == null) && (status != null)){
|
||||
userSingle = UsersEntity.find("Users.byEmailandStatus", Parameters.with("email", email).and("status",status)).firstResult();
|
||||
userSingle = UsersEntity.find("#Users.byEmailandStatus", Parameters.with("email", email).and("status",status)).firstResult();
|
||||
}
|
||||
if((roles != null) && (status != null)){
|
||||
userSingle = UsersEntity.find("Users.byEmailandRolesandStatus", Parameters.with("email", email).and("status",status).and("roles", roles)).firstResult();
|
||||
userSingle = UsersEntity.find("#Users.byEmailandRolesandStatus", Parameters.with("email", email).and("status",status).and("roles", roles)).firstResult();
|
||||
}
|
||||
responseHttp = Response.ok(userSingle).build();
|
||||
}
|
||||
if(search != null){
|
||||
List<UsersEntity> usersList = UsersEntity.list("Users.bySearch", Parameters.with("search", search));
|
||||
List<UsersEntity> usersList = UsersEntity.find("#Users.bySearch", Parameters.with("search", search)).page(Page.of(page, nbPages)).list();
|
||||
if((roles != null) && (status == null)){
|
||||
usersList = UsersEntity.find("Users.bySearchandRoles", Parameters.with("search", search).and("roles",roles)).list();
|
||||
usersList = UsersEntity.find("#Users.bySearchandRoles", Parameters.with("search", search).and("roles",roles)).page(Page.of(page, nbPages)).list();
|
||||
}
|
||||
if((roles == null) && (status != null)){
|
||||
usersList = UsersEntity.find("Users.bySearchandStatus", Parameters.with("search", search).and("status",status)).firstResult();
|
||||
usersList = UsersEntity.find("#Users.bySearchandStatus", Parameters.with("search", search).and("status",status)).page(Page.of(page, nbPages)).list();
|
||||
}
|
||||
if((roles != null) && (status != null)){
|
||||
usersList = UsersEntity.find("Users.bySearchandRolesandStatus", Parameters.with("search", search).and("status",status).and("roles", roles)).firstResult();
|
||||
usersList = UsersEntity.find("#Users.bySearchandRolesandStatus", Parameters.with("search", search).and("status",status).and("roles", roles)).page(Page.of(page, nbPages)).list();
|
||||
}
|
||||
responseHttp = Response.ok(usersList).build();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user