From 4601bcf00ff7d6c91683b95e14b18a3432d46553 Mon Sep 17 00:00:00 2001 From: huangyw <1207046171@qq.com> Date: Thu, 25 Jul 2024 09:51:14 +0800 Subject: [PATCH] =?UTF-8?q?release:=20=E5=BE=AA=E7=8E=AF=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luoo/user/service/TaskPointService.java | 8 +++--- .../user/service/UserPointLogService.java | 26 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/service/TaskPointService.java b/luoo_user/src/main/java/com/luoo/user/service/TaskPointService.java index 9d9d42b..8302f40 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/TaskPointService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/TaskPointService.java @@ -6,6 +6,7 @@ import com.luoo.user.pojo.TaskPoint; import dto.UserLoginDto; import java.util.List; import lombok.extern.slf4j.Slf4j; +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; @@ -34,16 +35,15 @@ public class TaskPointService { private final JwtUtil jwtUtil; - private final RedisTemplate redisTemplate; - public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil, - RedisTemplate redisTemplate) { + public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil) { this.taskPointDao = taskPointDao; this.idWorker = idWorker; this.jwtUtil = jwtUtil; - this.redisTemplate = redisTemplate; } + @Autowired + private RedisTemplate redisTemplate; /** * 新增配置 diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java index 0934be7..3b3ca67 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java @@ -2,6 +2,7 @@ package com.luoo.user.service; import api.PageResult; import com.luoo.user.dao.TaskPointDao; +import com.luoo.user.dao.UserInfoDao; import com.luoo.user.dao.UserPointLogDao; import com.luoo.user.dto.point.UserPointLogSearchDto; import com.luoo.user.pojo.TaskPoint; @@ -19,12 +20,12 @@ import javax.persistence.criteria.Root; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; 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.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; 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; import util.IdWorker; @@ -50,24 +51,23 @@ public class UserPointLogService { private final RabbitTemplate rabbitTemplate; - private final UserInfoService userInfoService; - - private final RedisTemplate redisTemplate; - - private final TaskPointService taskPointService; + private final UserInfoDao userInfoDao; public UserPointLogService(UserPointLogDao userPointLogDao, IdWorker idWorker, JwtUtil jwtUtil, - TaskPointDao taskPointDao, RabbitTemplate rabbitTemplate, - UserInfoService userInfoService, RedisTemplate redisTemplate, - TaskPointService taskPointService) { + TaskPointDao taskPointDao, RabbitTemplate rabbitTemplate, UserInfoDao userInfoDao) { this.userPointLogDao = userPointLogDao; this.idWorker = idWorker; this.jwtUtil = jwtUtil; this.taskPointDao = taskPointDao; this.rabbitTemplate = rabbitTemplate; - this.userInfoService = userInfoService; - this.redisTemplate = redisTemplate; + this.userInfoDao = userInfoDao; + } + + private TaskPointService taskPointService; + + @Autowired + private void setTaskPointService(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(); point += userPointLog.getScore(); userInfo.setPoint(point); // 更新用户积分信息 - userInfoService.update(userInfo); + userInfoDao.save(userInfo); }