我想为我的代码库暴露新的端点,同时还要扩展 RevisionRepository。
@RepositoryRestResource(collectionResourceRel = "persons", itemResourceRel = "person", path = "persons")
public interface PersonRepository extends PagingAndSortingRepository<PersonEntity, Long>, RevisionRepository<PersonEntity, Long, Integer> {
Revision<Integer, PersonEntity> findLastChangeRevision(@Param("id") Long id);
Revisions<Integer, PersonEntity> findRevisions(@Param("id") Long id);
Page<Revision<Integer, PersonEntity>> findRevisions(@Param("id") Long id, Pageable pageable);
PersonEntity findByName(@Param("name") String name);
}
目前我的问题是,这些新的方法没有作为URL公开(findLastChangeRevision
, findRevisions
),只有findByName
在搜索URL下。我对实际的URL形式并不特别在意,只要它能工作。
我现在唯一知道的选择是:
- 分离修订存储库
- 创建一个映射到"/"的新控制器,以替换Spring Data Rest创建的控制器,并手动添加所有存储库链接。其中一个问题是我的链接将是硬编码的(与链接到控制器时不同),路径将是相对的--不一定是坏事,但会让所有东西变得不一致。
- 添加映射到修订存储库的"/"链接
对于我上述的选择,我有很多保留意见。我不确定该如何继续。