diff --git a/src/main/java/com/share/help/Constants.java b/src/main/java/com/share/help/Constants.java index 81606eb..8efbf99 100644 --- a/src/main/java/com/share/help/Constants.java +++ b/src/main/java/com/share/help/Constants.java @@ -49,4 +49,8 @@ public class Constants { public static final String USER_INTERFACE_FIND_NAME = USER_INTERFACE_FIND+"/name"; //查找留言 public static final String USER_INTERFACE_FIND_LEAVE_WORD = USER_INTERFACE_FIND+"/leaveWord"; + //查找帮助信息 + public static final String ACTIVITY_INTERFACE_HELP = "/help"; + //修改分数 + public static final String ACTIVITY_INTERFACE_SCORE = "/score"; } diff --git a/src/main/java/com/share/help/Util.java b/src/main/java/com/share/help/Util.java index e3fe2a7..93a0134 100644 --- a/src/main/java/com/share/help/Util.java +++ b/src/main/java/com/share/help/Util.java @@ -14,7 +14,7 @@ public class Util { */ public static List> splitList(Class c,List dataList, int splitSize){ List> splitList=new ArrayList<>(); - if(dataList.size()(DefaultRes.fail,Result.FAIL); } } + + /** + * 查找帮助列表 + * @param queryHelpForm 查询表单 + * @param userId 用户id + * @return 返回帮助信息 + */ + @GetMapping(Constants.ACTIVITY_INTERFACE_HELP) + public JSONResponse>> queryHelp(QueryHelpForm queryHelpForm,@CookieValue(Constants.USER_COOKIE) String userId){ + if(ObjectUtils.allNotNull(queryHelpForm.getCurrentPage(),userId)){ + queryHelpForm.setUserId(userId); + return activityService.queryHelp(queryHelpForm); + }else{ + return new JSONResponse<>(DefaultRes.fail,Result.FAIL); + } + } + + /** + * 评价活动 + * @param helpScoreForm 评价表单 + * @return 返回评价结果 + */ + @PostMapping(Constants.ACTIVITY_INTERFACE_SCORE) + public JSONResponse updateScore(HelpScoreForm helpScoreForm){ + if(ObjectUtils.allNotNull(helpScoreForm.getHistoryId(),helpScoreForm.getScore())){ + return activityService.updateScore(helpScoreForm); + }else { + return new JSONResponse<>(DefaultRes.fail,Result.FAIL); + } + } } diff --git a/src/main/java/com/share/help/controller/UserController.java b/src/main/java/com/share/help/controller/UserController.java index 744af7c..8df442f 100644 --- a/src/main/java/com/share/help/controller/UserController.java +++ b/src/main/java/com/share/help/controller/UserController.java @@ -158,4 +158,5 @@ public class UserController { } } + } diff --git a/src/main/java/com/share/help/dao/ActivityHistoryMapper.java b/src/main/java/com/share/help/dao/ActivityHistoryMapper.java index e0e7df8..17e8048 100644 --- a/src/main/java/com/share/help/dao/ActivityHistoryMapper.java +++ b/src/main/java/com/share/help/dao/ActivityHistoryMapper.java @@ -1,9 +1,12 @@ package com.share.help.dao; 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 org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; import java.util.List; @@ -21,6 +24,21 @@ public interface ActivityHistoryMapper { "(#{activityId},#{userId},#{activityStatus},#{createTime},#{activityScore},#{timeScore})") boolean insert(ActivityHistoryEntity activityHistoryEntity); - + /** + * 获取志愿者列表 + * @param activityStatus 活动状态 + * @param activityId 活动id + * @return 返回志愿者列表 + */ List queryUser(@Param("activityStatus") String activityStatus, @Param("activityId") Long activityId); + +// 获取我的帮助列表数据 + List queryMyHelp(@Param("start") long start,@Param("count") long count,@Param("userId") String userId); + +// 获取分页信息 + Page> count(@Param("userId") String userId,@Param("pageSize") Integer pageSize); + + //活动评价 + @Update("update activity_history set activity_score=#{score} where history_id=#{historyId}") + boolean updateScore(@Param("historyId") Long historyId,@Param("score") Integer score); } diff --git a/src/main/java/com/share/help/entity/custorm/ActivitySimple.java b/src/main/java/com/share/help/entity/custorm/ActivitySimple.java index 642ca09..6c8b698 100644 --- a/src/main/java/com/share/help/entity/custorm/ActivitySimple.java +++ b/src/main/java/com/share/help/entity/custorm/ActivitySimple.java @@ -9,6 +9,24 @@ public class ActivitySimple { private String title; private String content; private String activityImg; + private Boolean hasApply; + private Boolean hasStart; + + public Boolean getHasStart() { + return hasStart; + } + + public void setHasStart(Boolean hasStart) { + this.hasStart = hasStart; + } + + public Boolean getHasApply() { + return hasApply; + } + + public void setHasApply(Boolean hasApply) { + this.hasApply = hasApply; + } public String getUserId() { return userId; diff --git a/src/main/java/com/share/help/entity/custorm/HelpRes.java b/src/main/java/com/share/help/entity/custorm/HelpRes.java new file mode 100644 index 0000000..cfc87d4 --- /dev/null +++ b/src/main/java/com/share/help/entity/custorm/HelpRes.java @@ -0,0 +1,159 @@ +package com.share.help.entity.custorm; + +import java.sql.Timestamp; + +/** + * 我的帮助列表 + */ +public class HelpRes { +// 活动id + private Long activityId; +// 历史id + private Long historyId; +// 活动背景图 + private String activityImg; +// 活动标题 + private String title; +// 活动内容 + private String content; +// 求助时间 + private Timestamp seekHelpTime; +// 活动开始时间 + private Timestamp activityStartTime; +// 活动结束时间 + private Timestamp activityEndTime; +// 状态 + private String status; +// 报名时间 + private Timestamp applyTime; +// 参与时间 + private Timestamp joinTime; +// 完成时间 + private Timestamp completeTime; +// 评分 + private Integer activityScore; + //活动开始状态 + private Boolean hasStart; + //活动结束状态 + private Boolean hasEnd; + + public Boolean getHasEnd() { + return hasEnd; + } + + public void setHasEnd(Boolean hasEnd) { + this.hasEnd = hasEnd; + } + + public Long getHistoryId() { + return historyId; + } + + public void setHistoryId(Long historyId) { + this.historyId = historyId; + } + + public Boolean getHasStart() { + return hasStart; + } + + public void setHasStart(Boolean hasStart) { + this.hasStart = hasStart; + } + + public Long getActivityId() { + return activityId; + } + + public void setActivityId(Long activityId) { + this.activityId = activityId; + } + + public String getActivityImg() { + return activityImg; + } + + public void setActivityImg(String activityImg) { + this.activityImg = activityImg; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Timestamp getSeekHelpTime() { + return seekHelpTime; + } + + public void setSeekHelpTime(Timestamp seekHelpTime) { + this.seekHelpTime = seekHelpTime; + } + + public Timestamp getActivityStartTime() { + return activityStartTime; + } + + public void setActivityStartTime(Timestamp activityStartTime) { + this.activityStartTime = activityStartTime; + } + + public Timestamp getActivityEndTime() { + return activityEndTime; + } + + public void setActivityEndTime(Timestamp activityEndTime) { + this.activityEndTime = activityEndTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Timestamp getApplyTime() { + return applyTime; + } + + public void setApplyTime(Timestamp applyTime) { + this.applyTime = applyTime; + } + + public Timestamp getJoinTime() { + return joinTime; + } + + public void setJoinTime(Timestamp joinTime) { + this.joinTime = joinTime; + } + + public Timestamp getCompleteTime() { + return completeTime; + } + + public void setCompleteTime(Timestamp completeTime) { + this.completeTime = completeTime; + } + + public Integer getActivityScore() { + return activityScore; + } + + public void setActivityScore(Integer activityScore) { + this.activityScore = activityScore; + } +} diff --git a/src/main/java/com/share/help/form/HelpScoreForm.java b/src/main/java/com/share/help/form/HelpScoreForm.java new file mode 100644 index 0000000..0de78b4 --- /dev/null +++ b/src/main/java/com/share/help/form/HelpScoreForm.java @@ -0,0 +1,27 @@ +package com.share.help.form; + +/** + * 活动评价表单 + */ +public class HelpScoreForm { + //历史id + private Long historyId; + //分数 + private Integer score; + + public Long getHistoryId() { + return historyId; + } + + public void setHistoryId(Long historyId) { + this.historyId = historyId; + } + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } +} diff --git a/src/main/java/com/share/help/form/QueryHelpForm.java b/src/main/java/com/share/help/form/QueryHelpForm.java new file mode 100644 index 0000000..17f1ada --- /dev/null +++ b/src/main/java/com/share/help/form/QueryHelpForm.java @@ -0,0 +1,26 @@ +package com.share.help.form; + +/** + * 我的帮助信息搜索条件 + */ +public class QueryHelpForm { + private Integer currentPage; + + private String userId; + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } +} diff --git a/src/main/java/com/share/help/service/ActivityService.java b/src/main/java/com/share/help/service/ActivityService.java index dd9c474..91e849b 100644 --- a/src/main/java/com/share/help/service/ActivityService.java +++ b/src/main/java/com/share/help/service/ActivityService.java @@ -7,15 +7,9 @@ import com.share.help.dao.LeaveWordMapper; import com.share.help.entity.ActivityEntity; import com.share.help.entity.ActivityHistoryEntity; import com.share.help.entity.LeaveWordEntity; -import com.share.help.entity.custorm.ActivitySimple; -import com.share.help.entity.custorm.FindActivityRes; -import com.share.help.entity.custorm.SeekHelpSum; -import com.share.help.entity.custorm.UserWithName; +import com.share.help.entity.custorm.*; import com.share.help.form.*; -import com.share.help.res.DefaultRes; -import com.share.help.res.JSONResponse; -import com.share.help.res.Result; -import com.share.help.res.SendHelpRes; +import com.share.help.res.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -45,11 +39,14 @@ public class ActivityService{ private ImageService imageService; //活动分页配置 - @Value("${activity.page-size}") - private int pageSize; + @Value("${page-size.activity.page-size}") + private int activityPageSize; - @Value("${activity.row-size}") - private int rowSize; + @Value("${page-size.activity.row-size}") + private int activityRowSize; + + @Value("${page-size.help}") + private int helpPageSize; private Logger logger = LoggerFactory.getLogger(ActivityService.class); @@ -84,12 +81,12 @@ public class ActivityService{ * @return 返回活动信息 */ public JSONResponse find(FindActivityForm findActivityForm){ - FindActivityRes findActivityRes=activityMapper.count(pageSize,findActivityForm.getUserId()); - findActivityRes.setPageSize(pageSize); + FindActivityRes findActivityRes=activityMapper.count(activityPageSize,findActivityForm.getUserId()); + findActivityRes.setPageSize(activityPageSize); findActivityRes.setCurrentPage(findActivityForm.getCurrentPage()); - List activitySimpleList=activityMapper.getPage((findActivityForm.getCurrentPage()-1)*pageSize,pageSize,findActivityForm.getUserId()); + List activitySimpleList=activityMapper.getPage((findActivityForm.getCurrentPage()-1)* activityPageSize, activityPageSize,findActivityForm.getUserId()); if(!activitySimpleList.isEmpty()){ - findActivityRes.setBody(Util.splitList(ActivitySimple.class,activitySimpleList,rowSize)); + findActivityRes.setBody(Util.splitList(ActivitySimple.class,activitySimpleList, activityRowSize)); return new JSONResponse(FindActivityRes.Res.ok,Result.OK).setBody(findActivityRes); }else{ return new JSONResponse<>(FindActivityRes.Res.empty, Result.OK); @@ -165,4 +162,30 @@ public class ActivityService{ List userList=activityHistoryMapper.queryUser(findUserHelp.getActivityStatus().name(),findUserHelp.getActivityId()); return new JSONResponse>(DefaultRes.ok,Result.OK).setBody(userList); } + + + /** + * 查询帮助列表 + * @param queryHelpForm 查询表单 + * @return 返回列表 + */ + public JSONResponse>> queryHelp(QueryHelpForm queryHelpForm){ + Page> page=activityHistoryMapper.count(queryHelpForm.getUserId(),helpPageSize); + List helpRes=activityHistoryMapper.queryMyHelp((queryHelpForm.getCurrentPage()-1)*helpPageSize,helpPageSize,queryHelpForm.getUserId()); + page.setBody(helpRes); + return new JSONResponse>>(DefaultRes.ok,Result.OK).setBody(page); + } + + /** + * 活动评价 + * @param helpScoreForm 评价表单 + * @return 返回评价结果 + */ + public JSONResponse updateScore(HelpScoreForm helpScoreForm){ + if(activityHistoryMapper.updateScore(helpScoreForm.getHistoryId(),helpScoreForm.getScore())){ + return new JSONResponse<>(DefaultRes.ok,Result.OK); + }else{ + return new JSONResponse<>(DefaultRes.fail,Result.FAIL); + } + } } diff --git a/src/main/java/com/share/help/service/LeaveWordService.java b/src/main/java/com/share/help/service/LeaveWordService.java index e673d61..8f66965 100644 --- a/src/main/java/com/share/help/service/LeaveWordService.java +++ b/src/main/java/com/share/help/service/LeaveWordService.java @@ -19,7 +19,7 @@ import java.util.List; @Service public class LeaveWordService { - @Value("${leave-word.page-size}") + @Value("${page-size.leave-word}") private int pageSize; @Autowired diff --git a/src/main/java/com/share/help/service/UserService.java b/src/main/java/com/share/help/service/UserService.java index 1dbd3fa..71c5b16 100644 --- a/src/main/java/com/share/help/service/UserService.java +++ b/src/main/java/com/share/help/service/UserService.java @@ -33,10 +33,10 @@ public class UserService{ private int timeScore; //用户分页配置 - @Value("${activity.page-size}") + @Value("${page-size.user.page-size}") private int pageSize; - @Value("${activity.row-size}") + @Value("${page-size.user.row-size}") private int rowSize; @Autowired @@ -105,7 +105,7 @@ public class UserService{ findUserRes.setBody(Util.splitList(UserEntity.class,userEntityList,rowSize)); return new JSONResponse(FindUserRes.Res.ok,Result.OK).setBody(findUserRes); }else{ - return new JSONResponse<>(FindUserRes.Res.empty, Result.FAIL); + return new JSONResponse<>(FindUserRes.Res.empty, Result.OK); } } @@ -191,4 +191,5 @@ public class UserService{ List userWithNameList=userMapper.queryUser(queryUserForm.getUserName(),queryUserForm.getInfo()); return new JSONResponse>(DefaultRes.ok,Result.OK).setBody(userWithNameList); } + } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 6d3ad9e..4f31cf0 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -25,14 +25,23 @@ user: register: #初始时间币 time-score: 20 -#活动 -activity: - # 分页大小 - page-size: 6 - # 前端一行显示数量 - row-size: 3 -#留言 -leave-word: - # 分页大小 - page-size: 3 + +#分页配置 +page-size: + #留言列表 + leave-word: 3 + #活动列表 + activity: + # 分页大小 + page-size: 6 + # 前端一行显示数量 + row-size: 3 + #我的帮助列表 + help: 3 + #志愿者列表 + user: + # 分页大小 + page-size: 6 + # 前端一行显示数量 + row-size: 3 diff --git a/src/main/resources/mapping/ActivityHistoryMapper.xml b/src/main/resources/mapping/ActivityHistoryMapper.xml index 30d4a89..b5d19b1 100644 --- a/src/main/resources/mapping/ActivityHistoryMapper.xml +++ b/src/main/resources/mapping/ActivityHistoryMapper.xml @@ -8,4 +8,39 @@ select user_id as userId,name from user where user_id in (select user_id from activity_history where activity_id=#{activityId} and activity_status=#{activityStatus}) + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapping/ActivityMapper.xml b/src/main/resources/mapping/ActivityMapper.xml index 5676c92..a9a93f2 100644 --- a/src/main/resources/mapping/ActivityMapper.xml +++ b/src/main/resources/mapping/ActivityMapper.xml @@ -21,23 +21,19 @@ + + - - - where user_id!=#{userId} - and - activity_id not in(select distinct activity_id from activity_history where activity_history.user_id=#{userId}) - + @@ -54,13 +50,16 @@ @@ -68,4 +67,6 @@ select user_id as userId,name from user where user_id in (select user_id from activity_history where activity_id=#{activityId} and activity_status=#{activityStatus}; + + \ 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 487b0b3..9e3067f 100644 --- a/src/test/java/com/share/help/HelpApplicationTests.java +++ b/src/test/java/com/share/help/HelpApplicationTests.java @@ -175,7 +175,7 @@ class HelpApplicationTests { // 求助信息统计 @Test public void testSeekHelpCount(){ - List seekHelpSums=activityMapper.seekHelp("777"); + List seekHelpSums=activityMapper.seekHelp("123"); Assertions.assertFalse(seekHelpSums.isEmpty()); } @@ -205,4 +205,13 @@ class HelpApplicationTests { List leaveWordRes=leaveWordMapper.select(0,3,"222"); Assertions.assertFalse(leaveWordRes.isEmpty()); } + + //查询我的帮助信息 + @Test + public void queryMyhelp(){ + Page> page=activityHistoryMapper.count("123",10); + Assertions.assertNotNull(page); + List list= activityHistoryMapper.queryMyHelp(0,2,"123"); + Assertions.assertFalse(list.isEmpty()); + } } diff --git a/src/test/resources/clean.sql b/src/test/resources/clean.sql index 3fd0108..273acff 100644 --- a/src/test/resources/clean.sql +++ b/src/test/resources/clean.sql @@ -1,2 +1,3 @@ -delete from activity; -delete from user; \ No newline at end of file +delete from activity_history; +delete from leave_word; +delete from activity; \ No newline at end of file