message resources wip
This commit is contained in:
parent
90ba63afd5
commit
0dba06a39b
@ -90,7 +90,7 @@ public class CommentRessources {
|
||||
|
||||
responseHttp = Response.ok(listComments).build();
|
||||
if(uuid != null){
|
||||
CommentEntity commentSingle= PublisherEntity.findById(UUID.fromString(uuid));
|
||||
CommentEntity commentSingle = CommentEntity.findById(UUID.fromString(uuid));
|
||||
responseHttp = Response.ok(commentSingle).build();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.covas.Entity.CommentEntity;
|
||||
import com.covas.Entity.MessageEntity;
|
||||
import com.covas.Entity.PublisherEntity;
|
||||
import com.covas.Entity.UsersEntity;
|
||||
|
||||
@ -36,7 +37,7 @@ import org.jboss.logging.Logger;
|
||||
import org.postgresql.shaded.com.ongres.scram.common.bouncycastle.base64.Base64;
|
||||
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("mewsage")
|
||||
@Path("message")
|
||||
public class MessageRessources {
|
||||
private static final Logger LOGGER = Logger.getLogger(UsersRessources.class);
|
||||
@Inject
|
||||
@ -69,7 +70,7 @@ public class MessageRessources {
|
||||
/// GET
|
||||
@GET
|
||||
@RolesAllowed("Admin")
|
||||
public Response getComments(@CookieParam("user") String userCookie, @Context SecurityContext ctx,
|
||||
public Response getMessages(@CookieParam("user") String userCookie, @Context SecurityContext ctx,
|
||||
@QueryParam("page") Integer page, @QueryParam("nbPages") Integer nbPages,
|
||||
@QueryParam("status") Short status,
|
||||
@QueryParam("search") String search,
|
||||
@ -85,19 +86,19 @@ public class MessageRessources {
|
||||
Response.Status statusHttp = getResponseCheck(ctx, userCookie, user);
|
||||
Response responseHttp = Response.status(statusHttp).build();
|
||||
if (statusHttp.equals(Response.Status.OK)) {
|
||||
List<CommentEntity> listComments = CommentEntity.findAll().page(Page.of(page, nbPages)).list();
|
||||
List<MessageEntity> listMessages = MessageEntity.findAll().page(Page.of(page, nbPages)).list();
|
||||
|
||||
|
||||
responseHttp = Response.ok(listComments).build();
|
||||
responseHttp = Response.ok(listMessages).build();
|
||||
if(uuid != null){
|
||||
CommentEntity commentSingle= PublisherEntity.findById(UUID.fromString(uuid));
|
||||
responseHttp = Response.ok(commentSingle).build();
|
||||
MessageEntity messageEntity= MessageEntity.findById(UUID.fromString(uuid));
|
||||
responseHttp = Response.ok(messageEntity).build();
|
||||
}
|
||||
|
||||
if(search != null){
|
||||
List<CommentEntity> commentsList = CommentEntity.find("#Comment.bySearch", Parameters.with("comment", search)).page(Page.of(page, nbPages)).list();
|
||||
List<MessageEntity> messagesList = MessageEntity.find("#Message.bySearch", Parameters.with("content", search)).page(Page.of(page, nbPages)).list();
|
||||
|
||||
responseHttp = Response.ok(commentsList).build();
|
||||
responseHttp = Response.ok(messagesList).build();
|
||||
|
||||
}
|
||||
}
|
||||
@ -113,7 +114,7 @@ public class MessageRessources {
|
||||
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
||||
Response responseHttp = Response.status(status).build();
|
||||
if (status.equals(Response.Status.OK)){
|
||||
responseHttp = Response.ok(CommentEntity.count()).build();
|
||||
responseHttp = Response.ok(MessageEntity.count()).build();
|
||||
}
|
||||
return responseHttp;
|
||||
}
|
||||
@ -121,7 +122,7 @@ public class MessageRessources {
|
||||
@GET
|
||||
@RolesAllowed("Admin")
|
||||
@Path("{id}")
|
||||
public Response getSingleComment(@PathParam("id") String id, @CookieParam("user") String userCookie,
|
||||
public Response getSingleMessage(@PathParam("id") String id, @CookieParam("user") String userCookie,
|
||||
@Context SecurityContext ctx) {
|
||||
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
|
||||
UsersEntity user = UsersEntity.findById(kid);
|
||||
@ -129,10 +130,10 @@ public class MessageRessources {
|
||||
Response responseHttp = Response.status(status).build();
|
||||
if (status.equals(Response.Status.OK)) {
|
||||
UUID uid = UUID.fromString(id);
|
||||
CommentEntity comment = CommentEntity.findById(uid);
|
||||
MessageEntity message = MessageEntity.findById(uid);
|
||||
responseHttp = Response.status(Response.Status.NOT_FOUND).build();
|
||||
if (comment != null) {
|
||||
responseHttp = Response.ok(comment).build();
|
||||
if (message != null) {
|
||||
responseHttp = Response.ok(message).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user