release- mq bug修复

release-2024-04-25
huangyawei 2 months ago
parent 1344a8b279
commit e5dc9bf48b

@ -4,6 +4,7 @@ package com.luoo.comment.controller;
import api.PageResult; import api.PageResult;
import api.Result; import api.Result;
import api.StatusCode; import api.StatusCode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.houbb.sensitive.word.bs.SensitiveWordBs; import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import com.github.houbb.sensitive.word.core.SensitiveWordHelper; import com.github.houbb.sensitive.word.core.SensitiveWordHelper;
import com.luoo.comment.dao.PublicationLikeDao; import com.luoo.comment.dao.PublicationLikeDao;
@ -42,6 +43,7 @@ import util.IdWorker;
import util.StringTools; import util.StringTools;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -373,7 +375,16 @@ public class CommentController extends BaseController {
.userId(userLoginDto.getUserId()) .userId(userLoginDto.getUserId())
.build(); .build();
rabbitTemplate.convertAndSend("pointLog", userPointLog); ObjectMapper objectMapper = new ObjectMapper();
try {
String json = objectMapper.writeValueAsString(userPointLog);
System.out.println(json);
rabbitTemplate.convertAndSend("pointLog", json);
} catch (IOException e) {
e.printStackTrace();
}
return Result.success(commentResp); return Result.success(commentResp);
} }

@ -1,5 +1,6 @@
package com.luoo.user.listener; package com.luoo.user.listener;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.luoo.user.pojo.UserPointLog; import com.luoo.user.pojo.UserPointLog;
import com.luoo.user.service.UserPointLogService; import com.luoo.user.service.UserPointLogService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -9,6 +10,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
/** /**
* @program: luoo_parent * @program: luoo_parent
* @description: * @description:
@ -24,11 +28,18 @@ public class PointLogListener {
private UserPointLogService userPointLogService; private UserPointLogService userPointLogService;
@RabbitHandler @RabbitHandler
public void executePointLog(Object userPointLog) { public void executePointLog(String json) {
log.info("userPointLog:{}", userPointLog); log.info("userPointLog:{}", json);
UserPointLog result = new UserPointLog();
BeanUtils.copyProperties(userPointLog, result); ObjectMapper objectMapper = new ObjectMapper();
userPointLogService.add(result);
try {
UserPointLog userPointLog = objectMapper.readValue(json, UserPointLog.class);
userPointLogService.add(userPointLog);
} catch (IOException e) {
e.printStackTrace();
}
} }
} }

@ -1,6 +1,7 @@
package com.luoo.user.service; package com.luoo.user.service;
import api.PageResult; import api.PageResult;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.luoo.user.Scheduler.DrawLotteryScheduler; import com.luoo.user.Scheduler.DrawLotteryScheduler;
import com.luoo.user.config.EnvConfig; import com.luoo.user.config.EnvConfig;
import com.luoo.user.dao.LotteryDao; import com.luoo.user.dao.LotteryDao;
@ -21,6 +22,7 @@ import enums.UserTypeEnum;
import enums.UserVipStatusEnum; import enums.UserVipStatusEnum;
import exception.BizException; import exception.BizException;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -306,7 +308,16 @@ public class LotteryService {
.score(lottery.getPoint()) .score(lottery.getPoint())
.build(); .build();
rabbitTemplate.convertAndSend("pointLog", userPointLog); ObjectMapper objectMapper = new ObjectMapper();
try {
String json = objectMapper.writeValueAsString(userPointLog);
System.out.println(json);
rabbitTemplate.convertAndSend("pointLog", json);
} catch (IOException e) {
e.printStackTrace();
}
}); });

@ -1,6 +1,7 @@
package com.luoo.user.service; package com.luoo.user.service;
import api.PageResult; import api.PageResult;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.luoo.user.dao.LotteryUserDao; import com.luoo.user.dao.LotteryUserDao;
import com.luoo.user.dao.TaskPointDao; import com.luoo.user.dao.TaskPointDao;
import com.luoo.user.dao.UserInfoDao; import com.luoo.user.dao.UserInfoDao;
@ -19,6 +20,7 @@ import constants.TaskPointIdConstants;
import dto.UserLoginDto; import dto.UserLoginDto;
import enums.PointEnums; import enums.PointEnums;
import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
@ -133,7 +135,16 @@ public class UserPointLogService {
.userId(userId) .userId(userId)
.build(); .build();
rabbitTemplate.convertAndSend("pointLog", userPointLog); ObjectMapper objectMapper = new ObjectMapper();
try {
String json = objectMapper.writeValueAsString(userPointLog);
System.out.println(json);
rabbitTemplate.convertAndSend("pointLog", json);
} catch (IOException e) {
e.printStackTrace();
}
} }
private void addByTask(String taskPointId, UserLoginDto userLoginDto) { private void addByTask(String taskPointId, UserLoginDto userLoginDto) {
@ -146,7 +157,16 @@ public class UserPointLogService {
.userId(userLoginDto.getUserId()) .userId(userLoginDto.getUserId())
.build(); .build();
rabbitTemplate.convertAndSend("pointLog", userPointLog); ObjectMapper objectMapper = new ObjectMapper();
try {
String json = objectMapper.writeValueAsString(userPointLog);
System.out.println(json);
rabbitTemplate.convertAndSend("pointLog", json);
} catch (IOException e) {
e.printStackTrace();
}
} }
/** /**

Loading…
Cancel
Save