|
|
|
@ -2,10 +2,12 @@ package com.luoo.user.service;
|
|
|
|
|
|
|
|
|
|
import api.PageResult;
|
|
|
|
|
import com.luoo.user.dao.TaskPointDao;
|
|
|
|
|
import com.luoo.user.dao.UserPointLogDao;
|
|
|
|
|
import com.luoo.user.dto.point.TaskPointDto;
|
|
|
|
|
import com.luoo.user.dto.point.TaskPointForAppDto;
|
|
|
|
|
import com.luoo.user.pojo.TaskPoint;
|
|
|
|
|
import com.luoo.user.pojo.UserPointLog;
|
|
|
|
|
import constants.TaskPointIdConstants;
|
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
@ -44,15 +46,16 @@ public class TaskPointService {
|
|
|
|
|
|
|
|
|
|
private final JwtUtil jwtUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final UserPointLogDao userPointLogDao;
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil, RedisTemplate redisTemplate) {
|
|
|
|
|
public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil, UserPointLogDao userPointLogDao, RedisTemplate redisTemplate) {
|
|
|
|
|
this.taskPointDao = taskPointDao;
|
|
|
|
|
this.idWorker = idWorker;
|
|
|
|
|
this.jwtUtil = jwtUtil;
|
|
|
|
|
this.userPointLogDao = userPointLogDao;
|
|
|
|
|
this.redisTemplate = redisTemplate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -172,8 +175,9 @@ public class TaskPointService {
|
|
|
|
|
* @return 列表
|
|
|
|
|
*/
|
|
|
|
|
public List<TaskPointForAppDto> getTaskPointListForApp(String token, Integer type) {
|
|
|
|
|
List<TaskPoint> taskPointList = taskPointDao.findByTypeAndValid(type, PointEnums.VALID.getCode());
|
|
|
|
|
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
|
|
|
|
|
|
|
|
|
|
List<TaskPoint> taskPointList = taskPointDao.findByTypeAndValid(type, PointEnums.VALID.getCode());
|
|
|
|
|
List<TaskPointForAppDto> result = taskPointList.stream().map(taskPoint -> {
|
|
|
|
|
TaskPointForAppDto taskPointForAppDto = new TaskPointForAppDto();
|
|
|
|
|
BeanUtils.copyProperties(taskPoint, taskPointForAppDto);
|
|
|
|
@ -182,7 +186,7 @@ public class TaskPointService {
|
|
|
|
|
// 如果是新手任务,需要判断是否已参与
|
|
|
|
|
result.forEach(taskPoint -> {
|
|
|
|
|
if(Objects.equals(taskPoint.getType(), PointEnums.TASK_TYPE_NEW.getCode())) {
|
|
|
|
|
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
|
|
|
|
|
|
|
|
|
|
UserPointLog checkLog = userPointLogService.getUserPointLog(userLoginDto.getUserId(), taskPoint.getId());
|
|
|
|
|
if(checkLog != null) {
|
|
|
|
|
taskPoint.setUserStatus(PointEnums.PARTICIPATED.getCode());
|
|
|
|
@ -190,6 +194,15 @@ public class TaskPointService {
|
|
|
|
|
taskPoint.setUserStatus(PointEnums.NOT_PARTICIPATED.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Objects.equals(taskPoint.getType(), Integer.valueOf(TaskPointIdConstants.DAILY_SIGN))) {
|
|
|
|
|
// 校验今日是否已签到
|
|
|
|
|
UserPointLog todayByUserIdAndTaskPointId = userPointLogDao.findTodayByUserIdAndTaskPointId(userLoginDto.getUserId(), TaskPointIdConstants.DAILY_SIGN);
|
|
|
|
|
if(todayByUserIdAndTaskPointId != null) {
|
|
|
|
|
taskPoint.setUserStatus(PointEnums.PARTICIPATED.getCode());
|
|
|
|
|
} else {
|
|
|
|
|
taskPoint.setUserStatus(PointEnums.NOT_PARTICIPATED.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|