提交 92d5c109 authored 作者: Whispa's avatar Whispa

commit commit

上级 f0a2c2f6
...@@ -3,6 +3,7 @@ package com.example.afrishop_v3.controllers; ...@@ -3,6 +3,7 @@ package com.example.afrishop_v3.controllers;
import com.example.afrishop_v3.models.Hashtag; import com.example.afrishop_v3.models.Hashtag;
import com.example.afrishop_v3.repository.HashtagRepository; import com.example.afrishop_v3.repository.HashtagRepository;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -18,13 +19,13 @@ public class HashtagController { ...@@ -18,13 +19,13 @@ public class HashtagController {
@GetMapping(value = "/home/listHashtags") @GetMapping(value = "/home/listHashtags")
//@PreAuthorize("hasAuthority('ADMIN_USER') or hasAuthority('STANDARD_USER')") //@PreAuthorize("hasAuthority('ADMIN_USER') or hasAuthority('STANDARD_USER')")
public List<Hashtag> getList(@RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) { public List<Hashtag> getList(@RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) {
return repository.findAll(PageRequest.of(pageNo, pageSize)).toList(); return repository.findAll(PageRequest.of(pageNo, pageSize, Sort.by(Sort.Order.desc("count")))).toList();
} }
@GetMapping(value = "/searchHashtags/{query}") @GetMapping(value = "/searchHashtags/{query}")
//@PreAuthorize("hasAuthority('ADMIN_USER') or hasAuthority('STANDARD_USER')") //@PreAuthorize("hasAuthority('ADMIN_USER') or hasAuthority('STANDARD_USER')")
public List<Hashtag> getSearch(@PathVariable(value = "query") String query, @RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) { public List<Hashtag> getSearch(@PathVariable(value = "query") String query, @RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) {
return repository.findAllByNameContaining(query, PageRequest.of(pageNo, pageSize)).toList(); return repository.findAllByNameContaining(query, PageRequest.of(pageNo, pageSize,Sort.by(Sort.Order.desc("count")))).toList();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论