美文网首页
sprintboot分页查询mongodb

sprintboot分页查询mongodb

作者: Spring第二春 | 来源:发表于2017-07-03 11:38 被阅读0次
    1. 在interface中定义
      public interface LoginLogRepository extends MongoRepository<LoginLog, Long>{
      Page<LoginLog> findByUserid(String userid, Pageable page);
      }
    2. 直接使用pageable接收参数
      public Page actpage(@RequestParam String userid,
      @PageableDefault(value = 2, sort = { "logintime" }, direction = Sort.Direction.DESC) Pageable pageable) {
      ServiceInstance instance = client.getLocalServiceInstance();
      Page<LoginLog> log = loginLogRepository.findByUserid(userid, pageable);
      logger.info("/act, host:" + instance.getHost() + ", service_id:" + instance.getServiceId() + ", result:" + log.getSize());
      return log;
      }

    相关文章

      网友评论

          本文标题:sprintboot分页查询mongodb

          本文链接:https://www.haomeiwen.com/subject/hapacxtx.html