get list publishers for a user

This commit is contained in:
Valentin CZERYBA 2023-01-08 11:48:33 +01:00
parent 5b30166cbf
commit e97a50b635
4 changed files with 30 additions and 26 deletions

View File

@ -2,6 +2,7 @@ package com.covas.Entity;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import javax.persistence.Column; import javax.persistence.Column;
@ -58,4 +59,8 @@ public class PublisherEntity extends PanacheEntityBase implements Serializable {
@ManyToOne(cascade = CascadeType.ALL) @ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "users_id", referencedColumnName = "id") @JoinColumn(name = "users_id", referencedColumnName = "id")
public UsersEntity users; public UsersEntity users;
public static List<PublisherEntity> findByUsers(String uuid){
return find("users_id", uuid).list();
}
} }

View File

@ -0,0 +1,22 @@
package com.covas.Json;
import java.util.Collection;
import com.covas.Entity.PublisherEntity;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class PublisherByUser {
public final String pseudo;
public final Collection<PublisherEntity> publishers;
public PublisherByUser(String pseudo, Collection<PublisherEntity> publishers){
this.pseudo = pseudo;
this.publishers = publishers;
}
}

View File

@ -1,21 +0,0 @@
package com.covas.Json;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class PublisherSingle {
public final String pseudo;
public final String text;
public final Short status;
public final String url;
public PublisherSingle(String pseudo, String text, Short status, String url){
this.pseudo = pseudo;
this.text = text;
this.status = status;
this.url = url;
}
}

View File

@ -10,7 +10,6 @@ import javax.annotation.security.RolesAllowed;
import javax.inject.Inject; import javax.inject.Inject;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam; import javax.ws.rs.CookieParam;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
@ -29,9 +28,8 @@ import javax.ws.rs.core.Response;
import com.covas.Classes.Hash; import com.covas.Classes.Hash;
import com.covas.Entity.PublisherEntity; import com.covas.Entity.PublisherEntity;
import com.covas.Entity.UsersEntity; import com.covas.Entity.UsersEntity;
import com.covas.Json.PublisherSingle; import com.covas.Json.PublisherByUser;
import com.covas.Json.UserExist; import com.covas.Json.UserExist;
import com.covas.Json.UserSingle;
import io.quarkus.panache.common.Page; import io.quarkus.panache.common.Page;
import io.quarkus.panache.common.Parameters; import io.quarkus.panache.common.Parameters;
@ -162,8 +160,8 @@ public class PublisherRessources {
} }
Response responseHttp = Response.status(status).build(); Response responseHttp = Response.status(status).build();
if (status.equals(Response.Status.OK)) { if (status.equals(Response.Status.OK)) {
// responseHttp = Response.status(status).entity(new PublisherSingle(user.name, user.pseudo, user.firstName, user.description)) responseHttp = Response.status(status).entity(new PublisherByUser(user.pseudo, user.publisher))
//.build(); .build();
} }
return responseHttp; return responseHttp;
} }