release: 循环依赖

release-2024-08-08
huangyw 6 months ago
parent e6e7977756
commit 4601bcf00f

@ -6,6 +6,7 @@ import com.luoo.user.pojo.TaskPoint;
import dto.UserLoginDto; import dto.UserLoginDto;
import java.util.List; import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -34,16 +35,15 @@ public class TaskPointService {
private final JwtUtil jwtUtil; private final JwtUtil jwtUtil;
private final RedisTemplate<String, Object> redisTemplate;
public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil, public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil) {
RedisTemplate<String, Object> redisTemplate) {
this.taskPointDao = taskPointDao; this.taskPointDao = taskPointDao;
this.idWorker = idWorker; this.idWorker = idWorker;
this.jwtUtil = jwtUtil; this.jwtUtil = jwtUtil;
this.redisTemplate = redisTemplate;
} }
@Autowired
private RedisTemplate redisTemplate;
/** /**
* *

@ -2,6 +2,7 @@ package com.luoo.user.service;
import api.PageResult; import api.PageResult;
import com.luoo.user.dao.TaskPointDao; import com.luoo.user.dao.TaskPointDao;
import com.luoo.user.dao.UserInfoDao;
import com.luoo.user.dao.UserPointLogDao; import com.luoo.user.dao.UserPointLogDao;
import com.luoo.user.dto.point.UserPointLogSearchDto; import com.luoo.user.dto.point.UserPointLogSearchDto;
import com.luoo.user.pojo.TaskPoint; import com.luoo.user.pojo.TaskPoint;
@ -19,12 +20,12 @@ import javax.persistence.criteria.Root;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import util.IdWorker; import util.IdWorker;
@ -50,24 +51,23 @@ public class UserPointLogService {
private final RabbitTemplate rabbitTemplate; private final RabbitTemplate rabbitTemplate;
private final UserInfoService userInfoService; private final UserInfoDao userInfoDao;
private final RedisTemplate<String, Object> redisTemplate;
private final TaskPointService taskPointService;
public UserPointLogService(UserPointLogDao userPointLogDao, IdWorker idWorker, JwtUtil jwtUtil, public UserPointLogService(UserPointLogDao userPointLogDao, IdWorker idWorker, JwtUtil jwtUtil,
TaskPointDao taskPointDao, RabbitTemplate rabbitTemplate, TaskPointDao taskPointDao, RabbitTemplate rabbitTemplate, UserInfoDao userInfoDao) {
UserInfoService userInfoService, RedisTemplate<String, Object> redisTemplate,
TaskPointService taskPointService) {
this.userPointLogDao = userPointLogDao; this.userPointLogDao = userPointLogDao;
this.idWorker = idWorker; this.idWorker = idWorker;
this.jwtUtil = jwtUtil; this.jwtUtil = jwtUtil;
this.taskPointDao = taskPointDao; this.taskPointDao = taskPointDao;
this.rabbitTemplate = rabbitTemplate; this.rabbitTemplate = rabbitTemplate;
this.userInfoService = userInfoService; this.userInfoDao = userInfoDao;
this.redisTemplate = redisTemplate; }
private TaskPointService taskPointService;
@Autowired
private void setTaskPointService(TaskPointService taskPointService) {
this.taskPointService = taskPointService; this.taskPointService = taskPointService;
} }
@ -152,12 +152,12 @@ public class UserPointLogService {
// 更新用户积分,获取用户信息并累加积分得分 // 更新用户积分,获取用户信息并累加积分得分
// 对用户进行积分计算 // 对用户进行积分计算
UserInfo userInfo = userInfoService.findById(userPointLog.getUserId()); UserInfo userInfo = userInfoDao.findById(userPointLog.getUserId()).get();
Integer point = userInfo.getPoint(); Integer point = userInfo.getPoint();
point += userPointLog.getScore(); point += userPointLog.getScore();
userInfo.setPoint(point); userInfo.setPoint(point);
// 更新用户积分信息 // 更新用户积分信息
userInfoService.update(userInfo); userInfoDao.save(userInfo);
} }

Loading…
Cancel
Save