更改@Deprecated的PageRequest方法

pull/8/head
Henry 2018-05-09 16:28:46 +08:00
parent edefe092f4
commit b9023a7b26
12 changed files with 17 additions and 17 deletions

View File

@ -182,7 +182,7 @@ public class AdminController extends BaseController {
@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "page", defaultValue = "0") Integer page,
@RequestParam(value = "size", defaultValue = "10") Integer size) { @RequestParam(value = "size", defaultValue = "10") Integer size) {
Sort sort = new Sort(Sort.Direction.DESC, "logId"); Sort sort = new Sort(Sort.Direction.DESC, "logId");
Pageable pageable = new PageRequest(page, size, sort); Pageable pageable = PageRequest.of(page, size, sort);
Page<Logs> logs = logsService.findAllLogs(pageable); Page<Logs> logs = logsService.findAllLogs(pageable);
model.addAttribute("logs", logs); model.addAttribute("logs", logs);
return "admin/widget/_logs-all"; return "admin/widget/_logs-all";

View File

@ -65,7 +65,7 @@ public class AttachmentController {
@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "page", defaultValue = "0") Integer page,
@RequestParam(value = "size", defaultValue = "18") Integer size) { @RequestParam(value = "size", defaultValue = "18") Integer size) {
Sort sort = new Sort(Sort.Direction.DESC, "attachId"); Sort sort = new Sort(Sort.Direction.DESC, "attachId");
Pageable pageable = new PageRequest(page, size, sort); Pageable pageable = PageRequest.of(page, size, sort);
Page<Attachment> attachments = attachmentService.findAllAttachments(pageable); Page<Attachment> attachments = attachmentService.findAllAttachments(pageable);
model.addAttribute("attachments", attachments); model.addAttribute("attachments", attachments);
@ -84,7 +84,7 @@ public class AttachmentController {
@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "page", defaultValue = "0") Integer page,
@RequestParam(value = "id") String id) { @RequestParam(value = "id") String id) {
Sort sort = new Sort(Sort.Direction.DESC, "attachId"); Sort sort = new Sort(Sort.Direction.DESC, "attachId");
Pageable pageable = new PageRequest(page, 18, sort); Pageable pageable = PageRequest.of(page, 18, sort);
Page<Attachment> attachments = attachmentService.findAllAttachments(pageable); Page<Attachment> attachments = attachmentService.findAllAttachments(pageable);
model.addAttribute("attachments", attachments); model.addAttribute("attachments", attachments);
model.addAttribute("id", id); model.addAttribute("id", id);

View File

@ -71,7 +71,7 @@ public class CommentController extends BaseController{
@RequestParam(value = "page",defaultValue = "0") Integer page, @RequestParam(value = "page",defaultValue = "0") Integer page,
@RequestParam(value = "size",defaultValue = "10") Integer size){ @RequestParam(value = "size",defaultValue = "10") Integer size){
Sort sort = new Sort(Sort.Direction.DESC,"commentDate"); Sort sort = new Sort(Sort.Direction.DESC,"commentDate");
Pageable pageable = new PageRequest(page,size,sort); Pageable pageable = PageRequest.of(page,size,sort);
Page<Comment> comments = commentService.findAllComments(status,pageable); Page<Comment> comments = commentService.findAllComments(status,pageable);
model.addAttribute("comments",comments); model.addAttribute("comments",comments);
model.addAttribute("publicCount",commentService.findAllComments(0,pageable).getTotalElements()); model.addAttribute("publicCount",commentService.findAllComments(0,pageable).getTotalElements());

View File

@ -142,7 +142,7 @@ public class PageController {
@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "page", defaultValue = "0") Integer page,
@RequestParam(value = "size", defaultValue = "18") Integer size) { @RequestParam(value = "size", defaultValue = "18") Integer size) {
Sort sort = new Sort(Sort.Direction.DESC, "galleryId"); Sort sort = new Sort(Sort.Direction.DESC, "galleryId");
Pageable pageable = new PageRequest(page, size, sort); Pageable pageable = PageRequest.of(page, size, sort);
Page<Gallery> galleries = galleryService.findAllGalleries(pageable); Page<Gallery> galleries = galleryService.findAllGalleries(pageable);
model.addAttribute("galleries", galleries); model.addAttribute("galleries", galleries);
return "admin/admin_page_gallery"; return "admin/admin_page_gallery";

View File

@ -66,7 +66,7 @@ public class PostController extends BaseController{
@RequestParam(value = "page",defaultValue = "0") Integer page, @RequestParam(value = "page",defaultValue = "0") Integer page,
@RequestParam(value = "size",defaultValue = "10") Integer size){ @RequestParam(value = "size",defaultValue = "10") Integer size){
Sort sort = new Sort(Sort.Direction.DESC,"postDate"); Sort sort = new Sort(Sort.Direction.DESC,"postDate");
Pageable pageable = new PageRequest(page,size,sort); Pageable pageable = PageRequest.of(page,size,sort);
Page<Post> posts = postService.findPostByStatus(status,HaloConst.POST_TYPE_POST,pageable); Page<Post> posts = postService.findPostByStatus(status,HaloConst.POST_TYPE_POST,pageable);
model.addAttribute("posts",posts); model.addAttribute("posts",posts);
model.addAttribute("publishCount",postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable).getTotalElements()); model.addAttribute("publishCount",postService.findPostByStatus(0,HaloConst.POST_TYPE_POST,pageable).getTotalElements());
@ -93,7 +93,7 @@ public class PostController extends BaseController{
try { try {
//排序规则 //排序规则
Sort sort = new Sort(Sort.Direction.DESC,"postId"); Sort sort = new Sort(Sort.Direction.DESC,"postId");
Pageable pageable = new PageRequest(page,size,sort); Pageable pageable = PageRequest.of(page,size,sort);
model.addAttribute("posts",postService.searchPosts(keyword,pageable)); model.addAttribute("posts",postService.searchPosts(keyword,pageable));
}catch (Exception e){ }catch (Exception e){
log.error("未知错误:{0}",e.getMessage()); log.error("未知错误:{0}",e.getMessage());

View File

@ -61,7 +61,7 @@ public class ArchivesController extends BaseController {
//所有文章数据分页material主题适用 //所有文章数据分页material主题适用
Sort sort = new Sort(Sort.Direction.DESC, "postDate"); Sort sort = new Sort(Sort.Direction.DESC, "postDate");
Pageable pageable = new PageRequest(page - 1, 5, sort); Pageable pageable = PageRequest.of(page - 1, 5, sort);
Page<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable); Page<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
model.addAttribute("posts", posts); model.addAttribute("posts", posts);
return this.render("archives"); return this.render("archives");
@ -109,7 +109,7 @@ public class ArchivesController extends BaseController {
model.addAttribute("afterPost", afterPosts.get(afterPosts.size() - 1)); model.addAttribute("afterPost", afterPosts.get(afterPosts.size() - 1));
} }
Sort sort = new Sort(Sort.Direction.DESC,"commentDate"); Sort sort = new Sort(Sort.Direction.DESC,"commentDate");
Pageable pageable = new PageRequest(0,999,sort); Pageable pageable = PageRequest.of(0,999,sort);
Page<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post,pageable,2); Page<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post,pageable,2);
model.addAttribute("post", post); model.addAttribute("post", post);

View File

@ -71,7 +71,7 @@ public class CategoriesController extends BaseController {
if(!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))){ if(!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))){
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts")); size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
} }
Pageable pageable = new PageRequest(page-1,size,sort); Pageable pageable = PageRequest.of(page-1,size,sort);
Page<Post> posts = postService.findPostByCategories(category,pageable); Page<Post> posts = postService.findPostByCategories(category,pageable);
model.addAttribute("posts",posts); model.addAttribute("posts",posts);
model.addAttribute("category",category); model.addAttribute("category",category);

View File

@ -53,7 +53,7 @@ public class CommentsController {
public List<Comment> getComment(@PathVariable Long postId) { public List<Comment> getComment(@PathVariable Long postId) {
Optional<Post> post = postService.findByPostId(postId); Optional<Post> post = postService.findByPostId(postId);
Sort sort = new Sort(Sort.Direction.DESC, "commentDate"); Sort sort = new Sort(Sort.Direction.DESC, "commentDate");
Pageable pageable = new PageRequest(0, 10, sort); Pageable pageable = PageRequest.of(0, 10, sort);
List<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post.get(), pageable, 2).getContent(); List<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post.get(), pageable, 2).getContent();
if (null == comments) { if (null == comments) {
return null; return null;

View File

@ -66,7 +66,7 @@ public class IndexController extends BaseController {
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts")); size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
} }
//所有文章数据,分页 //所有文章数据,分页
Pageable pageable = new PageRequest(page - 1, size, sort); Pageable pageable = PageRequest.of(page - 1, size, sort);
Page<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable); Page<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
model.addAttribute("posts", posts); model.addAttribute("posts", posts);
return this.render("index"); return this.render("index");
@ -90,7 +90,7 @@ public class IndexController extends BaseController {
} }
//文章数据,只获取文章,没有分页 //文章数据,只获取文章,没有分页
Pageable pageable = new PageRequest(page - 1, size, sort); Pageable pageable = PageRequest.of(page - 1, size, sort);
List<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable).getContent(); List<Post> posts = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable).getContent();
return posts; return posts;
} }

View File

@ -40,7 +40,7 @@ public class OthersController {
} }
//获取文章列表并根据时间排序 //获取文章列表并根据时间排序
Sort sort = new Sort(Sort.Direction.DESC, "postDate"); Sort sort = new Sort(Sort.Direction.DESC, "postDate");
Pageable pageable = new PageRequest(0, Integer.parseInt(rssPosts), sort); Pageable pageable = PageRequest.of(0, Integer.parseInt(rssPosts), sort);
Page<Post> postsPage = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable); Page<Post> postsPage = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
List<Post> posts = postsPage.getContent(); List<Post> posts = postsPage.getContent();
return postService.buildRss(posts); return postService.buildRss(posts);
@ -56,7 +56,7 @@ public class OthersController {
public String siteMap() { public String siteMap() {
//获取文章列表并根据时间排序 //获取文章列表并根据时间排序
Sort sort = new Sort(Sort.Direction.DESC, "postDate"); Sort sort = new Sort(Sort.Direction.DESC, "postDate");
Pageable pageable = new PageRequest(0, 999, sort); Pageable pageable = PageRequest.of(0, 999, sort);
Page<Post> postsPage = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable); Page<Post> postsPage = postService.findPostByStatus(0, HaloConst.POST_TYPE_POST, pageable);
List<Post> posts = postsPage.getContent(); List<Post> posts = postsPage.getContent();
return postService.buildSiteMap(posts); return postService.buildSiteMap(posts);

View File

@ -80,7 +80,7 @@ public class PagesController extends BaseController {
Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_PAGE); Post post = postService.findByPostUrl(postUrl, HaloConst.POST_TYPE_PAGE);
Sort sort = new Sort(Sort.Direction.DESC,"commentDate"); Sort sort = new Sort(Sort.Direction.DESC,"commentDate");
Pageable pageable = new PageRequest(0,999,sort); Pageable pageable = PageRequest.of(0,999,sort);
Page<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post,pageable,2); Page<Comment> comments = commentService.findCommentsByPostAndCommentStatus(post,pageable,2);
model.addAttribute("comments",comments); model.addAttribute("comments",comments);

View File

@ -80,7 +80,7 @@ public class TagsController extends BaseController {
if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) { if (!StringUtils.isBlank(HaloConst.OPTIONS.get("index_posts"))) {
size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts")); size = Integer.parseInt(HaloConst.OPTIONS.get("index_posts"));
} }
Pageable pageable = new PageRequest(page - 1, size, sort); Pageable pageable = PageRequest.of(page - 1, size, sort);
Page<Post> posts = postService.findPostsByTags(tag, pageable); Page<Post> posts = postService.findPostsByTags(tag, pageable);
model.addAttribute("posts", posts); model.addAttribute("posts", posts);
model.addAttribute("tag", tag); model.addAttribute("tag", tag);