fix: revert to get only the questions from the current user
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package fr.itsonus.bousoleplussbackend.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@@ -44,6 +45,7 @@ public class Axe {
|
||||
|
||||
@OneToMany(mappedBy = "axe")
|
||||
@ToString.Exclude
|
||||
@JsonIgnore
|
||||
private Set<Question> questions;
|
||||
|
||||
@Override
|
||||
|
@@ -32,7 +32,7 @@ public class Question {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "axe_id")
|
||||
@JsonIgnore
|
||||
@ToString.Exclude
|
||||
private Axe axe;
|
||||
|
||||
@JsonIgnore
|
||||
@@ -42,7 +42,6 @@ public class Question {
|
||||
@Size(max = 200)
|
||||
private String label;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 500)
|
||||
private String description;
|
||||
|
||||
|
@@ -1,24 +0,0 @@
|
||||
package fr.itsonus.bousoleplussbackend.projections;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Axe;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.rest.core.config.Projection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Projection(name = "axeWithQuestion", types = {Axe.class})
|
||||
public interface AxeWithQuestion {
|
||||
|
||||
Integer getIdentifier();
|
||||
|
||||
String getShortTitle();
|
||||
|
||||
String getTitle();
|
||||
|
||||
String getDescription();
|
||||
|
||||
String getColor();
|
||||
|
||||
@Value("#{target.getQuestions()}")
|
||||
List<QuestionProj> getQuestions();
|
||||
}
|
@@ -1,16 +1,11 @@
|
||||
package fr.itsonus.bousoleplussbackend.repositories;
|
||||
|
||||
import fr.itsonus.bousoleplussbackend.models.Axe;
|
||||
import fr.itsonus.bousoleplussbackend.projections.AxeWithQuestion;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
|
||||
@RepositoryRestResource(excerptProjection = AxeWithQuestion.class)
|
||||
public interface AxeRepository extends CrudRepository<Axe, Long> {
|
||||
@RepositoryRestResource
|
||||
public interface AxeRepository extends CrudRepository<Axe, Long>, JpaSpecificationExecutor<Axe> {
|
||||
|
||||
@RestResource(path = "me", rel = "me")
|
||||
@Query("SELECT DISTINCT a FROM Axe a INNER JOIN a.questions as q WHERE q.userId = ?#{principal.id}")
|
||||
Iterable<Axe> findAllWithQuestionsOfCurrentUser();
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@ import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@RepositoryRestResource
|
||||
public interface QuestionRepository extends CrudRepository<Question, Long> {
|
||||
@@ -14,4 +13,5 @@ public interface QuestionRepository extends CrudRepository<Question, Long> {
|
||||
@RestResource(path="byAxeId", rel="byAxeId")
|
||||
@Query("SELECT q FROM Question q JOIN q.axe a WHERE q.axe.id = :id AND user_id = ?#{principal.id}")
|
||||
Iterable<Question> findAllByAxeId(@Param("id") final Long id);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user