Commit fadd6155 authored by 赵啸非's avatar 赵啸非

添加操作日志发送到管理平台

parent e068c386
......@@ -53,7 +53,16 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
......
package com.mortals.xhx.common.keys;
/**
* rabbit 队列key定义
*/
public class QueueKey {
public static final String ACCESS_LOG_QUEUE = "ACCESS_LOG_QUEUE";
public static final String BIZ_LOG_QUEUE = "BIZ_LOG_QUEUE";
public static final String ERROR_LOG_QUEUE = "ERROR_LOG_QUEUE";
public static final String OPERATION_LOG_QUEUE = "OPERATION_LOG_QUEUE";
public static final String EXCHANGE = "LOG";
public static final String ROUTING_KEY = "LOG_ROUTING_KEY";
}
package com.mortals.xhx.system;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.model.AccessLogPdu;
import com.mortals.framework.model.BizLogPdu;
import com.mortals.framework.model.ErrorLogPdu;
import com.mortals.framework.model.OperateLogPdu;
import com.mortals.framework.service.IMessageProduceService;
import com.mortals.xhx.common.keys.QueueKey;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
@Component
@Primary
@Slf4j
public class MessageProducer implements IMessageProduceService {
@Autowired
private RabbitTemplate rabbitTemplate;
public void syncAccessSend(AccessLogPdu accessLogPdu) {
//new Message(JSON.toJSONString(accessLogPdu).getBytes(StandardCharsets.UTF_8))
//rabbitTemplate.send(QueueKey.EXCHANGE, QueueKey.ACCESS_LOG_QUEUE,new Message(JSON.toJSONString(accessLogPdu).getBytes(StandardCharsets.UTF_8)));
rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.ACCESS_LOG_QUEUE, JSON.toJSONString(accessLogPdu));
//rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.ACCESS_LOG_QUEUE, accessLogPdu);
}
@Override
public void syncBizSend(BizLogPdu bizLogPdu) {
rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.BIZ_LOG_QUEUE, JSON.toJSONString(bizLogPdu));
}
@Override
public void syncErrorSend(ErrorLogPdu errorLogPdu) {
rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.ERROR_LOG_QUEUE, JSON.toJSONString(errorLogPdu));
}
@Override
public void syncOperSend(OperateLogPdu operLogPdu) {
rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.OPERATION_LOG_QUEUE, JSON.toJSONString(operLogPdu));
}
}
......@@ -51,6 +51,11 @@
<![CDATA[jdbc:mysql://192.168.0.98:3306/datav_platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>nacos@2020</profiles.datasource.password>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost>
<profiles.redis.uri>192.168.0.252</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
......@@ -92,6 +97,11 @@
<![CDATA[jdbc:mysql://172.15.28.121:3306/datav_platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>xhx@2022</profiles.datasource.password>
<profiles.rabbitmq.host>172.15.28.115</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost>
<profiles.redis.uri>172.15.28.120</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
......
......@@ -4,6 +4,8 @@ import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import com.mortals.framework.model.OperateLogPdu;
import com.mortals.framework.service.IMessageProduceService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
......@@ -27,15 +29,30 @@ import com.mortals.xhx.base.system.oper.service.OperLogService;
public class OperlogAspect extends FileLogServiceImpl implements ILogService {
private final static Logger logger = LoggerFactory.getLogger(OperlogAspect.class);
@Autowired
private OperLogService operLogService;
@Autowired
private IMessageProduceService messageProducer;
@Override
public void doHandlerLog(String platformMark, Long userId, String userName, String loginName, String requestUrl,
String content, String ip, Date logDate) {
super.doHandlerLog(platformMark, userId, userName, loginName, requestUrl, content, ip, logDate);
operLogService.insertOperLog(ip, requestUrl, userId, userName, loginName, content);
OperateLogPdu operateLogPdu = new OperateLogPdu();
operateLogPdu.initAttrValue();
operateLogPdu.setIp(ip);
operateLogPdu.setRequestUrl(requestUrl);
operateLogPdu.setUserId(userId);
operateLogPdu.setUserName(userName);
operateLogPdu.setLoginName(loginName);
operateLogPdu.setPlatformMark(platformMark);
operateLogPdu.setLogDate(logDate);
operateLogPdu.setContent(content);
operateLogPdu.setOperType(1);
messageProducer.syncOperSend(operateLogPdu);
}
@Override
......
......@@ -16,6 +16,12 @@ spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
rabbitmq:
host: @profiles.rabbitmq.host@
port: @profiles.rabbitmq.port@
username: @profiles.rabbitmq.username@
password: @profiles.rabbitmq.password@
virtualHost: @profiles.rabbitmq.virtualhost@
security:
enable: true
user:
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>com.mortals</groupId>
<artifactId>mortals-common</artifactId>
<version>1.1.5-SNAPSHOT</version>
<version>1.1.7-SNAPSHOT</version>
</parent>
<groupId>com.mortals.xhx</groupId>
<artifactId>datav_platform</artifactId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment