增加获取用户参加活动奖励时间币记录

master
pan 4 years ago
parent 9494e563d5
commit 68067dfc15
  1. 4
      src/main/java/com/share/help/Constants.java
  2. 9
      src/main/java/com/share/help/controller/ManagerController.java
  3. 5
      src/main/java/com/share/help/dao/ActivityHistoryMapper.java
  4. 1
      src/main/java/com/share/help/dao/ActivityMapper.java
  5. 26
      src/main/java/com/share/help/form/QueryScoreForm.java
  6. 25
      src/main/java/com/share/help/res/TimeScore.java
  7. 14
      src/main/java/com/share/help/service/ManagerService.java
  8. 11
      src/main/resources/mapping/ActivityHistoryMapper.xml
  9. 9
      src/test/java/com/share/help/HelpApplicationTests.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";
}

@ -152,4 +152,13 @@ public class ManagerController {
return new JSONResponse<>(DefaultRes.fail,Result.FAIL);
}
}
@GetMapping(Constants.MANAGER_INTERFACE_SCORE)
public JSONResponse<DefaultRes,TimeScore> queryTimeScore(QueryScoreForm queryScoreForm){
if(queryScoreForm.getActivityId()!=null&&StringUtils.isNotEmpty(queryScoreForm.getUserId())){
return managerService.queryTimeScore(queryScoreForm);
}else{
return new JSONResponse<>(DefaultRes.fail,Result.FAIL);
}
}
}

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

@ -79,4 +79,5 @@ public interface ActivityMapper {
//查询活跃用户
List<ActiveUserRes> queryActiveUser(@Param("userId") String userId,@Param("serviceAddress") String serviceAddress);
}

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

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

@ -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<DefaultRes, TimeScore> queryTimeScore(QueryScoreForm queryScoreForm) {
TimeScore timeScore=activityHistoryMapper.queryActivityHistory(queryScoreForm.getUserId(),queryScoreForm.getActivityId());
return new JSONResponse<DefaultRes, TimeScore>(DefaultRes.ok,Result.OK).setBody(timeScore);
}
}

@ -53,10 +53,19 @@
<!-- 计算时间币-->
<select id="getTimeScore" resultType="int">
select TIMESTAMPDIFF(HOUR, create_time, now()) as time_score
select ceil(TIMESTAMPDIFF(SECOND , create_time, now()) /3600) as time_score
from activity_history
where activity_id = #{activityId}
and user_id = #{userId}
and activity_status = 'join'
</select>
<!-- 查询时间币历史记录-->
<select id="queryActivityHistory" resultType="com.share.help.res.TimeScore">
select create_time as createTime, time_score as timeScore
from activity_history
where activity_id = #{activityId}
and user_id = #{userId}
and activity_status = 'complete'
</select>
</mapper>

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

Loading…
Cancel
Save