Spring Data Rest & Spring Data Envers:如何为扩展 Revision Repository 的 Repository 公开 REST API

Spring Data Rest & Spring Data Envers: How to expose REST API for Repository that extends Revision Repository

我在为我的存储库公开 RevisionRepository(Spring Data Envers)端点时遇到问题,它扩展了 RevisionRepository,如下所示:

    @RepositoryRestResource(path = "disciplines", itemResourceRel = "disciplines")
    public interface DisciplineRepository extends
        RevisionRepository<Discipline, Integer, Integer>,
        CrudRepository<Discipline, Integer>{

        @RestResource(path = "findByName", rel = "findByName")
        List<Discipline> findByName(String name);

    }

只暴露了findByName方法,有没有其他方法可以暴露RevisionRepository中的方法?我也试图覆盖 DisciplineRepository 中的那些方法,但它不起作用。

谢谢...

您必须编写一个自定义控制器方法来实现它,如下所示:

@Autowired
private DisciplineRepository disciplineRepository; 

@RequestMapping(value = "/disciplines/{id}/changes", method = RequestMethod.GET)
public ResponseEntity<Resource<RevisionsObject>> getDisciplineRevisions(@PathVariable(value = "id")Discipline discipline) {
    if (discipline != null) {
        Revisions<Integer, Discipline> disciplineRevisions = disciplineRepository.findRevisions(discipline.getId());
        return new ResponseEntity<>(new Resource<>(disciplineRevisions), HttpStatus.OK);
    } else {
        throw new ResourceNotFoundException();
    }
}