From 7f9a149196421bd7a00ff0ca9cd63f9d81eb74ac Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 7 Jan 2023 21:46:22 +0100 Subject: [PATCH] update delete for publisher admin --- .../covas/Resources/PublisherRessources.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/covas/Resources/PublisherRessources.java b/src/main/java/com/covas/Resources/PublisherRessources.java index 5d08820..07756c7 100644 --- a/src/main/java/com/covas/Resources/PublisherRessources.java +++ b/src/main/java/com/covas/Resources/PublisherRessources.java @@ -294,21 +294,21 @@ public class PublisherRessources { @Path("{id}") @RolesAllowed("Admin") @Transactional - public Response changeStatusSingleUserToDelete(@Context SecurityContext ctx, @CookieParam("user") String userCookie, + public Response changeStatusSinglePublisherToDelete(@Context SecurityContext ctx, @CookieParam("user") String userCookie, @PathParam("id") String id) { UUID kid = UUID.fromString(jwt.getClaim(Claims.kid)); UsersEntity user = UsersEntity.findById(kid); Response.Status status = getResponseCheck(ctx, userCookie, user); if (status.equals(Response.Status.OK)) { - UsersEntity singleUser = UsersEntity.find("id", UUID.fromString(id)).firstResult(); - if (singleUser == null) { + PublisherEntity singlePublisher = PublisherEntity.find("id", UUID.fromString(id)).firstResult(); + if (singlePublisher == null) { status = Response.Status.NOT_FOUND; } else { - singleUser.status = -1; - singleUser.updated_at = LocalDateTime.now(); - singleUser.deleted_at = LocalDateTime.now(); - singleUser.persist(); - if (!singleUser.isPersistent()) { + singlePublisher.status = -1; + singlePublisher.updated_at = LocalDateTime.now(); + singlePublisher.deleted_at = LocalDateTime.now(); + singlePublisher.persist(); + if (!singlePublisher.isPersistent()) { status = Response.Status.NOT_MODIFIED; } } @@ -344,21 +344,21 @@ public class PublisherRessources { @Path("/disable/{id}") @RolesAllowed("Admin") @Transactional - public Response changeStatusSingleUserToDisable(@Context SecurityContext ctx, @CookieParam("user") String userCookie, + public Response changeStatusSinglePublisherToDisable(@Context SecurityContext ctx, @CookieParam("user") String userCookie, @PathParam("id") String id) { UUID kid = UUID.fromString(jwt.getClaim(Claims.kid)); UsersEntity user = UsersEntity.findById(kid); Response.Status status = getResponseCheck(ctx, userCookie, user); if (status.equals(Response.Status.OK)) { - UsersEntity singleUser = UsersEntity.find("id", UUID.fromString(id)).firstResult(); - if (singleUser == null) { + PublisherEntity singlePublisher = PublisherEntity.find("id", UUID.fromString(id)).firstResult(); + if (singlePublisher == null) { status = Response.Status.NOT_FOUND; } else { - singleUser.status = 0; - singleUser.updated_at = LocalDateTime.now(); - singleUser.deleted_at = LocalDateTime.now(); - singleUser.persist(); - if (!singleUser.isPersistent()) { + singlePublisher.status = 0; + singlePublisher.updated_at = LocalDateTime.now(); + singlePublisher.deleted_at = LocalDateTime.now(); + singlePublisher.persist(); + if (!singlePublisher.isPersistent()) { status = Response.Status.NOT_MODIFIED; } }