在Spring Data REST的上下文中,我想针对单个查询的结果公开搜索/过滤器功能。如果我的查询是findAll,那将是开箱即用的(足以扩展QueryDslPredicateExecutor)。但是,如何将自定义查询(findMyNotes)与用户提供的其他过滤功能(标记为已完成)结合起来。我的意思是:
@Entity
class Note {
@Id
private UUID id;
private UUID personId;
private String status;
private String text;
}
@RepositoryRestResource(path = "notes", itemResourceRel = "notes", collectionResourceRel = "notes")
interface NoteRepository extends JpaRepository<Note, UUID>, QueryDslPredicateExecutor<Note> {
@RestResource(path="notes/my")
@Query("select n from Note n where n.personId=:creatorId")
Page<Note> findDone(@Param("creatorId") UUID creatorId, Predicate predicate, Pageable pageable);
}
Run Code Online (Sandbox Code Playgroud)
我什么也没发现。因此,我在考虑使用AOP和:
@RestResource?)映射到org.springframework.data.querydsl.QueryDslPredicateExecutor#findAll(Predicate, org.springframework.data.domain.Pageable)@Query示例中的内容)问题是我不知道如何做第一点(除了在servlet过滤器中将其黑客化)-将多个路径映射到同一个findAll方法。
或者,也许我错过了一些开箱即用的功能?