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

时间:2015-12-10 08:05:12

标签: java rest spring-data-rest

我有问题要为我的存储库公开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中覆盖这些方法,但它不起作用。

谢谢......

1 个答案:

答案 0 :(得分:6)

您必须编写自定义控制器方法来实现此功能,如下所示:

 <?php


// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'Axxxxxxxxxxxxxxxxxx' );


$registrationIds = array("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" );

// prep the bundle
$msg = array
(
    'message'       => 'here is a message. message',
    'title'         => 'This is a title. title',
    'subtitle'      => 'This is a subtitle. subtitle',
    'tickerText'    => 'Ticker text here...Ticker text here...Ticker text      here',
    'vibrate'   => 1,
    'sound'     => 1
);

$fields = array
(
    'registration_ids'  => $registrationIds,
    'data'              => $msg
);

$headers = array
(
    'Authorization: key=' . API_ACCESS_KEY,
    'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );

echo $result;
?>