增加查询活动详情接口

master
pan 5 years ago
parent 476625d359
commit 75751c846a
  1. 3
      src/main/java/com/share/help/Constants.java
  2. 21
      src/main/java/com/share/help/controller/ActivityController.java
  3. 21
      src/main/java/com/share/help/entity/LeaveWordEntity.java
  4. 9
      src/main/java/com/share/help/res/activity/ActivityDetailRes.java
  5. 15
      src/main/java/com/share/help/service/ActivityService.java
  6. 6
      src/test/java/com/share/help/HelpApplicationTests.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}" ;
}

@ -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<ActivityDetailRes,ActivityEntity> find(@PathVariable Long activityId){
if(activityId==null){
return new JSONResponse<>(ActivityDetailRes.fail,Result.FAIL);
}else{
return activityService.find(activityId);
}
}
}

@ -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;
}

@ -0,0 +1,9 @@
package com.share.help.res.activity;
/**
* 活动详情响应
*/
public enum ActivityDetailRes{
ok,
fail
}

@ -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<ActivityDetailRes,ActivityEntity> find(Long activityId){
ActivityEntity activityEntity=activityMapper.findOne(activityId);
if(activityEntity==null){
return new JSONResponse<>(ActivityDetailRes.fail,Result.FAIL);
}else{
return new JSONResponse<ActivityDetailRes,ActivityEntity>(ActivityDetailRes.ok,Result.OK).setBody(activityEntity);
}
}
}

@ -140,11 +140,7 @@ class HelpApplicationTests {
*/
@Test
public void testActivity(){
// FindActivityRes findActivityRes=activityMapper.count(10L);
// List<ActivitySimple> list=activityMapper.getPage(0,10);
Assertions.assertNotNull(activityMapper.findOne(1L));
}

Loading…
Cancel
Save