From 68067dfc15fd6f7f8de2a1b89b827c0fd37c7aec Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Tue, 2 Jun 2020 22:27:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8F=82=E5=8A=A0=E6=B4=BB=E5=8A=A8=E5=A5=96=E5=8A=B1?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=B8=81=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/share/help/Constants.java | 4 +-- .../help/controller/ManagerController.java | 9 +++++++ .../share/help/dao/ActivityHistoryMapper.java | 5 ++++ .../com/share/help/dao/ActivityMapper.java | 1 + .../com/share/help/form/QueryScoreForm.java | 26 +++++++++++++++++++ .../java/com/share/help/res/TimeScore.java | 25 ++++++++++++++++++ .../share/help/service/ManagerService.java | 14 ++++++++++ .../mapping/ActivityHistoryMapper.xml | 11 +++++++- .../com/share/help/HelpApplicationTests.java | 9 +++++++ 9 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/share/help/form/QueryScoreForm.java create mode 100644 src/main/java/com/share/help/res/TimeScore.java diff --git a/src/main/java/com/share/help/Constants.java b/src/main/java/com/share/help/Constants.java index 915220a..e562760 100644 --- a/src/main/java/com/share/help/Constants.java +++ b/src/main/java/com/share/help/Constants.java @@ -86,8 +86,8 @@ public class Constants { public static final String MANAGER_INTERFACE_UPDATE_USER = "/userUpdate"; //查找活动列表 public static final String MANAGER_INTERFACE_FIND_ACTIVITY ="/find/activity" ; - //删除活动接口 - public static final String MANAGER_INTERFACE_DELTE_ACTIVITY = "/delete/{activityId}"; //更新活动接口 public static final String MANAGER_INTERFACE_UPDATE_ACTIVITY = "/update/{activityId}"; + //查询时间币 + public static final String MANAGER_INTERFACE_SCORE = "/score"; } diff --git a/src/main/java/com/share/help/controller/ManagerController.java b/src/main/java/com/share/help/controller/ManagerController.java index 58e8ac6..d6a9ee3 100644 --- a/src/main/java/com/share/help/controller/ManagerController.java +++ b/src/main/java/com/share/help/controller/ManagerController.java @@ -152,4 +152,13 @@ public class ManagerController { return new JSONResponse<>(DefaultRes.fail,Result.FAIL); } } + + @GetMapping(Constants.MANAGER_INTERFACE_SCORE) + public JSONResponse queryTimeScore(QueryScoreForm queryScoreForm){ + if(queryScoreForm.getActivityId()!=null&&StringUtils.isNotEmpty(queryScoreForm.getUserId())){ + return managerService.queryTimeScore(queryScoreForm); + }else{ + return new JSONResponse<>(DefaultRes.fail,Result.FAIL); + } + } } diff --git a/src/main/java/com/share/help/dao/ActivityHistoryMapper.java b/src/main/java/com/share/help/dao/ActivityHistoryMapper.java index e12f432..fdcd162 100644 --- a/src/main/java/com/share/help/dao/ActivityHistoryMapper.java +++ b/src/main/java/com/share/help/dao/ActivityHistoryMapper.java @@ -4,6 +4,7 @@ import com.share.help.entity.ActivityHistoryEntity; import com.share.help.entity.custorm.HelpRes; import com.share.help.entity.custorm.UserWithName; import com.share.help.res.Page; +import com.share.help.res.TimeScore; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Update; @@ -43,4 +44,8 @@ public interface ActivityHistoryMapper { //获取时间币 Integer getTimeScore(@Param("activityId") Long activityId,@Param("userId") String userId); + + + //测试时间币 + TimeScore queryActivityHistory(@Param("userId") String userId, @Param("activityId") Long activityId); } diff --git a/src/main/java/com/share/help/dao/ActivityMapper.java b/src/main/java/com/share/help/dao/ActivityMapper.java index 8c2e282..38bc8ff 100644 --- a/src/main/java/com/share/help/dao/ActivityMapper.java +++ b/src/main/java/com/share/help/dao/ActivityMapper.java @@ -79,4 +79,5 @@ public interface ActivityMapper { //查询活跃用户 List queryActiveUser(@Param("userId") String userId,@Param("serviceAddress") String serviceAddress); + } diff --git a/src/main/java/com/share/help/form/QueryScoreForm.java b/src/main/java/com/share/help/form/QueryScoreForm.java new file mode 100644 index 0000000..3d1b240 --- /dev/null +++ b/src/main/java/com/share/help/form/QueryScoreForm.java @@ -0,0 +1,26 @@ +package com.share.help.form; + +/** + * 查询分数 + */ +public class QueryScoreForm { + private String userId; + + private Long activityId; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Long getActivityId() { + return activityId; + } + + public void setActivityId(Long activityId) { + this.activityId = activityId; + } +} diff --git a/src/main/java/com/share/help/res/TimeScore.java b/src/main/java/com/share/help/res/TimeScore.java new file mode 100644 index 0000000..286e62b --- /dev/null +++ b/src/main/java/com/share/help/res/TimeScore.java @@ -0,0 +1,25 @@ +package com.share.help.res; + +import java.sql.Timestamp; + +public class TimeScore { + private Timestamp createTime; + + private Integer timeScore; + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Integer getTimeScore() { + return timeScore; + } + + public void setTimeScore(Integer timeScore) { + this.timeScore = timeScore; + } +} diff --git a/src/main/java/com/share/help/service/ManagerService.java b/src/main/java/com/share/help/service/ManagerService.java index af1391c..daad431 100644 --- a/src/main/java/com/share/help/service/ManagerService.java +++ b/src/main/java/com/share/help/service/ManagerService.java @@ -1,5 +1,6 @@ package com.share.help.service; +import com.share.help.dao.ActivityHistoryMapper; import com.share.help.dao.ActivityMapper; import com.share.help.dao.ManagerMapper; import com.share.help.dao.UserMapper; @@ -44,6 +45,9 @@ public class ManagerService { @Autowired private ImageService imageService; + @Autowired + private ActivityHistoryMapper activityHistoryMapper; + /** * 登录 * @param managerLoginForm 登录表单 @@ -175,4 +179,14 @@ public class ManagerService { return new JSONResponse<>(DefaultRes.fail,Result.FAIL); } } + + /** + * 查询时间币 + * @param queryScoreForm 查询时间币表单 + * @return 返回时间币 + */ + public JSONResponse queryTimeScore(QueryScoreForm queryScoreForm) { + TimeScore timeScore=activityHistoryMapper.queryActivityHistory(queryScoreForm.getUserId(),queryScoreForm.getActivityId()); + return new JSONResponse(DefaultRes.ok,Result.OK).setBody(timeScore); + } } diff --git a/src/main/resources/mapping/ActivityHistoryMapper.xml b/src/main/resources/mapping/ActivityHistoryMapper.xml index 14e7c9c..55b9b16 100644 --- a/src/main/resources/mapping/ActivityHistoryMapper.xml +++ b/src/main/resources/mapping/ActivityHistoryMapper.xml @@ -53,10 +53,19 @@ + + + \ No newline at end of file diff --git a/src/test/java/com/share/help/HelpApplicationTests.java b/src/test/java/com/share/help/HelpApplicationTests.java index 61a1084..5dcce73 100644 --- a/src/test/java/com/share/help/HelpApplicationTests.java +++ b/src/test/java/com/share/help/HelpApplicationTests.java @@ -9,6 +9,7 @@ import com.share.help.form.ActivityStatus; import com.share.help.form.manager.ActiveUserRes; import com.share.help.res.ManagerActivityRes; import com.share.help.res.Page; +import com.share.help.res.TimeScore; import com.share.help.res.account.QueryRes; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -317,9 +318,17 @@ class HelpApplicationTests { Assertions.assertTrue(activityMapper.updateActivity(66L,"44","", null)); } + //测试活跃用户 @Test public void testQueryActiveUser(){ List activeUserRes= activityMapper.queryActiveUser("123","广州"); Assertions.assertEquals(2, activeUserRes.get(0).getCount()); } + + //测试时间币 + @Test + public void testQueryTimeScore(){ + TimeScore timeScore= activityHistoryMapper.queryActivityHistory("123",65L); + Assertions.assertEquals(24, (int) timeScore.getTimeScore()); + } }