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.Result;
import api.StatusCode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import com.github.houbb.sensitive.word.core.SensitiveWordHelper;
import com.luoo.comment.dao.PublicationLikeDao;
@ -42,6 +43,7 @@ import util.IdWorker;
import util.StringTools;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@ -373,7 +375,16 @@ public class CommentController extends BaseController {
.userId(userLoginDto.getUserId())
.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);
}

@ -1,5 +1,6 @@
package com.luoo.user.listener;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.luoo.user.pojo.UserPointLog;
import com.luoo.user.service.UserPointLogService;
import lombok.extern.slf4j.Slf4j;
@ -9,6 +10,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
/**
* @program: luoo_parent
* @description:
@ -24,11 +28,18 @@ public class PointLogListener {
private UserPointLogService userPointLogService;
@RabbitHandler
public void executePointLog(Object userPointLog) {
log.info("userPointLog:{}", userPointLog);
UserPointLog result = new UserPointLog();
BeanUtils.copyProperties(userPointLog, result);
userPointLogService.add(result);
public void executePointLog(String json) {
log.info("userPointLog:{}", json);
ObjectMapper objectMapper = new ObjectMapper();
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;
import api.PageResult;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.luoo.user.Scheduler.DrawLotteryScheduler;
import com.luoo.user.config.EnvConfig;
import com.luoo.user.dao.LotteryDao;
@ -21,6 +22,7 @@ import enums.UserTypeEnum;
import enums.UserVipStatusEnum;
import exception.BizException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -306,7 +308,16 @@ public class LotteryService {
.score(lottery.getPoint())
.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;
import api.PageResult;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.luoo.user.dao.LotteryUserDao;
import com.luoo.user.dao.TaskPointDao;
import com.luoo.user.dao.UserInfoDao;
@ -19,6 +20,7 @@ import constants.TaskPointIdConstants;
import dto.UserLoginDto;
import enums.PointEnums;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
@ -133,7 +135,16 @@ public class UserPointLogService {
.userId(userId)
.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) {
@ -146,7 +157,16 @@ public class UserPointLogService {
.userId(userLoginDto.getUserId())
.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