2015-12-10 45 views
4

我不必暴露RevisionRepository(春季數據Envers)端點爲我的寶庫,它作爲下方延伸RevisionRepository問題庫:春數據舒適春數據Envers:如何暴露REST API的擴展版本庫

@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中的那些方法,但它不起作用。

謝謝你......

回答

5

你必須編寫自定義控制的方法來實現這一點,類似如下:

@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(); 
    } 
}