diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java index 875ab69..54abf34 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java @@ -17,6 +17,7 @@ import com.luoo.comment.util.EmojiConverterUtil; import com.luoo.comment.util.IpUtil; import com.luoo.comment.util.MySensitiveWordReplaceUtils; import constants.Constants; +import constants.RabbitmqConstants; import constants.TaskPointIdConstants; import controller.BaseController; import dto.UserLoginDto; @@ -385,7 +386,7 @@ public class CommentController extends BaseController { String json = objectMapper.writeValueAsString(userPointLog); System.out.println(json); - rabbitTemplate.convertAndSend("pointLog", json); + rabbitTemplate.convertAndSend(RabbitmqConstants.POINT_LOG_QUEUE, json); } catch (IOException e) { e.printStackTrace(); } diff --git a/luoo_common/src/main/java/constants/RabbitmqConstants.java b/luoo_common/src/main/java/constants/RabbitmqConstants.java new file mode 100644 index 0000000..e4be8a2 --- /dev/null +++ b/luoo_common/src/main/java/constants/RabbitmqConstants.java @@ -0,0 +1,22 @@ +package constants;/** + * @Author: yawei.huang + * @Package: constants + * @Project: luoo_parent + * @Date: 2024/11/28 8:08 + * @Filename: RabbitmqConstants + * @Describe: + */ + +/** + * @program: luoo_parent + * + * @description: + * + * @author: yawei.huang + * + * @create: 2024-11-28 08:08 + **/ +public class RabbitmqConstants { + + public static final String POINT_LOG_QUEUE = "pointLog_test"; +} diff --git a/luoo_user/src/main/java/com/luoo/user/listener/PointLogListener.java b/luoo_user/src/main/java/com/luoo/user/listener/PointLogListener.java index 99b1a1c..a00f159 100644 --- a/luoo_user/src/main/java/com/luoo/user/listener/PointLogListener.java +++ b/luoo_user/src/main/java/com/luoo/user/listener/PointLogListener.java @@ -6,6 +6,7 @@ import com.luoo.user.pojo.UserPointLog; import com.luoo.user.service.InvitationService; import com.luoo.user.service.SignService; import com.luoo.user.util.DistributedLock; +import constants.RabbitmqConstants; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.amqp.rabbit.annotation.RabbitHandler; @@ -23,7 +24,7 @@ import java.io.IOException; * @create: 2024-07-24 13:05 **/ @Component -@RabbitListener(queues = "pointLog") +@RabbitListener(queues = RabbitmqConstants.POINT_LOG_QUEUE) @Slf4j public class PointLogListener { @@ -51,7 +52,6 @@ public class PointLogListener { String key = "pointLog:"; - distributedLock.unlock(key); if (distributedLock.tryLock(key, "1")) { try { // 执行需要加锁的业务逻辑 @@ -71,7 +71,7 @@ public class PointLogListener { } } else { // 获取锁失败,处理相应逻辑 - rabbitTemplate.convertAndSend("pointLog", json); + rabbitTemplate.convertAndSend(RabbitmqConstants.POINT_LOG_QUEUE, json); } } catch (IOException e) { e.printStackTrace(); diff --git a/luoo_user/src/main/java/com/luoo/user/service/InvitationService.java b/luoo_user/src/main/java/com/luoo/user/service/InvitationService.java index 47e83fb..c63f395 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/InvitationService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/InvitationService.java @@ -129,36 +129,36 @@ public class InvitationService { Integer score = 0; List list = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId( userId, TaskPointIdConstants.NEW_USER_INVITE); - if (list.size() >= 3 - 1) { + if (list.size() >= 3) { String inviteUserId3 = TaskPointIdConstants.INVITE_USER_3; TaskPoint inviteUser3TaskPoint = taskPointDao.findById(inviteUserId3).get(); // 邀请人数 >= 3人,并且没有获得对应的积分 List userPointLogsByUserIdAndTaskPointId3 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId( - TaskPointIdConstants.INVITE_USER_3, userId); + userId, TaskPointIdConstants.INVITE_USER_3); score += doMulInvitation(userId, inviteUser3TaskPoint, userPointLogsByUserIdAndTaskPointId3); } - if (list.size() >= 6 - 1) { + if (list.size() >= 6) { String inviteUserId6 = TaskPointIdConstants.INVITE_USER_6; TaskPoint inviteUser6TaskPoint = taskPointDao.findById(inviteUserId6).get(); // 邀请人数 >= 6人,并且没有获得对应的积分 List userPointLogsByUserIdAndTaskPointId6 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId( - TaskPointIdConstants.INVITE_USER_6, userId); + userId, TaskPointIdConstants.INVITE_USER_6); score += doMulInvitation(userId, inviteUser6TaskPoint, userPointLogsByUserIdAndTaskPointId6); } - if (list.size() >= 10 - 1) { + if (list.size() >= 10) { String inviteUserId10 = TaskPointIdConstants.INVITE_USER_10; TaskPoint inviteUser10TaskPoint = taskPointDao.findById(inviteUserId10).get(); // 邀请人数 >= 10人,并且没有获得对应的积分 List userPointLogsByUserIdAndTaskPointId10 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId( - TaskPointIdConstants.INVITE_USER_10, userId); + userId, TaskPointIdConstants.INVITE_USER_10); score += doMulInvitation(userId, inviteUser10TaskPoint, userPointLogsByUserIdAndTaskPointId10); } - if (list.size() >= 20 - 1) { + if (list.size() >= 20) { String inviteUserId20 = TaskPointIdConstants.INVITE_USER_20; TaskPoint inviteUser20TaskPoint = taskPointDao.findById(inviteUserId20).get(); // 邀请人数 >= 20人,并且没有获得对应的积分 List userPointLogsByUserIdAndTaskPointId20 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId( - TaskPointIdConstants.INVITE_USER_20, userId); + userId, TaskPointIdConstants.INVITE_USER_20); score += doMulInvitation(userId, inviteUser20TaskPoint, userPointLogsByUserIdAndTaskPointId20); } return score; diff --git a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java index 8abfffc..e83fc9c 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java @@ -23,6 +23,7 @@ import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import constants.Constants; import constants.ErrorConstants; +import constants.RabbitmqConstants; import constants.TaskPointIdConstants; import dto.UserLoginDto; import enums.PointEnums; @@ -369,7 +370,7 @@ public class LotteryService { String json = objectMapper.writeValueAsString(userPointLog); System.out.println(json); - rabbitTemplate.convertAndSend("pointLog", json); + rabbitTemplate.convertAndSend(RabbitmqConstants.POINT_LOG_QUEUE, json); } catch (IOException e) { e.printStackTrace(); } diff --git a/luoo_user/src/main/java/com/luoo/user/service/SignService.java b/luoo_user/src/main/java/com/luoo/user/service/SignService.java index e21465d..fbd2c51 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/SignService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/SignService.java @@ -98,7 +98,7 @@ public class SignService { userPointLog.getUserId(), TaskPointIdConstants.DAILY_SIGN, 3 - 1); if (daysByUserIdAndTaskPointId3.size() == 3 - 1) { List sign3 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId( - TaskPointIdConstants.DAILY_SIGN_3, userPointLog.getUserId()); + userPointLog.getUserId(), TaskPointIdConstants.DAILY_SIGN_3); if (sign3.isEmpty()) { point += executeMulSign(TaskPointIdConstants.DAILY_SIGN_3, userPointLog.getUserId()); } @@ -109,7 +109,7 @@ public class SignService { userPointLog.getUserId(), TaskPointIdConstants.DAILY_SIGN, 7 - 1); if (daysByUserIdAndTaskPointId7.size() == 7 - 1) { List sign7 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId( - TaskPointIdConstants.DAILY_SIGN_7, userPointLog.getUserId()); + userPointLog.getUserId(), TaskPointIdConstants.DAILY_SIGN_7); if (sign7.isEmpty()) { point += executeMulSign(TaskPointIdConstants.DAILY_SIGN_7, userPointLog.getUserId()); } @@ -119,7 +119,7 @@ public class SignService { userPointLog.getUserId(), TaskPointIdConstants.DAILY_SIGN, 30 - 1); if (daysByUserIdAndTaskPointId30.size() == 30 - 1) { List sign30 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId( - TaskPointIdConstants.DAILY_SIGN_30, userPointLog.getUserId()); + userPointLog.getUserId(),TaskPointIdConstants.DAILY_SIGN_30); if (sign30.isEmpty()) { point += executeMulSign(TaskPointIdConstants.DAILY_SIGN_30, userPointLog.getUserId()); } diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java index b2fce4e..8949856 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java @@ -17,6 +17,7 @@ import com.luoo.user.util.NickNameUtil; import com.luoo.user.util.NickNameUtil2; import constants.Constants; import constants.ErrorConstants; +import constants.RabbitmqConstants; import constants.TaskPointIdConstants; import dto.UserLoginDto; import enums.*; @@ -303,7 +304,7 @@ public class UserInfoService { String json = objectMapper.writeValueAsString(userPointLog); System.out.println(json); - rabbitTemplate.convertAndSend("pointLog", json); + rabbitTemplate.convertAndSend(RabbitmqConstants.POINT_LOG_QUEUE, json); } catch (IOException e) { e.printStackTrace(); } 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 9aa6df7..ee3e3b9 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 @@ -17,6 +17,7 @@ import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import constants.ErrorConstants; +import constants.RabbitmqConstants; import constants.TaskPointIdConstants; import dto.UserLoginDto; import enums.PointEnums; @@ -144,7 +145,7 @@ public class UserPointLogService { String json = objectMapper.writeValueAsString(userPointLog); System.out.println(json); - rabbitTemplate.convertAndSend("pointLog", json); + rabbitTemplate.convertAndSend(RabbitmqConstants.POINT_LOG_QUEUE, json); } catch (IOException e) { e.printStackTrace(); } @@ -166,7 +167,7 @@ public class UserPointLogService { String json = objectMapper.writeValueAsString(userPointLog); System.out.println(json); - rabbitTemplate.convertAndSend("pointLog", json); + rabbitTemplate.convertAndSend(RabbitmqConstants.POINT_LOG_QUEUE, json); } catch (IOException e) { e.printStackTrace(); }