update delete for publisher admin

This commit is contained in:
Valentin CZERYBA 2023-01-07 21:46:22 +01:00
parent d0b6cee3ea
commit 7f9a149196

View File

@ -294,21 +294,21 @@ public class PublisherRessources {
@Path("{id}") @Path("{id}")
@RolesAllowed("Admin") @RolesAllowed("Admin")
@Transactional @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) { @PathParam("id") String id) {
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);
if (status.equals(Response.Status.OK)) { if (status.equals(Response.Status.OK)) {
UsersEntity singleUser = UsersEntity.find("id", UUID.fromString(id)).firstResult(); PublisherEntity singlePublisher = PublisherEntity.find("id", UUID.fromString(id)).firstResult();
if (singleUser == null) { if (singlePublisher == null) {
status = Response.Status.NOT_FOUND; status = Response.Status.NOT_FOUND;
} else { } else {
singleUser.status = -1; singlePublisher.status = -1;
singleUser.updated_at = LocalDateTime.now(); singlePublisher.updated_at = LocalDateTime.now();
singleUser.deleted_at = LocalDateTime.now(); singlePublisher.deleted_at = LocalDateTime.now();
singleUser.persist(); singlePublisher.persist();
if (!singleUser.isPersistent()) { if (!singlePublisher.isPersistent()) {
status = Response.Status.NOT_MODIFIED; status = Response.Status.NOT_MODIFIED;
} }
} }
@ -344,21 +344,21 @@ public class PublisherRessources {
@Path("/disable/{id}") @Path("/disable/{id}")
@RolesAllowed("Admin") @RolesAllowed("Admin")
@Transactional @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) { @PathParam("id") String id) {
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);
if (status.equals(Response.Status.OK)) { if (status.equals(Response.Status.OK)) {
UsersEntity singleUser = UsersEntity.find("id", UUID.fromString(id)).firstResult(); PublisherEntity singlePublisher = PublisherEntity.find("id", UUID.fromString(id)).firstResult();
if (singleUser == null) { if (singlePublisher == null) {
status = Response.Status.NOT_FOUND; status = Response.Status.NOT_FOUND;
} else { } else {
singleUser.status = 0; singlePublisher.status = 0;
singleUser.updated_at = LocalDateTime.now(); singlePublisher.updated_at = LocalDateTime.now();
singleUser.deleted_at = LocalDateTime.now(); singlePublisher.deleted_at = LocalDateTime.now();
singleUser.persist(); singlePublisher.persist();
if (!singleUser.isPersistent()) { if (!singlePublisher.isPersistent()) {
status = Response.Status.NOT_MODIFIED; status = Response.Status.NOT_MODIFIED;
} }
} }