add patch publisher
This commit is contained in:
parent
7f9a149196
commit
5b30166cbf
@ -372,35 +372,30 @@ public class PublisherRessources {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Transactional
|
||||
@Path("{id}")
|
||||
public Response updateUserAdmin(@Context SecurityContext ctx, @CookieParam("user") String userCookie,
|
||||
UsersEntity users, @PathParam("id") String id) {
|
||||
public Response updatePublisherAdmin(@Context SecurityContext ctx, @CookieParam("user") String userCookie,
|
||||
PublisherEntity publishers, @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 usersOrig = UsersEntity.findById(UUID.fromString(id));
|
||||
if (usersOrig == null) {
|
||||
PublisherEntity publishersOrig = PublisherEntity.findById(UUID.fromString(id));
|
||||
if (publishersOrig == null) {
|
||||
status = Response.Status.NOT_FOUND;
|
||||
} else {
|
||||
usersOrig.name = users.name;
|
||||
usersOrig.firstName = users.firstName;
|
||||
usersOrig.email = users.email;
|
||||
usersOrig.birth = LocalDate.of(users.birth.getYear(), users.birth.getMonth(),
|
||||
users.birth.getDayOfMonth());
|
||||
usersOrig.updated_at = LocalDateTime.now();
|
||||
if(users.password.length() > 0){
|
||||
usersOrig.password = Hash
|
||||
.encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8)));
|
||||
publishersOrig.description = publishers.description;
|
||||
publishersOrig.url = publishers.url;
|
||||
publishersOrig.type = publishers.type;
|
||||
|
||||
publishersOrig.updated_at = LocalDateTime.now();
|
||||
|
||||
if(publishers.status == 1){
|
||||
publishersOrig.deleted_at = null;
|
||||
publishersOrig.status = 1;
|
||||
}
|
||||
usersOrig.roles = users.roles;
|
||||
if(users.status == 1){
|
||||
usersOrig.deleted_at = null;
|
||||
usersOrig.status = 1;
|
||||
}
|
||||
usersOrig.persist();
|
||||
if (!usersOrig.isPersistent()) {
|
||||
publishersOrig.persist();
|
||||
if (!publishersOrig.isPersistent()) {
|
||||
status = Response.Status.NOT_MODIFIED;
|
||||
}
|
||||
}
|
||||
@ -421,13 +416,13 @@ public class PublisherRessources {
|
||||
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
||||
if (status.equals(Response.Status.OK)) {
|
||||
|
||||
UsersEntity usersOrig = UsersEntity.findById(UUID.fromString(id));
|
||||
if (usersOrig == null) {
|
||||
PublisherEntity publishersOrig = PublisherEntity.findById(UUID.fromString(id));
|
||||
if (publishersOrig == null) {
|
||||
status = Response.Status.NOT_FOUND;
|
||||
} else {
|
||||
usersOrig.status = 1;
|
||||
usersOrig.persist();
|
||||
if (!usersOrig.isPersistent()) {
|
||||
publishersOrig.status = 1;
|
||||
publishersOrig.persist();
|
||||
if (!publishersOrig.isPersistent()) {
|
||||
status = Response.Status.NOT_MODIFIED;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user