|
@@ -37,11 +37,13 @@ public class NewsServiceImpl implements NewsService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<News> findBycreated(int pagenumber , int pagesize) {
|
|
|
+ public List<News> findBycreated(int pagenumber , int pagesize , String taxonomySlug) {
|
|
|
+ List<Long> idByTaxonomySlug = newsRepository.findNewsIdByTaxonomySlug(taxonomySlug);
|
|
|
Pageable pageable = new PageRequest(pagenumber-1 ,pagesize, new Sort(Sort.Direction.DESC, "modified"));
|
|
|
Page<News> page = newsRepository.findAll((root, query, builder) -> {
|
|
|
- Predicate predicate = builder.equal(root.get("module"), "news");
|
|
|
- query.where(predicate);
|
|
|
+ Predicate predicateId = root.get("id").in(idByTaxonomySlug);
|
|
|
+ Predicate predicateModule = builder.equal(root.get("module"), "news");
|
|
|
+ query.where(predicateId,predicateModule);
|
|
|
return null;
|
|
|
}, pageable);
|
|
|
if (page != null && !CollectionUtils.isEmpty(page.getContent())) {
|
|
@@ -52,11 +54,13 @@ public class NewsServiceImpl implements NewsService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public List<News> findByViewCount(int pagenumber , int pagesize) {
|
|
|
+ public List<News> findByViewCount(int pagenumber , int pagesize , String taxonomySlug) {
|
|
|
+ List<Long> idByTaxonomySlug = newsRepository.findNewsIdByTaxonomySlug(taxonomySlug);
|
|
|
Pageable pageable = new PageRequest(pagenumber-1 ,pagesize, new Sort(Sort.Direction.DESC, "viewCount"));
|
|
|
Page<News> page = newsRepository.findAll((root, query, builder) -> {
|
|
|
- Predicate predicate = builder.equal(root.get("module"), "news");
|
|
|
- query.where(predicate);
|
|
|
+ Predicate predicateId = root.get("id").in(idByTaxonomySlug);
|
|
|
+ Predicate predicateModule = builder.equal(root.get("module"), "news");
|
|
|
+ query.where(predicateId,predicateModule);
|
|
|
return null;
|
|
|
}, pageable);
|
|
|
if (page != null && !CollectionUtils.isEmpty(page.getContent())) {
|