|
|
|
@ -3,15 +3,22 @@ package com.luoo.user.service;
|
|
|
|
|
import api.PageResult;
|
|
|
|
|
import com.luoo.user.dao.TaskPointDao;
|
|
|
|
|
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 dto.UserLoginDto;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import enums.PointEnums;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -38,14 +45,24 @@ public class TaskPointService {
|
|
|
|
|
private final JwtUtil jwtUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil) {
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil, RedisTemplate redisTemplate) {
|
|
|
|
|
this.taskPointDao = taskPointDao;
|
|
|
|
|
this.idWorker = idWorker;
|
|
|
|
|
this.jwtUtil = jwtUtil;
|
|
|
|
|
this.redisTemplate = redisTemplate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private UserPointLogService userPointLogService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
private void setUserPointLogService(UserPointLogService userPointLogService) {
|
|
|
|
|
this.userPointLogService = userPointLogService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增配置
|
|
|
|
@ -146,6 +163,37 @@ public class TaskPointService {
|
|
|
|
|
return new PageResult<>(totalElements, taskPointPage.getContent());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* APP查询积分任务清单,以及本人是否已参与
|
|
|
|
|
*
|
|
|
|
|
* @param token token
|
|
|
|
|
* @param type 任务类型
|
|
|
|
|
* @return 列表
|
|
|
|
|
*/
|
|
|
|
|
public List<TaskPointForAppDto> getTaskPointListForApp(String token, Integer type) {
|
|
|
|
|
List<TaskPoint> taskPointList = taskPointDao.findByTypeAndValid(type, PointEnums.VALID.getCode());
|
|
|
|
|
|
|
|
|
|
List<TaskPointForAppDto> result = taskPointList.stream().map(taskPoint -> {
|
|
|
|
|
TaskPointForAppDto taskPointForAppDto = new TaskPointForAppDto();
|
|
|
|
|
BeanUtils.copyProperties(taskPoint, taskPointForAppDto);
|
|
|
|
|
return taskPointForAppDto;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
// 如果是新手任务,需要判断是否已参与
|
|
|
|
|
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());
|
|
|
|
|
} else {
|
|
|
|
|
taskPoint.setUserStatus(PointEnums.NOT_PARTICIPATED.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 单个查询
|
|
|
|
|
*/
|
|
|
|
|