审计日志相关代码提交
This commit is contained in:
@@ -68,4 +68,5 @@ public class UserLog extends BaseEntity {
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -49,11 +49,8 @@ public class UserLogController extends BaseController {
|
||||
@ApiImplicitParam(name = "logInfoDTO", value = "插入日志参数", required = true)
|
||||
public HttpResult addUserLog(@RequestBody LogInfoDTO logInfoDTO) {
|
||||
String methodDescribe = getMethodDescribe("addUserLog");
|
||||
boolean res = userLogService.addUserLog(logInfoDTO);
|
||||
if (res) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,null,methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL,null,methodDescribe);
|
||||
userLogService.addUserLog(logInfoDTO);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.system.handler;
|
||||
|
||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.system.service.IUserLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年07月13日 13:35
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MqttMessageHandler {
|
||||
|
||||
private final IUserLogService userLogService;
|
||||
|
||||
/**
|
||||
* 订阅审计日志的记录,并进行入库操作
|
||||
*/
|
||||
@MqttSubscribe(value = "/userLog")
|
||||
public void subUserLog(String topic, MqttMessage message, @Payload String payload) {
|
||||
LogInfoDTO logInfoDTO = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8),LogInfoDTO.class);
|
||||
userLogService.addUserLog(logInfoDTO);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @server.url@
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
@@ -47,3 +47,10 @@ logging:
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.system.pojo
|
||||
|
||||
|
||||
mqtt:
|
||||
uri: tcp://@middle.server.url@:1883
|
||||
client-id: @artifactId@
|
||||
username: t_user
|
||||
password: njcnpqs
|
||||
Reference in New Issue
Block a user