モンゴDB改ページ

参考:https://blog.csdn.net/qq_40715775/article/details/83153808

依存性:

      <依存性> 
            <のgroupId> org.springframework.boot </のgroupId> 
            <たartifactId>ばねブートスタータデータMongoDBの</たartifactId> 
        </依存> 
        <依存性> 
            <のgroupId> org.springframework.boot </のgroupId> 
            <たartifactId>春・ブート・スターター・データ・休息</たartifactId> 
        </依存関係>

 

ドメイン:

@NoArgsConstructor 
@AllArgsConstructor 
@Document(収集 = Constant.MILESTONE_WORK_TABLE)
 パブリック クラス MilestoneInfoが実装シリアライズ{ 

    プライベート 静的 最終 長いのserialVersionUID = 1L 

    @Id 
    プライベート文字列ID; 

    プライベート文字列のmawb;}

 

設定:(application.propeties)

#spring.data.mongodb.uri =のMongoDB:// ユーザ名:パスワード@のIP:ポート/データベース 
spring.data.mongodb.database = SERVICE-sea- テスト
spring.data.mongodb.host = 127.0.0.1 
spring.data。 mongodb.port = 27017 
#spring.data.mongodb.username = ルート
#spring.data.mongodb.password =ルート

 

 

倉庫:

  @RepositoryRestResource(パス= "作業台"、collectionResourceRelは= "作業テーブル" パブリック インターフェース WorkTableRepositoryが   延び MongoRepository <MilestoneInfo、文字列> { 
    
//     @query( "{\" sendtimes \ ":{\" $正規表現\ ":?0} ?、\ "courierbillNo \":1} ") 
    一覧<MilestoneInfo> findByReasonAndCustomerAndSendTimesLessThan(文字列のため、文字列の顧客は、int型)sendTimersを。
    
//     @query( "{\" sendtimes \ ":{\" $の正規表現\ ":? 0}、\"成功\ "?:1}") 
    一覧<MilestoneInfo> findByMawbOrCustomerOrOrderNoOrStatusOrCourierBillNoOrSendTimesLessThan(文字列mawb、文字列の顧客、文字列ORDERNO、文字列の状態、文字列courierbillNo、整数sendTimers)。
    リスト
   
    <MilestoneInfo> findByMawbAndCustomerAndOrderNoAndStatusAndCourierBillNoAndSendTimesLessThan(文字列mawb、文字列顧客文字列ORDERNO、文字列のステータス、文字列courierbillNo、整数sendTimers)。

}

 

 

 

ウェブ:

    ( "/ {ページ} / {サイズ}検索" @GetMapping 公共ページ<MilestoneInfo> findByPageSort(@PathVariable( "ページ")のintページPathVariable( "サイズ")@、int型のサイズ){ 
        
        
        // 並び替えソート=新しい新(「ID」); 
        ソートは、ソート= 新しい新しいソート(Direction.ASC、「MAWB」); 
        
//         設定ページのためのページング可能クエリインターフェイスは、その実装クラスをPageRequest、植物がPageRequest提供された方法により作成することができます:
 //         パブリック静的のPageRequest(ページはint、int型のサイズは)
 //         また、ソートPageRequestに添加してもよい:
 //         (ページはint、int型のサイズ、ソートソート)のパブリック静的PageRequest 
        
        
        PageRequestページング可能 = PageRequest。、サイズ、ソート)。
        ページ <MilestoneInfo> pagedatas = workTableRepository.findAll(ページング可能)。
        返すpagedatasを。
    }

 

おすすめ

転載: www.cnblogs.com/lshan/p/11532941.html