From 711000eb5af73170d79ed3cb8ff7afb89e4291ca Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Mon, 1 Jun 2020 11:32:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=88=91=E7=9A=84=E6=B1=82?= =?UTF-8?q?=E5=8A=A9=E6=88=91=E7=9A=84=E5=B8=AE=E5=8A=A9=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../help/controller/ActivityController.java | 7 ++-- .../com/share/help/dao/ActivityMapper.java | 5 ++- .../com/share/help/form/SeekHelpForm.java | 23 +++++++++++ .../share/help/service/ActivityService.java | 10 +++-- .../mapping/ActivityHistoryMapper.xml | 4 +- src/main/resources/mapping/ActivityMapper.xml | 38 +++++++++++++++++++ .../com/share/help/HelpApplicationTests.java | 6 ++- 7 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/share/help/form/SeekHelpForm.java diff --git a/src/main/java/com/share/help/controller/ActivityController.java b/src/main/java/com/share/help/controller/ActivityController.java index 7b5c8f5..5fcb15b 100644 --- a/src/main/java/com/share/help/controller/ActivityController.java +++ b/src/main/java/com/share/help/controller/ActivityController.java @@ -96,11 +96,12 @@ public class ActivityController { * @return 返回统计结果 */ @GetMapping(Constants.ACTIVITY_INTERFACE_SEEK_HELP) - public JSONResponse> seekHelp(@CookieValue(Constants.USER_COOKIE) String userId){ - if(userId==null){ + public JSONResponse>> seekHelp(SeekHelpForm seekHelpForm,@CookieValue(Constants.USER_COOKIE) String userId){ + if(userId==null||seekHelpForm.getCurrentPage()==null){ return new JSONResponse<>(DefaultRes.fail,Result.FAIL); }else{ - return activityService.seekHelpCount(userId); + seekHelpForm.setUserId(userId); + return activityService.seekHelpCount(seekHelpForm); } } diff --git a/src/main/java/com/share/help/dao/ActivityMapper.java b/src/main/java/com/share/help/dao/ActivityMapper.java index fd10c7e..980c4b2 100644 --- a/src/main/java/com/share/help/dao/ActivityMapper.java +++ b/src/main/java/com/share/help/dao/ActivityMapper.java @@ -63,7 +63,10 @@ public interface ActivityMapper { FindActivityRes count(@Param("pageSize") Integer pageSize,@Param("userId") String userId,@Param("title") String title); //求助信息 - List seekHelp(@Param("userId") String userId); + List seekHelp(@Param("userId") String userId,@Param("start") Integer start, @Param("count") Integer count); + + //统计分页信息 + Page> seekHelpCount(@Param("pageSize") Integer pageSize,@Param("userId") String userId); //查找管理员信息 List queryActivity(@Param("start") Integer start, @Param("count") Integer count); diff --git a/src/main/java/com/share/help/form/SeekHelpForm.java b/src/main/java/com/share/help/form/SeekHelpForm.java new file mode 100644 index 0000000..2b1aabb --- /dev/null +++ b/src/main/java/com/share/help/form/SeekHelpForm.java @@ -0,0 +1,23 @@ +package com.share.help.form; + +public class SeekHelpForm { + private String userId; + + private Integer currentPage; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } +} diff --git a/src/main/java/com/share/help/service/ActivityService.java b/src/main/java/com/share/help/service/ActivityService.java index 14c3992..ca58dbf 100644 --- a/src/main/java/com/share/help/service/ActivityService.java +++ b/src/main/java/com/share/help/service/ActivityService.java @@ -217,9 +217,12 @@ public class ActivityService{ * 求助信息统计 * @return 返回统计结果 */ - public JSONResponse> seekHelpCount(String userId){ - List seekHelpSums=activityMapper.seekHelp(userId); - return new JSONResponse>(DefaultRes.ok,Result.OK).setBody(seekHelpSums); + public JSONResponse>> seekHelpCount(SeekHelpForm seekHelpForm){ + Page> page=activityMapper.seekHelpCount(helpPageSize,seekHelpForm.getUserId()); + List seekHelpSums=activityMapper.seekHelp(seekHelpForm.getUserId(),(seekHelpForm.getCurrentPage()-1)*helpPageSize,helpPageSize); + page.setBody(seekHelpSums); + page.setCurrentPage(seekHelpForm.getCurrentPage()); + return new JSONResponse>>(DefaultRes.ok,Result.OK).setBody(page); } /** @@ -240,6 +243,7 @@ public class ActivityService{ */ public JSONResponse>> queryHelp(QueryHelpForm queryHelpForm){ Page> page=activityHistoryMapper.count(queryHelpForm.getUserId(),helpPageSize); + page.setCurrentPage(queryHelpForm.getCurrentPage()); List helpRes=activityHistoryMapper.queryMyHelp((queryHelpForm.getCurrentPage()-1)*helpPageSize,helpPageSize,queryHelpForm.getUserId()); page.setBody(helpRes); return new JSONResponse>>(DefaultRes.ok,Result.OK).setBody(page); diff --git a/src/main/resources/mapping/ActivityHistoryMapper.xml b/src/main/resources/mapping/ActivityHistoryMapper.xml index b66c464..14e7c9c 100644 --- a/src/main/resources/mapping/ActivityHistoryMapper.xml +++ b/src/main/resources/mapping/ActivityHistoryMapper.xml @@ -39,7 +39,9 @@ diff --git a/src/main/resources/mapping/ActivityMapper.xml b/src/main/resources/mapping/ActivityMapper.xml index b38f6e8..e2be0ad 100644 --- a/src/main/resources/mapping/ActivityMapper.xml +++ b/src/main/resources/mapping/ActivityMapper.xml @@ -96,6 +96,43 @@ + + diff --git a/src/test/java/com/share/help/HelpApplicationTests.java b/src/test/java/com/share/help/HelpApplicationTests.java index f84f7c7..61a1084 100644 --- a/src/test/java/com/share/help/HelpApplicationTests.java +++ b/src/test/java/com/share/help/HelpApplicationTests.java @@ -181,8 +181,10 @@ class HelpApplicationTests { // 求助信息统计 @Test public void testSeekHelpCount(){ - List seekHelpSums=activityMapper.seekHelp("123"); - Assertions.assertFalse(seekHelpSums.isEmpty()); + Page> page=activityMapper.seekHelpCount(3,"123"); + Assertions.assertEquals(10, (long) page.getCount()); + List seekHelpSums=activityMapper.seekHelp("123",0,3); + Assertions.assertEquals(seekHelpSums.size(),3); }