🎨 修改列表接口统一返回 PageInfo 对象
This commit is contained in:
parent
64421a2bfa
commit
15e82e3ded
@ -114,7 +114,7 @@ public class LuceneSearchController {
|
||||
}
|
||||
articles.addAll(articleDTOList);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(articles);
|
||||
return GlobalResultGenerator.genSuccessResult(Utils.getArticlesGlobalResult(pageInfo));
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,7 +156,7 @@ public class LuceneSearchController {
|
||||
}
|
||||
users.addAll(userDTOList);
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo<>(users);
|
||||
return GlobalResultGenerator.genSuccessResult(Utils.getUserGlobalResult(pageInfo));
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,6 +198,6 @@ public class LuceneSearchController {
|
||||
}
|
||||
portfolios.addAll(portfolioDTOList);
|
||||
PageInfo<PortfolioDTO> pageInfo = new PageInfo<>(portfolios);
|
||||
return GlobalResultGenerator.genSuccessResult(Utils.getPortfolioGlobalResult(pageInfo));
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
}
|
||||
|
@ -40,17 +40,15 @@ public class AdminController {
|
||||
private ArticleService articleService;
|
||||
@Resource
|
||||
private CommentService commentService;
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@GetMapping("/users")
|
||||
public GlobalResult<Map<String, Object>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){
|
||||
public GlobalResult<PageInfo<UserInfoDTO>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){
|
||||
PageHelper.startPage(page, rows);
|
||||
List<UserInfoDTO> list = userService.findUsers(searchDTO);
|
||||
PageInfo<UserInfoDTO> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<String, Object>(2);
|
||||
map.put("users", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/user/{idUser}/role")
|
||||
@ -60,15 +58,11 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@GetMapping("/roles")
|
||||
public GlobalResult<Map<String, Object>> roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||
public GlobalResult<PageInfo<Role>> roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Role> list = roleService.findAll();
|
||||
PageInfo<Role> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<String, Object>(2);
|
||||
map.put("roles", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@PatchMapping("/user/update-role")
|
||||
@ -102,15 +96,11 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@GetMapping("/topics")
|
||||
public GlobalResult<Map<String, Object>> topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||
public GlobalResult<PageInfo<Topic>> topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Topic> list = topicService.findAll();
|
||||
PageInfo<Topic> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("topics", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/topic/{topicUri}")
|
||||
@ -138,17 +128,13 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@GetMapping("/topic/unbind-topic-tags")
|
||||
public GlobalResult unbindTopicTags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, HttpServletRequest request){
|
||||
public GlobalResult<PageInfo<Tag>> unbindTopicTags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, HttpServletRequest request){
|
||||
Integer idTopic = Integer.valueOf(request.getParameter("idTopic"));
|
||||
String tagTitle = request.getParameter("tagTitle");
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Tag> list = topicService.findUnbindTagsById(idTopic, tagTitle);
|
||||
PageInfo<Tag> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("tags", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@PostMapping("/topic/bind-topic-tag")
|
||||
@ -176,19 +162,15 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@GetMapping("/tags")
|
||||
public GlobalResult<Map<String, Object>> tags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||
public GlobalResult<PageInfo<Tag>> tags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Tag> list = tagService.findAll();
|
||||
PageInfo<Tag> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("tags", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@DeleteMapping("/tag/clean-unused")
|
||||
public GlobalResult<Map<String, Object>> cleanUnusedTag(){
|
||||
public GlobalResult cleanUnusedTag(){
|
||||
Map map = tagService.cleanUnusedTag();
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
@ -212,39 +194,35 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@GetMapping("/special-days")
|
||||
public GlobalResult<Map> specialDays(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
public GlobalResult<PageInfo<SpecialDay>> specialDays(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<SpecialDay> list = specialDayService.findAll();
|
||||
PageInfo<SpecialDay> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("specialDays", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/articles")
|
||||
public GlobalResult<Map> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO articleSearchDTO) {
|
||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO articleSearchDTO) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findArticles(articleSearchDTO);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("articles", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/comments")
|
||||
public GlobalResult<Map> comments(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
public GlobalResult<PageInfo<CommentDTO>> comments(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<CommentDTO> list = commentService.findComments();
|
||||
PageInfo<CommentDTO> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("comments", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/products")
|
||||
public GlobalResult<PageInfo<ProductDTO>> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ProductDTO> list = productService.findProducts();
|
||||
PageInfo<ProductDTO> pageInfo = new PageInfo<>(list);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,15 +32,11 @@ public class AdminCurrencyRuleController {
|
||||
private CurrencyRuleService currencyRuleService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public GlobalResult list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) {
|
||||
public GlobalResult<PageInfo<TransactionRecordDTO>> list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<CurrencyRule> list = currencyRuleService.findAll();
|
||||
Map map = new HashMap(2);
|
||||
PageInfo<TransactionRecordDTO> pageInfo = new PageInfo(list);
|
||||
map.put("rules", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,41 +49,26 @@ public class DashboardController {
|
||||
}
|
||||
|
||||
@GetMapping("/new-users")
|
||||
public GlobalResult newUsers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
public GlobalResult<PageInfo<UserInfoDTO>> newUsers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<UserInfoDTO> list = dashboardService.newUsers();
|
||||
PageInfo<UserInfoDTO> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<String, Object>(2);
|
||||
map.put("users", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/new-bank-accounts")
|
||||
public GlobalResult newBankAccounts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
public GlobalResult<PageInfo<BankAccountDTO>> newBankAccounts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<BankAccountDTO> list = dashboardService.newBankAccounts();
|
||||
PageInfo<BankAccountDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("bankAccounts", pageInfo.getList());
|
||||
Map pagination = new HashMap(4);
|
||||
pagination.put("pageSize", pageInfo.getPageSize());
|
||||
pagination.put("total", pageInfo.getTotal());
|
||||
pagination.put("currentPage", pageInfo.getPageNum());
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/new-articles")
|
||||
public GlobalResult newArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
public GlobalResult<PageInfo<ArticleDTO>> newArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = dashboardService.newArticles();
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("articles", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
}
|
||||
|
@ -28,39 +28,28 @@ public class BankAccountController {
|
||||
private BankAccountService bankAccountService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public GlobalResult banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, BankAccountSearchDTO bankAccountSearchDTO) {
|
||||
public GlobalResult<PageInfo<BankAccountDTO>> banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, BankAccountSearchDTO bankAccountSearchDTO) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<BankAccountDTO> list = bankAccountService.findBankAccounts(bankAccountSearchDTO);
|
||||
PageInfo<BankAccountDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("bankAccounts", pageInfo.getList());
|
||||
Map pagination = new HashMap(4);
|
||||
pagination.put("pageSize", pageInfo.getPageSize());
|
||||
pagination.put("total", pageInfo.getTotal());
|
||||
pagination.put("currentPage", pageInfo.getPageNum());
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/{idUser}")
|
||||
public GlobalResult detail(@PathVariable Long idUser) {
|
||||
public GlobalResult<BankAccountDTO> detail(@PathVariable Long idUser) {
|
||||
BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(idUser);
|
||||
return GlobalResultGenerator.genSuccessResult(bankAccount);
|
||||
}
|
||||
|
||||
@GetMapping("/transaction-records")
|
||||
public GlobalResult transactionRecords(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) {
|
||||
public GlobalResult<PageInfo<TransactionRecordDTO>> transactionRecords(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) {
|
||||
String bankAccount = request.getParameter("bankAccount");
|
||||
String startDate = request.getParameter("startDate");
|
||||
String endDate = request.getParameter("endDate");
|
||||
PageHelper.startPage(page, rows);
|
||||
List<TransactionRecordDTO> list = bankAccountService.findUserTransactionRecords(bankAccount, startDate, endDate);
|
||||
PageInfo<TransactionRecordDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("records", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,15 +30,11 @@ public class BankController {
|
||||
private BankService bankService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public GlobalResult banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
public GlobalResult<PageInfo<BankDTO>> banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<BankDTO> list = bankService.findBanks();
|
||||
PageInfo<BankDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("banks", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,14 +33,14 @@ public class WalletController {
|
||||
|
||||
@GetMapping("/{idUser}")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult detail(@PathVariable Long idUser) {
|
||||
public GlobalResult<BankAccountDTO> detail(@PathVariable Long idUser) {
|
||||
BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(idUser);
|
||||
return GlobalResultGenerator.genSuccessResult(bankAccount);
|
||||
}
|
||||
|
||||
@GetMapping("/transaction-records")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult transactionRecords(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) {
|
||||
public GlobalResult<PageInfo<TransactionRecordDTO>> transactionRecords(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) {
|
||||
String idUser = request.getParameter("idUser");
|
||||
String startDate = request.getParameter("startDate");
|
||||
String endDate = request.getParameter("endDate");
|
||||
@ -48,10 +48,6 @@ public class WalletController {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<TransactionRecordDTO> list = bankAccountService.findUserTransactionRecords(bankAccount.getBankAccount(), startDate, endDate);
|
||||
PageInfo<TransactionRecordDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("records", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
}
|
||||
|
@ -87,21 +87,19 @@ public class CommonApiController {
|
||||
|
||||
@GetMapping("/articles")
|
||||
@VisitLogger
|
||||
public GlobalResult<Map> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO) {
|
||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findArticles(searchDTO);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/announcements")
|
||||
public GlobalResult<Map> announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows) {
|
||||
public GlobalResult<PageInfo<ArticleDTO>> announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findAnnouncements();
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/article/{id}")
|
||||
@ -127,36 +125,27 @@ public class CommonApiController {
|
||||
}
|
||||
|
||||
@GetMapping("/portfolio/{id}/articles")
|
||||
public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Long id) {
|
||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Long id) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findArticlesByIdPortfolio(id);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/portfolios")
|
||||
public GlobalResult portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||
public GlobalResult<PageInfo<PortfolioDTO>> portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<PortfolioDTO> list = portfolioService.findPortfolios();
|
||||
PageInfo<PortfolioDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("portfolios", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/products")
|
||||
public GlobalResult products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||
public GlobalResult<PageInfo<ProductDTO>> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ProductDTO> list = productService.findProducts();
|
||||
PageInfo<ProductDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("products", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/product/{id}")
|
||||
|
@ -31,7 +31,7 @@ public class NotificationController {
|
||||
private NotificationService notificationService;
|
||||
|
||||
@GetMapping("/all")
|
||||
public GlobalResult notifications(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException {
|
||||
public GlobalResult<PageInfo<NotificationDTO>> notifications(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException {
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
if (Objects.isNull(user)) {
|
||||
throw new BaseApiException(ErrorCode.TOKEN_);
|
||||
@ -39,12 +39,11 @@ public class NotificationController {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<NotificationDTO> list = notificationService.findNotifications(user.getIdUser());
|
||||
PageInfo<NotificationDTO> pageInfo = new PageInfo(list);
|
||||
Map map = Utils.getNotificationDTOsGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/unread")
|
||||
public GlobalResult unreadNotification(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException {
|
||||
public GlobalResult<PageInfo<Notification>> unreadNotification(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException {
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
if (Objects.isNull(user)) {
|
||||
throw new BaseApiException(ErrorCode.TOKEN_);
|
||||
@ -52,8 +51,7 @@ public class NotificationController {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Notification> list = notificationService.findUnreadNotifications(user.getIdUser());
|
||||
PageInfo<Notification> pageInfo = new PageInfo(list);
|
||||
Map map = Utils.getNotificationsGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@PutMapping("/read/{id}")
|
||||
|
@ -28,12 +28,11 @@ public class TagController {
|
||||
private TagService tagService;
|
||||
|
||||
@GetMapping("/{name}")
|
||||
public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){
|
||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findArticlesByTagName(name);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/tags")
|
||||
|
@ -35,11 +35,10 @@ public class TopicController {
|
||||
|
||||
@GetMapping("/{name}")
|
||||
@VisitLogger
|
||||
public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){
|
||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findArticlesByTopicUri(name);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/{account}/articles")
|
||||
public GlobalResult userArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
|
||||
public GlobalResult<PageInfo<ArticleDTO>> userArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
|
||||
UserDTO userDTO = userService.findUserDTOByAccount(account);
|
||||
if (userDTO == null){
|
||||
return GlobalResultGenerator.genErrorResult("用户不存在!");
|
||||
@ -53,12 +53,11 @@ public class UserController {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findUserArticlesByIdUser(userDTO.getIdUser());
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/{account}/portfolios")
|
||||
public GlobalResult userPortfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
|
||||
public GlobalResult<PageInfo<PortfolioDTO>> userPortfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
|
||||
UserDTO userDTO = userService.findUserDTOByAccount(account);
|
||||
if (userDTO == null){
|
||||
return GlobalResultGenerator.genErrorResult("用户不存在!");
|
||||
@ -66,15 +65,11 @@ public class UserController {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<PortfolioDTO> list = portfolioService.findUserPortfoliosByUser(userDTO);
|
||||
PageInfo<PortfolioDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("portfolios", list);
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/{account}/followers")
|
||||
public GlobalResult userFollowers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
|
||||
public GlobalResult<PageInfo<UserDTO>> userFollowers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
|
||||
UserDTO userDTO = userService.findUserDTOByAccount(account);
|
||||
if (userDTO == null){
|
||||
return GlobalResultGenerator.genErrorResult("用户不存在!");
|
||||
@ -82,15 +77,11 @@ public class UserController {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<UserDTO> list = followService.findUserFollowersByUser(userDTO);
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("users", list);
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/{account}/followings")
|
||||
public GlobalResult userFollowings(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
|
||||
public GlobalResult<PageInfo<UserDTO>> userFollowings(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
|
||||
UserDTO userDTO = userService.findUserDTOByAccount(account);
|
||||
if (userDTO == null){
|
||||
return GlobalResultGenerator.genErrorResult("用户不存在!");
|
||||
@ -98,15 +89,11 @@ public class UserController {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<UserDTO> list = followService.findUserFollowingsByUser(userDTO);
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("users", list);
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/{account}/user-extend")
|
||||
public GlobalResult userExtend(@PathVariable String account) {
|
||||
public GlobalResult<UserExtend> userExtend(@PathVariable String account) {
|
||||
UserExtend userExtend = userService.selectUserExtendByAccount(account);
|
||||
return GlobalResultGenerator.genSuccessResult(userExtend);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user