123
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.cai.mq.dto;
|
||||
|
||||
public enum CommonConsumerEnum {
|
||||
RANK,WINDOW_GIFT,WINDOW_RECHARGE,
|
||||
SYS_PUSH
|
||||
WINDOW_GIFT,WINDOW_RECHARGE,
|
||||
SYS_PUSH,RANK,LOGIN
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.cai.mq.handle;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.cai.mq.dto.CommonConsumerEnum;
|
||||
import com.ruoyi.cai.mq.handle.dto.LoginNotifyDTO;
|
||||
import com.ruoyi.cai.mq.handle.dto.RankNotifyDTO;
|
||||
import com.ruoyi.cai.rank.RankManager;
|
||||
import com.ruoyi.framework.OnlineUserTodayCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class LoginNotifyHandle implements IHandle {
|
||||
|
||||
@Autowired
|
||||
private OnlineUserTodayCache onlineUserTodayCache;
|
||||
|
||||
@Override
|
||||
public void run(String message) {
|
||||
LoginNotifyDTO loginNotify = JSON.parseObject(message, LoginNotifyDTO.class);
|
||||
boolean todayFirstLogin = onlineUserTodayCache.addOnlineUserId(loginNotify.getUserId());
|
||||
// 上线通知
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonConsumerEnum getType() {
|
||||
return CommonConsumerEnum.LOGIN;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.ruoyi.cai.mq.handle;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.cai.mq.dto.CommonConsumerEnum;
|
||||
import com.ruoyi.cai.mq.handle.dto.RankDTO;
|
||||
import com.ruoyi.cai.mq.handle.dto.RankNotifyDTO;
|
||||
import com.ruoyi.cai.rank.RankManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -10,13 +10,13 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RankHandle implements IHandle {
|
||||
public class RankNotifyHandle implements IHandle {
|
||||
|
||||
@Autowired
|
||||
private RankManager rankManager;
|
||||
@Override
|
||||
public void run(String message) {
|
||||
RankDTO rank = JSON.parseObject(message, RankDTO.class);
|
||||
RankNotifyDTO rank = JSON.parseObject(message, RankNotifyDTO.class);
|
||||
rankManager.addRank(rank);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.ruoyi.cai.mq.handle;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.cai.mq.dto.CommonConsumerEnum;
|
||||
import com.ruoyi.cai.mq.handle.dto.SysPushDTO;
|
||||
import com.ruoyi.cai.mq.handle.dto.SysPushNotifyDTO;
|
||||
import com.ruoyi.cai.service.SysPushService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -10,14 +10,14 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SysPushHandle implements IHandle{
|
||||
public class SysPushNotifyHandle implements IHandle{
|
||||
@Autowired
|
||||
private SysPushService sysPushService;
|
||||
|
||||
@Override
|
||||
public void run(String message) {
|
||||
try {
|
||||
SysPushDTO sysPush = JSON.parseObject(message, SysPushDTO.class);
|
||||
SysPushNotifyDTO sysPush = JSON.parseObject(message, SysPushNotifyDTO.class);
|
||||
sysPushService.doRun(sysPush.getSysPushId());
|
||||
}catch (Exception e){
|
||||
log.error("处理推送消息失败!",e);
|
||||
@@ -5,12 +5,11 @@ import com.google.common.collect.Lists;
|
||||
import com.ruoyi.cai.domain.Gift;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.mq.dto.CommonConsumerEnum;
|
||||
import com.ruoyi.cai.mq.handle.dto.WindowGiftDTO;
|
||||
import com.ruoyi.cai.mq.handle.dto.WindowGiftNotifyDTO;
|
||||
import com.ruoyi.cai.notice.YunxinHttpService;
|
||||
import com.ruoyi.cai.notice.data.child.SendGiftWindowsAmountNoticeData;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import com.ruoyi.cai.util.CaiDateUtil;
|
||||
import com.ruoyi.framework.OnlineTodayCache;
|
||||
import com.ruoyi.framework.OnlineUserTodayCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -19,22 +18,22 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class WindowGiftHandle implements IHandle{
|
||||
public class WindowGiftNotifyHandle implements IHandle{
|
||||
|
||||
@Autowired
|
||||
private YunxinHttpService yunxinHttpService;
|
||||
@Autowired
|
||||
private OnlineTodayCache onlineTodayCache;
|
||||
private OnlineUserTodayCache onlineUserTodayCache;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void run(String message) {
|
||||
WindowGiftDTO windowGift = JSON.parseObject(message, WindowGiftDTO.class);
|
||||
WindowGiftNotifyDTO windowGift = JSON.parseObject(message, WindowGiftNotifyDTO.class);
|
||||
User fromUser = userService.getById(windowGift.getFromId());
|
||||
User toUser = userService.getById(windowGift.getToId());
|
||||
Gift gift = windowGift.getGift();
|
||||
Set<Long> userIds = onlineTodayCache.getAllOnlineToday();
|
||||
Set<Long> userIds = onlineUserTodayCache.getAllOnlineToday();
|
||||
List<Long> userIdList = new ArrayList<>(userIds);
|
||||
List<List<Long>> lists = Lists.partition(userIdList, 300);
|
||||
for (List<Long> list : lists) {
|
||||
@@ -3,9 +3,9 @@ package com.ruoyi.cai.mq.handle;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.ruoyi.cai.mq.dto.CommonConsumerEnum;
|
||||
import com.ruoyi.cai.mq.handle.dto.WindowRechargeDTO;
|
||||
import com.ruoyi.cai.mq.handle.dto.WindowRechargeNotifyDTO;
|
||||
import com.ruoyi.cai.notice.YunxinHttpService;
|
||||
import com.ruoyi.framework.OnlineTodayCache;
|
||||
import com.ruoyi.framework.OnlineUserTodayCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -14,17 +14,17 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class WindowRechargeHandle implements IHandle{
|
||||
public class WindowRechargeNotifyHandle implements IHandle{
|
||||
|
||||
@Autowired
|
||||
private YunxinHttpService yunxinHttpService;
|
||||
@Autowired
|
||||
private OnlineTodayCache onlineTodayCache;
|
||||
private OnlineUserTodayCache onlineUserTodayCache;
|
||||
|
||||
@Override
|
||||
public void run(String message) {
|
||||
WindowRechargeDTO windowRecharge = JSON.parseObject(message, WindowRechargeDTO.class);
|
||||
Set<Long> userIds = onlineTodayCache.getAllOnlineToday();
|
||||
WindowRechargeNotifyDTO windowRecharge = JSON.parseObject(message, WindowRechargeNotifyDTO.class);
|
||||
Set<Long> userIds = onlineUserTodayCache.getAllOnlineToday();
|
||||
List<Long> userIdList = new ArrayList<>(userIds);
|
||||
List<List<Long>> lists = Lists.partition(userIdList, 300);
|
||||
for (List<Long> list : lists) {
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.cai.mq.handle.dto;
|
||||
|
||||
import com.ruoyi.cai.mq.dto.CommonConsumerEnum;
|
||||
import com.ruoyi.cai.mq.dto.CommonDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class LoginNotifyDTO extends CommonDTO {
|
||||
private Long userId;
|
||||
|
||||
private LocalDateTime happenTime;
|
||||
|
||||
public LoginNotifyDTO() {
|
||||
this.setType(CommonConsumerEnum.LOGIN);
|
||||
this.happenTime = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RankDTO extends CommonDTO {
|
||||
public class RankNotifyDTO extends CommonDTO {
|
||||
|
||||
/**
|
||||
* 1-魅力榜
|
||||
@@ -20,7 +20,7 @@ public class RankDTO extends CommonDTO {
|
||||
private LocalDateTime happenTime;
|
||||
private Long traceId;
|
||||
|
||||
public RankDTO() {
|
||||
public RankNotifyDTO() {
|
||||
this.setType(CommonConsumerEnum.RANK);
|
||||
this.happenTime = LocalDateTime.now();
|
||||
}
|
||||
@@ -5,10 +5,10 @@ import com.ruoyi.cai.mq.dto.CommonDTO;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysPushDTO extends CommonDTO {
|
||||
public class SysPushNotifyDTO extends CommonDTO {
|
||||
private Long sysPushId;
|
||||
|
||||
public SysPushDTO() {
|
||||
public SysPushNotifyDTO() {
|
||||
this.setType(CommonConsumerEnum.SYS_PUSH);
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,14 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class WindowGiftDTO extends CommonDTO {
|
||||
public class WindowGiftNotifyDTO extends CommonDTO {
|
||||
private Long fromId;
|
||||
private Long toId;
|
||||
private Gift gift;
|
||||
private Long giftNum;
|
||||
private LocalDateTime time;
|
||||
|
||||
public WindowGiftDTO() {
|
||||
public WindowGiftNotifyDTO() {
|
||||
this.setType(CommonConsumerEnum.WINDOW_GIFT);
|
||||
this.time = LocalDateTime.now();
|
||||
}
|
||||
@@ -4,17 +4,16 @@ import com.ruoyi.cai.mq.dto.CommonConsumerEnum;
|
||||
import com.ruoyi.cai.mq.dto.CommonDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class WindowRechargeDTO extends CommonDTO {
|
||||
public class WindowRechargeNotifyDTO extends CommonDTO {
|
||||
private Long id;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
private Long amount;
|
||||
private LocalDateTime time;
|
||||
public WindowRechargeDTO() {
|
||||
public WindowRechargeNotifyDTO() {
|
||||
this.setType(CommonConsumerEnum.WINDOW_RECHARGE);
|
||||
this.time = LocalDateTime.now();
|
||||
}
|
||||
Reference in New Issue
Block a user