feat(count): 实现关注与粉丝数统计功能

- 新增关注数与粉丝数 MQ 消费者
- 在用户关系服务中新增关注/取关时发送 MQ 消息逻辑
- 新增关注/取关类型枚举类
- 新增用于统计的 MQ 常量定义
- 调整应用主类包路径以符合项目结构(致命,查半天)
- 移除配置文件中不再使用的 MQ 消费者限流配置项
This commit is contained in:
2025-10-15 22:25:59 +08:00
parent e17ab857b9
commit 31ab7c3d86
9 changed files with 181 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
package com.hanserwei.hannote.count.biz.domain;
package com.hanserwei.hannote.count.biz;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;

View File

@@ -0,0 +1,15 @@
package com.hanserwei.hannote.count.biz.constant;
public interface MQConstants {
/**
* Topic: 关注数计数
*/
String TOPIC_COUNT_FOLLOWING = "CountFollowingTopic";
/**
* Topic: 粉丝数计数
*/
String TOPIC_COUNT_FANS = "CountFansTopic";
}

View File

@@ -0,0 +1,20 @@
package com.hanserwei.hannote.count.biz.consumer;
import com.hanserwei.hannote.count.biz.constant.MQConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
@Component
@RocketMQMessageListener(
consumerGroup = "han_note_group_" + MQConstants.TOPIC_COUNT_FANS,
topic = MQConstants.TOPIC_COUNT_FANS
)
@Slf4j
public class CountFansConsumer implements RocketMQListener<String> {
@Override
public void onMessage(String body) {
log.info("## 消费了 MQ [计数:粉丝数]: {}", body);
}
}

View File

@@ -0,0 +1,20 @@
package com.hanserwei.hannote.count.biz.consumer;
import com.hanserwei.hannote.count.biz.constant.MQConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
@Component
@RocketMQMessageListener(
consumerGroup = "han_note_group_" + MQConstants.TOPIC_COUNT_FOLLOWING,
topic = MQConstants.TOPIC_COUNT_FOLLOWING
)
@Slf4j
public class CountFollowingConsumer implements RocketMQListener<String> {
@Override
public void onMessage(String body) {
log.info("## 消费了 MQ [计数:关注数]: {}", body);
}
}

View File

@@ -28,7 +28,4 @@ mybatis-plus:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
global-config:
banner: false
mapper-locations: classpath*:/mapperxml/*.xml
mq-consumer: # MQ 消费者
follow-unfollow: # 关注、取关
rate-limit: 5000 # 每秒限流阈值
mapper-locations: classpath*:/mapperxml/*.xml