Commit 3a380c87 authored by 赵啸非's avatar 赵啸非

业务日志添加

parent 22775c20
...@@ -27,15 +27,15 @@ ...@@ -27,15 +27,15 @@
<![CDATA[jdbc:mysql://localhost:3306/log-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri> <![CDATA[jdbc:mysql://localhost:3306/log-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username> <profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>12345678</profiles.datasource.password> <profiles.datasource.password>12345678</profiles.datasource.password>
<profiles.redis.uri>192.168.0.252</profiles.redis.uri> <profiles.redis.uri>127.0.0.1</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port> <profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username> <profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password> <profiles.redis.password></profiles.redis.password>
<profiles.redis.database>8</profiles.redis.database> <profiles.redis.database>8</profiles.redis.database>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host> <profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username> <profiles.rabbitmq.username>guest</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password> <profiles.rabbitmq.password>guest</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost> <profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.exchange></profiles.rabbitmq.exchange> <profiles.rabbitmq.exchange></profiles.rabbitmq.exchange>
<profiles.filepath>/mortals/data</profiles.filepath> <profiles.filepath>/mortals/data</profiles.filepath>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<profiles.log.path>/logs</profiles.log.path> <profiles.log.path>/logs</profiles.log.path>
<profiles.data.path>/data</profiles.data.path> <profiles.data.path>/data</profiles.data.path>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
</properties> </properties>
......
package com.mortals.xhx.base.framework.listener; package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.key.QueueKey; import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.module.access.model.AccessLogEntity; import com.mortals.xhx.module.access.model.AccessLogEntity;
...@@ -37,6 +38,7 @@ public class BizMessageConsumerListener { ...@@ -37,6 +38,7 @@ public class BizMessageConsumerListener {
log.info("[Biz onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName()+Thread.currentThread().getId(), messages.size()); log.info("[Biz onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName()+Thread.currentThread().getId(), messages.size());
List<BizLogEntity> collect = messages.stream().map(str -> { List<BizLogEntity> collect = messages.stream().map(str -> {
BizLogEntity entity = JSON.parseObject(str, BizLogEntity.class); BizLogEntity entity = JSON.parseObject(str, BizLogEntity.class);
entity.setId(IdUtil.getSnowflake(0, 1).nextId());
entity.setCreateUserId(1L); entity.setCreateUserId(1L);
entity.setCreateTime(new Date()); entity.setCreateTime(new Date());
return entity; return entity;
......
package com.mortals.xhx.module.operate.service.impl; package com.mortals.xhx.module.operate.service.impl;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import com.mortals.xhx.module.error.model.ErrorLogEntity; import com.mortals.xhx.module.error.model.ErrorLogEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
...@@ -22,4 +23,9 @@ import java.util.Date; ...@@ -22,4 +23,9 @@ import java.util.Date;
@Service("operateLogService") @Service("operateLogService")
public class OperateLogServiceImpl extends AbstractCRUDServiceImpl<OperateLogDao, OperateLogEntity, Long> implements OperateLogService { public class OperateLogServiceImpl extends AbstractCRUDServiceImpl<OperateLogDao, OperateLogEntity, Long> implements OperateLogService {
public static void main(String[] args) {
System.out.println(RandomUtil.randomString(1024));
}
} }
\ No newline at end of file
...@@ -21,7 +21,7 @@ spring: ...@@ -21,7 +21,7 @@ spring:
host: @profiles.redis.uri@ host: @profiles.redis.uri@
port: @profiles.redis.port@ port: @profiles.redis.port@
username: @profiles.redis.username@ username: @profiles.redis.username@
password: @profiles.redis.password@ # password: @profiles.redis.password@
database: @profiles.redis.database@ database: @profiles.redis.database@
timeout: 30000 timeout: 30000
pool: pool:
......
...@@ -85,20 +85,20 @@ ...@@ -85,20 +85,20 @@
</trim> </trim>
</sql> </sql>
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="BizLogEntity" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="BizLogEntity" >
insert into `${tableName}` insert into `${tableName}`
(traceID,appName,hostName,logLevel,userCode,deviceCode,eventTopic,eventTopicName,msg,logTime,createUserId,createTime) (id,traceID,appName,hostName,logLevel,userCode,deviceCode,eventTopic,eventTopicName,msg,logTime,createUserId,createTime)
VALUES VALUES
(#{traceID},#{appName},#{hostName},#{logLevel},#{userCode},#{deviceCode},#{eventTopic},#{eventTopicName},#{msg},#{logTime},#{createUserId},#{createTime}) (#{id},#{traceID},#{appName},#{hostName},#{logLevel},#{userCode},#{deviceCode},#{eventTopic},#{eventTopicName},#{msg},#{logTime},#{createUserId},#{createTime})
</insert> </insert>
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into `${tableName}` insert into `${tableName}`
(traceID,appName,hostName,logLevel,userCode,deviceCode,eventTopic,eventTopicName,msg,logTime,createUserId,createTime) (id,traceID,appName,hostName,logLevel,userCode,deviceCode,eventTopic,eventTopicName,msg,logTime,createUserId,createTime)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.traceID},#{item.appName},#{item.hostName},#{item.logLevel},#{item.userCode},#{item.deviceCode},#{item.eventTopic},#{item.eventTopicName},#{item.msg},#{item.logTime},#{item.createUserId},#{item.createTime}) (#{item.id},#{item.traceID},#{item.appName},#{item.hostName},#{item.logLevel},#{item.userCode},#{item.deviceCode},#{item.eventTopic},#{item.eventTopicName},#{item.msg},#{item.logTime},#{item.createUserId},#{item.createTime})
</foreach> </foreach>
</insert> </insert>
......
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