From 15e82e3ded86fc922d31c90e1bb989a8657b98b3 Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 22 Jul 2022 21:52:31 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BF=AE=E6=94=B9=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=BB=9F=E4=B8=80=E8=BF=94=E5=9B=9E=20PageIn?= =?UTF-8?q?fo=20=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lucene/api/LuceneSearchController.java | 6 +- .../forest/web/api/admin/AdminController.java | 76 +++++++------------ .../admin/AdminCurrencyRuleController.java | 8 +- .../web/api/admin/DashboardController.java | 27 ++----- .../web/api/bank/BankAccountController.java | 21 ++--- .../forest/web/api/bank/BankController.java | 8 +- .../forest/web/api/bank/WalletController.java | 10 +-- .../web/api/common/CommonApiController.java | 31 +++----- .../notification/NotificationController.java | 10 +-- .../forest/web/api/tag/TagController.java | 5 +- .../forest/web/api/topic/TopicController.java | 5 +- .../forest/web/api/user/UserController.java | 31 +++----- 12 files changed, 75 insertions(+), 163 deletions(-) diff --git a/src/main/java/com/rymcu/forest/lucene/api/LuceneSearchController.java b/src/main/java/com/rymcu/forest/lucene/api/LuceneSearchController.java index 80350c1..9717152 100755 --- a/src/main/java/com/rymcu/forest/lucene/api/LuceneSearchController.java +++ b/src/main/java/com/rymcu/forest/lucene/api/LuceneSearchController.java @@ -114,7 +114,7 @@ public class LuceneSearchController { } articles.addAll(articleDTOList); PageInfo 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 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 pageInfo = new PageInfo<>(portfolios); - return GlobalResultGenerator.genSuccessResult(Utils.getPortfolioGlobalResult(pageInfo)); + return GlobalResultGenerator.genSuccessResult(pageInfo); } } diff --git a/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java b/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java index a8ec9f4..05875d5 100644 --- a/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java +++ b/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java @@ -40,17 +40,15 @@ public class AdminController { private ArticleService articleService; @Resource private CommentService commentService; + @Resource + private ProductService productService; @GetMapping("/users") - public GlobalResult> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){ + public GlobalResult> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){ PageHelper.startPage(page, rows); List list = userService.findUsers(searchDTO); PageInfo pageInfo = new PageInfo<>(list); - Map map = new HashMap(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> roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){ + public GlobalResult> roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){ PageHelper.startPage(page, rows); List list = roleService.findAll(); PageInfo pageInfo = new PageInfo<>(list); - Map map = new HashMap(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> topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){ + public GlobalResult> topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){ PageHelper.startPage(page, rows); List list = topicService.findAll(); PageInfo pageInfo = new PageInfo<>(list); - Map 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> 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 list = topicService.findUnbindTagsById(idTopic, tagTitle); PageInfo pageInfo = new PageInfo<>(list); - Map 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> tags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){ + public GlobalResult> tags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){ PageHelper.startPage(page, rows); List list = tagService.findAll(); PageInfo pageInfo = new PageInfo<>(list); - Map 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> cleanUnusedTag(){ + public GlobalResult cleanUnusedTag(){ Map map = tagService.cleanUnusedTag(); return GlobalResultGenerator.genSuccessResult(map); } @@ -212,39 +194,35 @@ public class AdminController { } @GetMapping("/special-days") - public GlobalResult specialDays(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { + public GlobalResult> specialDays(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { PageHelper.startPage(page, rows); List list = specialDayService.findAll(); PageInfo pageInfo = new PageInfo<>(list); - Map 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 articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO articleSearchDTO) { + public GlobalResult> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO articleSearchDTO) { PageHelper.startPage(page, rows); List list = articleService.findArticles(articleSearchDTO); PageInfo pageInfo = new PageInfo<>(list); - Map 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 comments(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { + public GlobalResult> comments(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { PageHelper.startPage(page, rows); List list = commentService.findComments(); PageInfo pageInfo = new PageInfo<>(list); - Map 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> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { + PageHelper.startPage(page, rows); + List list = productService.findProducts(); + PageInfo pageInfo = new PageInfo<>(list); + return GlobalResultGenerator.genSuccessResult(pageInfo); } diff --git a/src/main/java/com/rymcu/forest/web/api/admin/AdminCurrencyRuleController.java b/src/main/java/com/rymcu/forest/web/api/admin/AdminCurrencyRuleController.java index 8c1ce41..39cf31a 100644 --- a/src/main/java/com/rymcu/forest/web/api/admin/AdminCurrencyRuleController.java +++ b/src/main/java/com/rymcu/forest/web/api/admin/AdminCurrencyRuleController.java @@ -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> list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) { PageHelper.startPage(page, rows); List list = currencyRuleService.findAll(); - Map map = new HashMap(2); PageInfo 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); } } diff --git a/src/main/java/com/rymcu/forest/web/api/admin/DashboardController.java b/src/main/java/com/rymcu/forest/web/api/admin/DashboardController.java index 6d34e5c..6b17356 100644 --- a/src/main/java/com/rymcu/forest/web/api/admin/DashboardController.java +++ b/src/main/java/com/rymcu/forest/web/api/admin/DashboardController.java @@ -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> newUsers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { PageHelper.startPage(page, rows); List list = dashboardService.newUsers(); PageInfo pageInfo = new PageInfo<>(list); - Map map = new HashMap(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> newBankAccounts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { PageHelper.startPage(page, rows); List list = dashboardService.newBankAccounts(); PageInfo 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> newArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { PageHelper.startPage(page, rows); List list = dashboardService.newArticles(); PageInfo pageInfo = new PageInfo<>(list); - Map 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); } } diff --git a/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java b/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java index 37f1d87..2e1db18 100644 --- a/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java +++ b/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java @@ -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> banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, BankAccountSearchDTO bankAccountSearchDTO) { PageHelper.startPage(page, rows); List list = bankAccountService.findBankAccounts(bankAccountSearchDTO); PageInfo 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 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> 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 list = bankAccountService.findUserTransactionRecords(bankAccount, startDate, endDate); PageInfo 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); } } diff --git a/src/main/java/com/rymcu/forest/web/api/bank/BankController.java b/src/main/java/com/rymcu/forest/web/api/bank/BankController.java index f155982..e157a08 100644 --- a/src/main/java/com/rymcu/forest/web/api/bank/BankController.java +++ b/src/main/java/com/rymcu/forest/web/api/bank/BankController.java @@ -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> banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { PageHelper.startPage(page, rows); List list = bankService.findBanks(); PageInfo 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); } } diff --git a/src/main/java/com/rymcu/forest/web/api/bank/WalletController.java b/src/main/java/com/rymcu/forest/web/api/bank/WalletController.java index 9714ee6..e9ea1ac 100644 --- a/src/main/java/com/rymcu/forest/web/api/bank/WalletController.java +++ b/src/main/java/com/rymcu/forest/web/api/bank/WalletController.java @@ -33,14 +33,14 @@ public class WalletController { @GetMapping("/{idUser}") @SecurityInterceptor - public GlobalResult detail(@PathVariable Long idUser) { + public GlobalResult 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> 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 list = bankAccountService.findUserTransactionRecords(bankAccount.getBankAccount(), startDate, endDate); PageInfo 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); } } diff --git a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java index 0ad2e31..5f1ed82 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java @@ -87,21 +87,19 @@ public class CommonApiController { @GetMapping("/articles") @VisitLogger - public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO) { + public GlobalResult> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO) { PageHelper.startPage(page, rows); List list = articleService.findArticles(searchDTO); PageInfo pageInfo = new PageInfo(list); - Map map = Utils.getArticlesGlobalResult(pageInfo); - return GlobalResultGenerator.genSuccessResult(map); + return GlobalResultGenerator.genSuccessResult(pageInfo); } @GetMapping("/announcements") - public GlobalResult announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows) { + public GlobalResult> announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows) { PageHelper.startPage(page, rows); List list = articleService.findAnnouncements(); PageInfo 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> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Long id) { PageHelper.startPage(page, rows); List list = articleService.findArticlesByIdPortfolio(id); PageInfo 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> portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) { PageHelper.startPage(page, rows); List list = portfolioService.findPortfolios(); PageInfo 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> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) { PageHelper.startPage(page, rows); List list = productService.findProducts(); PageInfo 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}") diff --git a/src/main/java/com/rymcu/forest/web/api/notification/NotificationController.java b/src/main/java/com/rymcu/forest/web/api/notification/NotificationController.java index 4150e3f..4508ecc 100644 --- a/src/main/java/com/rymcu/forest/web/api/notification/NotificationController.java +++ b/src/main/java/com/rymcu/forest/web/api/notification/NotificationController.java @@ -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> 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 list = notificationService.findNotifications(user.getIdUser()); PageInfo 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> 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 list = notificationService.findUnreadNotifications(user.getIdUser()); PageInfo pageInfo = new PageInfo(list); - Map map = Utils.getNotificationsGlobalResult(pageInfo); - return GlobalResultGenerator.genSuccessResult(map); + return GlobalResultGenerator.genSuccessResult(pageInfo); } @PutMapping("/read/{id}") diff --git a/src/main/java/com/rymcu/forest/web/api/tag/TagController.java b/src/main/java/com/rymcu/forest/web/api/tag/TagController.java index dda3353..9b4556a 100644 --- a/src/main/java/com/rymcu/forest/web/api/tag/TagController.java +++ b/src/main/java/com/rymcu/forest/web/api/tag/TagController.java @@ -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> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){ PageHelper.startPage(page, rows); List list = articleService.findArticlesByTagName(name); PageInfo pageInfo = new PageInfo(list); - Map map = Utils.getArticlesGlobalResult(pageInfo); - return GlobalResultGenerator.genSuccessResult(map); + return GlobalResultGenerator.genSuccessResult(pageInfo); } @GetMapping("/tags") diff --git a/src/main/java/com/rymcu/forest/web/api/topic/TopicController.java b/src/main/java/com/rymcu/forest/web/api/topic/TopicController.java index 56d55f0..d90d1f9 100644 --- a/src/main/java/com/rymcu/forest/web/api/topic/TopicController.java +++ b/src/main/java/com/rymcu/forest/web/api/topic/TopicController.java @@ -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> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){ PageHelper.startPage(page, rows); List list = articleService.findArticlesByTopicUri(name); PageInfo pageInfo = new PageInfo(list); - Map map = Utils.getArticlesGlobalResult(pageInfo); - return GlobalResultGenerator.genSuccessResult(map); + return GlobalResultGenerator.genSuccessResult(pageInfo); } } diff --git a/src/main/java/com/rymcu/forest/web/api/user/UserController.java b/src/main/java/com/rymcu/forest/web/api/user/UserController.java index 9976387..7e7d06f 100644 --- a/src/main/java/com/rymcu/forest/web/api/user/UserController.java +++ b/src/main/java/com/rymcu/forest/web/api/user/UserController.java @@ -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> 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 list = articleService.findUserArticlesByIdUser(userDTO.getIdUser()); PageInfo 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> 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 list = portfolioService.findUserPortfoliosByUser(userDTO); PageInfo 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> 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 list = followService.findUserFollowersByUser(userDTO); PageInfo 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> 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 list = followService.findUserFollowingsByUser(userDTO); PageInfo 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(@PathVariable String account) { UserExtend userExtend = userService.selectUserExtendByAccount(account); return GlobalResultGenerator.genSuccessResult(userExtend); }