|
@@ -1,10 +1,9 @@
|
|
-package com.xy.consumer.log;
|
|
|
|
|
|
+package com.xy.service;
|
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
-import com.xy.annotate.MqttConsumerAsyn;
|
|
|
|
import com.xy.config.SysThreadPoolConfig;
|
|
import com.xy.config.SysThreadPoolConfig;
|
|
-import com.xy.consumer.MqttConsumer;
|
|
|
|
|
|
+import com.xy.dto.SysMqttDto;
|
|
import com.xy.entity.LogOperate;
|
|
import com.xy.entity.LogOperate;
|
|
import com.xy.entity.LogSysEvents;
|
|
import com.xy.entity.LogSysEvents;
|
|
import com.xy.entity.LogTasks;
|
|
import com.xy.entity.LogTasks;
|
|
@@ -12,26 +11,28 @@ import com.xy.mapper.LogOperateMapper;
|
|
import com.xy.mapper.LogSysEventsMapper;
|
|
import com.xy.mapper.LogSysEventsMapper;
|
|
import com.xy.mapper.LogTasksMapper;
|
|
import com.xy.mapper.LogTasksMapper;
|
|
import com.xy.utils.LambdaUtils;
|
|
import com.xy.utils.LambdaUtils;
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-/**
|
|
|
|
- * 日志消费者
|
|
|
|
- */
|
|
|
|
@Service
|
|
@Service
|
|
-@RequiredArgsConstructor
|
|
|
|
-@MqttConsumerAsyn(value = SysThreadPoolConfig.LOG_POLL, isFailSaveEs = false)
|
|
|
|
-public class LogConsumer implements MqttConsumer {
|
|
|
|
|
|
+@AllArgsConstructor
|
|
|
|
+@Api(tags = "系统消费者")
|
|
|
|
+public class SysMqttConsumerImpl implements SysMqttConsumer {
|
|
|
|
|
|
- private final LogOperateMapper logOperateMapper;
|
|
|
|
|
|
+ private LogOperateMapper logOperateMapper;
|
|
|
|
|
|
- private final LogSysEventsMapper logSysEventsMapper;
|
|
|
|
|
|
+ private LogSysEventsMapper logSysEventsMapper;
|
|
|
|
|
|
- private final LogTasksMapper logTasksMapper;
|
|
|
|
|
|
+ private LogTasksMapper logTasksMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean message(String topic, String payload) {
|
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(payload);
|
|
|
|
|
|
+ @ApiOperation("日志")
|
|
|
|
+ @Async(SysThreadPoolConfig.LOG_POLL)
|
|
|
|
+ public void logs(SysMqttDto.RequestParams requestParams) {
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(requestParams.getData());
|
|
String type = jsonObject.getStr(LambdaUtils.getProperty(LogOperate::getType));
|
|
String type = jsonObject.getStr(LambdaUtils.getProperty(LogOperate::getType));
|
|
if ("operate".equals(type)) {
|
|
if ("operate".equals(type)) {
|
|
logOperateMapper.insert(jsonObject.toBean(LogOperate.class));
|
|
logOperateMapper.insert(jsonObject.toBean(LogOperate.class));
|
|
@@ -42,6 +43,5 @@ public class LogConsumer implements MqttConsumer {
|
|
if ("tasks".equals(type)) {
|
|
if ("tasks".equals(type)) {
|
|
logTasksMapper.insert(jsonObject.toBean(LogTasks.class));
|
|
logTasksMapper.insert(jsonObject.toBean(LogTasks.class));
|
|
}
|
|
}
|
|
- return true;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|