- 在interface中定义
public interface LoginLogRepository extends MongoRepository<LoginLog, Long>{
Page<LoginLog> findByUserid(String userid, Pageable page);
} - 直接使用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;
}
网友评论