feat(mq): 添加日志消息处理功能
- 在BusinessTopic中新增ZL_LOG_TOPIC常量 - 添加LogTag接口用于日志标签定义 - 创建LogMessage类定义日志消息结构 - 实现LogMessageTemplate用于发送日志消息 - 集成RocketMQ增强模板支持日志消息发送 - 定义日志消息的数据类型和操作字段
This commit is contained in:
@@ -110,6 +110,8 @@ public interface BusinessTopic {
|
||||
|
||||
String CLOUD_REPLY_TOPIC = "Cloud_Reply_Topic";
|
||||
|
||||
String ZL_LOG_TOPIC = "ZL_LOG_Topic";
|
||||
|
||||
|
||||
interface AppDataTag {
|
||||
|
||||
@@ -166,4 +168,10 @@ public interface BusinessTopic {
|
||||
String CLD_TAG = "cld";
|
||||
}
|
||||
|
||||
interface LogTag {
|
||||
|
||||
//日志
|
||||
String LOG_TAG = "log";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.njcn.mq.message;
|
||||
|
||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2025/9/29 15:06
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LogMessage extends BaseMessage {
|
||||
|
||||
@ApiModelProperty("唯一标识")
|
||||
private String guid;
|
||||
|
||||
@ApiModelProperty("日志类型 0:设备接入日志")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("操作人员")
|
||||
private String userIndex;
|
||||
|
||||
@ApiModelProperty("用户登录名")
|
||||
private String loginName;
|
||||
|
||||
@ApiModelProperty("当前操作")
|
||||
private String operate;
|
||||
|
||||
@ApiModelProperty("结果")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty("失败原因")
|
||||
private String failReason;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.mq.template;
|
||||
|
||||
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
|
||||
import com.njcn.mq.constant.BusinessResource;
|
||||
import com.njcn.mq.constant.BusinessTopic;
|
||||
import com.njcn.mq.message.LogMessage;
|
||||
import org.apache.rocketmq.client.producer.SendResult;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:记录日志
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
*/
|
||||
@Component
|
||||
public class LogMessageTemplate extends RocketMQEnhanceTemplate {
|
||||
|
||||
public LogMessageTemplate(RocketMQTemplate template) {
|
||||
super(template);
|
||||
}
|
||||
|
||||
public SendResult sendMember(LogMessage logMessage) {
|
||||
logMessage.setSource(BusinessResource.APP_RESOURCE);
|
||||
return send(BusinessTopic.ZL_LOG_TOPIC, BusinessTopic.LogTag.LOG_TAG, logMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user