From 75751c846aca8fd876a3a5a6c1f7e4e1a0ad4602 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Wed, 27 May 2020 12:09:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/share/help/Constants.java | 3 +++ .../help/controller/ActivityController.java | 21 +++++++++++++++---- .../share/help/entity/LeaveWordEntity.java | 21 ++++++++++++++----- .../help/res/activity/ActivityDetailRes.java | 9 ++++++++ .../share/help/service/ActivityService.java | 15 +++++++++++++ .../com/share/help/HelpApplicationTests.java | 6 +----- 6 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/share/help/res/activity/ActivityDetailRes.java diff --git a/src/main/java/com/share/help/Constants.java b/src/main/java/com/share/help/Constants.java index 4da6d42..5a01c88 100644 --- a/src/main/java/com/share/help/Constants.java +++ b/src/main/java/com/share/help/Constants.java @@ -25,4 +25,7 @@ public class Constants { //查找用户接口 public static final String USER_INTERFACE_FIND = "/find"; + + //查找活动接口 + public static final String ACTIVITY_INTERFACE_FIND_ID =ACTIVITY_INTERFACE_FIND+"/{activityId}" ; } diff --git a/src/main/java/com/share/help/controller/ActivityController.java b/src/main/java/com/share/help/controller/ActivityController.java index 06e0810..ca3ad49 100644 --- a/src/main/java/com/share/help/controller/ActivityController.java +++ b/src/main/java/com/share/help/controller/ActivityController.java @@ -1,20 +1,19 @@ package com.share.help.controller; import com.share.help.Constants; +import com.share.help.entity.ActivityEntity; import com.share.help.form.FindActivityForm; import com.share.help.form.SendHelpForm; import com.share.help.res.JSONResponse; import com.share.help.res.Result; import com.share.help.res.SendHelpRes; +import com.share.help.res.activity.ActivityDetailRes; import com.share.help.res.activity.FindActivityRes; import com.share.help.service.ActivityService; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping(Constants.ACTIVITY_INTERFACE) @@ -52,4 +51,18 @@ public class ActivityController { return activityService.find(findActivityForm); } } + + /** + * 查看活动详情 + * @param activityId 活动id + * @return 返回活动列表 + */ + @GetMapping(Constants.ACTIVITY_INTERFACE_FIND_ID) + public JSONResponse find(@PathVariable Long activityId){ + if(activityId==null){ + return new JSONResponse<>(ActivityDetailRes.fail,Result.FAIL); + }else{ + return activityService.find(activityId); + } + } } diff --git a/src/main/java/com/share/help/entity/LeaveWordEntity.java b/src/main/java/com/share/help/entity/LeaveWordEntity.java index 97e64f6..d7718e1 100644 --- a/src/main/java/com/share/help/entity/LeaveWordEntity.java +++ b/src/main/java/com/share/help/entity/LeaveWordEntity.java @@ -1,15 +1,16 @@ package com.share.help.entity; +import java.sql.Timestamp; import java.util.Objects; - public class LeaveWordEntity { private Long leaveWordId; private String type; private String sourceUserId; private String targetUserId; private Long activityId; + private Timestamp createTime; private UserEntity userBySourceUserId; private UserEntity userByTargetUserId; private ActivityEntity activityByActivityId; @@ -64,6 +65,14 @@ public class LeaveWordEntity { this.activityId = activityId; } + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -73,16 +82,18 @@ public class LeaveWordEntity { Objects.equals(type, that.type) && Objects.equals(sourceUserId, that.sourceUserId) && Objects.equals(targetUserId, that.targetUserId) && - Objects.equals(activityId, that.activityId); + Objects.equals(activityId, that.activityId) && + Objects.equals(createTime, that.createTime) && + Objects.equals(userBySourceUserId, that.userBySourceUserId) && + Objects.equals(userByTargetUserId, that.userByTargetUserId) && + Objects.equals(activityByActivityId, that.activityByActivityId); } @Override public int hashCode() { - return Objects.hash(leaveWordId, type, sourceUserId, targetUserId, activityId); + return Objects.hash(leaveWordId, type, sourceUserId, targetUserId, activityId, createTime, userBySourceUserId, userByTargetUserId, activityByActivityId); } - - public UserEntity getUserBySourceUserId() { return userBySourceUserId; } diff --git a/src/main/java/com/share/help/res/activity/ActivityDetailRes.java b/src/main/java/com/share/help/res/activity/ActivityDetailRes.java new file mode 100644 index 0000000..aa66e72 --- /dev/null +++ b/src/main/java/com/share/help/res/activity/ActivityDetailRes.java @@ -0,0 +1,9 @@ +package com.share.help.res.activity; + +/** + * 活动详情响应 + */ +public enum ActivityDetailRes{ + ok, + fail +} diff --git a/src/main/java/com/share/help/service/ActivityService.java b/src/main/java/com/share/help/service/ActivityService.java index ca6c90b..d9d5a0e 100644 --- a/src/main/java/com/share/help/service/ActivityService.java +++ b/src/main/java/com/share/help/service/ActivityService.java @@ -8,6 +8,7 @@ import com.share.help.form.SendHelpForm; import com.share.help.res.JSONResponse; import com.share.help.res.Result; import com.share.help.res.SendHelpRes; +import com.share.help.res.activity.ActivityDetailRes; import com.share.help.res.activity.ActivitySimple; import com.share.help.res.activity.FindActivityRes; import org.springframework.beans.factory.annotation.Autowired; @@ -79,4 +80,18 @@ public class ActivityService{ } } + /** + * 查看活动详情 + * @param activityId 活动id + * @return 返回活动详情信息 + */ + public JSONResponse find(Long activityId){ + ActivityEntity activityEntity=activityMapper.findOne(activityId); + if(activityEntity==null){ + return new JSONResponse<>(ActivityDetailRes.fail,Result.FAIL); + }else{ + return new JSONResponse(ActivityDetailRes.ok,Result.OK).setBody(activityEntity); + } + } + } diff --git a/src/test/java/com/share/help/HelpApplicationTests.java b/src/test/java/com/share/help/HelpApplicationTests.java index de8a2d0..88ca00b 100644 --- a/src/test/java/com/share/help/HelpApplicationTests.java +++ b/src/test/java/com/share/help/HelpApplicationTests.java @@ -140,11 +140,7 @@ class HelpApplicationTests { */ @Test public void testActivity(){ -// FindActivityRes findActivityRes=activityMapper.count(10L); - -// List list=activityMapper.getPage(0,10); - - + Assertions.assertNotNull(activityMapper.findOne(1L)); }