Commit 9973512e authored by Maxym Borodenko's avatar Maxym Borodenko

Sitemap update

parent 0ff8fee4
......@@ -116,8 +116,8 @@ public class CMSController {
* @return the page
*/
@RequestMapping(value = "/all-news", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public Page<ActivityPost> getAllNews(@RequestParam(name = "p", required = false, defaultValue = "1") final int page) {
return contentService.allNews(page);
public Page<ActivityPost> getAllNews(final Pagination page) {
return contentService.allNews(page.toPageRequest(50, Sort.Direction.DESC, "postDate"));
}
/**
......
/**
* Copyright 2015 Global Crop Diversity Trust
/*
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
*/
package org.genesys2.server.mvc;
......@@ -27,6 +27,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
......@@ -51,8 +53,7 @@ public class NewsController extends BaseController {
@GetMapping(value = "/content/news")
public String getAllNews(ModelMap model, @RequestParam(value = "page", defaultValue = "1") int page) {
Page<ActivityPost> allNews = contentService.allNews(page);
Page<ActivityPost> allNews = contentService.allNews(new PageRequest(page - 1, 50, Sort.Direction.DESC, "postDate"));
model.addAttribute("pagedData", allNews);
......
......@@ -72,7 +72,7 @@ public interface ContentService {
List<ActivityPost> lastNews();
Page<ActivityPost> allNews(int page);
Page<ActivityPost> allNews(Pageable page);
ClassPK ensureClassPK(Class<?> clazz);
......
......@@ -102,9 +102,8 @@ public class ContentServiceImpl implements ContentService {
@Override
@Cacheable(value = "contentcache")
public Page<ActivityPost> allNews(int page) {
final PageRequest pageRequest = new PageRequest(page - 1, 50, Direction.DESC, "postDate");
return postRepository.findAll(pageRequest);
public Page<ActivityPost> allNews(Pageable page) {
return postRepository.findAll(page);
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment