parent
102c9c4a38
commit
4deba9f86c
|
@ -1,28 +0,0 @@
|
||||||
listen 1935;
|
|
||||||
max_connections 1000;
|
|
||||||
daemon off;
|
|
||||||
http_api {
|
|
||||||
enabled on;
|
|
||||||
listen 1985;
|
|
||||||
}
|
|
||||||
http_server {
|
|
||||||
enabled on;
|
|
||||||
listen 8080;
|
|
||||||
}
|
|
||||||
vhost __defaultVhost__ {
|
|
||||||
hls {
|
|
||||||
enabled on;
|
|
||||||
hls_path ./objs/nginx/html;
|
|
||||||
hls_fragment 10;
|
|
||||||
hls_window 60;
|
|
||||||
}
|
|
||||||
http_remux {
|
|
||||||
enabled on;
|
|
||||||
mount [vhost]/[app]/[stream].flv;
|
|
||||||
}
|
|
||||||
dvr {
|
|
||||||
enabled on;
|
|
||||||
dvr_path ./recordings/[app]/[stream].flv;
|
|
||||||
dvr_plan session;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
version: '3'
|
|
||||||
services:
|
|
||||||
srs:
|
|
||||||
image: ossrs/srs:4
|
|
||||||
ports:
|
|
||||||
- "1935:1935" # RTMP
|
|
||||||
- "8080:8080" # HTTP-FLV
|
|
||||||
- "8088:8088" # HLS
|
|
||||||
volumes:
|
|
||||||
- ./conf/srs.conf:/usr/local/srs/conf/srs.conf
|
|
||||||
- ./recordings:/usr/local/srs/recordings
|
|
6
pom.xml
6
pom.xml
|
@ -304,7 +304,11 @@
|
||||||
<version>3.0.9</version>
|
<version>3.0.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Janino 依赖,用于 logback 条件判断 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.janino</groupId>
|
||||||
|
<artifactId>janino</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -49,23 +49,15 @@ public class OperationLogAspect {
|
||||||
SysLog sysLog = new SysLog();
|
SysLog sysLog = new SysLog();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 执行方法
|
|
||||||
Object result = point.proceed();
|
Object result = point.proceed();
|
||||||
// 设置状态为成功
|
|
||||||
sysLog.setStatus(1);
|
sysLog.setStatus(1);
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 记录异常信息
|
|
||||||
sysLog.setStatus(0);
|
sysLog.setStatus(0);
|
||||||
sysLog.setErrorMsg(e.getMessage());
|
sysLog.setErrorMsg(e.getMessage());
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
saveLog(point, operationLog, beginTime, sysLog);
|
||||||
// 记录日志
|
|
||||||
saveLog(point, operationLog, beginTime, sysLog);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("记录操作日志失败", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.guwan.backend.controller;
|
package com.guwan.backend.controller;
|
||||||
|
|
||||||
|
import com.guwan.backend.annotation.OperationLog;
|
||||||
import com.guwan.backend.common.Result;
|
import com.guwan.backend.common.Result;
|
||||||
import com.guwan.backend.entity.BookContent;
|
import com.guwan.backend.entity.BookContent;
|
||||||
import com.guwan.backend.mongodb.EveryReadDetailOfMongodb;
|
import com.guwan.backend.mongodb.EveryReadDetailOfMongodb;
|
||||||
|
@ -8,6 +9,7 @@ import com.guwan.backend.mongodb.User;
|
||||||
import com.guwan.backend.mongodb.MongodbUserService;
|
import com.guwan.backend.mongodb.MongodbUserService;
|
||||||
import com.guwan.backend.service.BookContentService;
|
import com.guwan.backend.service.BookContentService;
|
||||||
import com.guwan.backend.util.MinioUtil;
|
import com.guwan.backend.util.MinioUtil;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
@ -239,6 +241,7 @@ public class CommonController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getUserOneTotalTime")
|
@GetMapping("/getUserOneTotalTime")
|
||||||
|
@OperationLog(description = "统计用户某本书的读书时间")
|
||||||
public Result getUserOneTotalTime(@RequestParam Long userId){
|
public Result getUserOneTotalTime(@RequestParam Long userId){
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class EveryReadDetailOfMongodbServiceImpl extends ServiceImpl<EveryReadDetailOfMongodb> implements EveryReadDetailOfMongodbService {
|
public class EveryReadDetailOfMongodbServiceImpl extends ServiceImpl<EveryReadDetailOfMongodb> implements EveryReadDetailOfMongodbService {
|
||||||
|
@ -18,7 +20,7 @@ public class EveryReadDetailOfMongodbServiceImpl extends ServiceImpl<EveryReadDe
|
||||||
List<EveryReadDetailOfMongodb> list = this.list(new LambdaQueryChainWrapper<>(this.getBaseMapper(), EveryReadDetailOfMongodb.class)
|
List<EveryReadDetailOfMongodb> list = this.list(new LambdaQueryChainWrapper<>(this.getBaseMapper(), EveryReadDetailOfMongodb.class)
|
||||||
.eq(EveryReadDetailOfMongodb::getUserId, userId));
|
.eq(EveryReadDetailOfMongodb::getUserId, userId));
|
||||||
|
|
||||||
log.debug("list: {}", list);
|
log.info("list: {}", list);
|
||||||
|
|
||||||
Long total = 0L;
|
Long total = 0L;
|
||||||
for (EveryReadDetailOfMongodb everyReadDetailOfMongodb : list) {
|
for (EveryReadDetailOfMongodb everyReadDetailOfMongodb : list) {
|
||||||
|
@ -31,4 +33,5 @@ public class EveryReadDetailOfMongodbServiceImpl extends ServiceImpl<EveryReadDe
|
||||||
return total;
|
return total;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -67,6 +67,9 @@ spring:
|
||||||
exclude:
|
exclude:
|
||||||
- org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration
|
- org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration
|
||||||
|
|
||||||
|
profiles:
|
||||||
|
active: dev # 确保使用开发环境配置
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# MyBatis-Plus配置
|
# MyBatis-Plus配置
|
||||||
|
@ -188,4 +191,22 @@ mongo-plus:
|
||||||
authenticationDatabase: admin #验证数据库
|
authenticationDatabase: admin #验证数据库
|
||||||
connectTimeoutMS: 50000 #在超时之前等待连接打开的最长时间(以毫秒为单位)
|
connectTimeoutMS: 50000 #在超时之前等待连接打开的最长时间(以毫秒为单位)
|
||||||
|
|
||||||
|
# 已有配置...
|
||||||
|
|
||||||
|
# 日志配置
|
||||||
|
logging:
|
||||||
|
# 日志文件路径
|
||||||
|
file:
|
||||||
|
path: logs
|
||||||
|
name: logs/backend.log
|
||||||
|
enabled: true # 添加这个配置来控制是否写入文件
|
||||||
|
# 日志级别配置
|
||||||
|
level:
|
||||||
|
root: INFO
|
||||||
|
com.guwan.backend: DEBUG
|
||||||
|
org.springframework.web: INFO
|
||||||
|
org.hibernate: ERROR
|
||||||
|
# 日志格式配置
|
||||||
|
pattern:
|
||||||
|
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"
|
||||||
|
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"
|
||||||
|
|
|
@ -20,22 +20,16 @@ CREATE TABLE IF NOT EXISTS `user` (
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `sys_log` (
|
CREATE TABLE IF NOT EXISTS `sys_log` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '日志ID',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '日志ID',
|
||||||
`user_id` bigint DEFAULT NULL COMMENT '用户ID',
|
`user_id` bigint DEFAULT NULL COMMENT '用户ID',
|
||||||
`username` varchar(50) DEFAULT NULL COMMENT '用户名',
|
`username` varchar(50) DEFAULT NULL COMMENT '用户名',
|
||||||
`operation` varchar(50) DEFAULT NULL COMMENT '操作',
|
`operation` varchar(50) DEFAULT NULL COMMENT '操作',
|
||||||
`method` varchar(200) DEFAULT NULL COMMENT '方法名',
|
`method` varchar(200) DEFAULT NULL COMMENT '方法名',
|
||||||
`params` varchar(2000) DEFAULT NULL COMMENT '参数',
|
`params` varchar(2000) DEFAULT NULL COMMENT '参数',
|
||||||
`ip` varchar(64) DEFAULT NULL COMMENT 'IP地址',
|
`ip` varchar(64) DEFAULT NULL COMMENT 'IP地址',
|
||||||
`location` varchar(255) DEFAULT NULL COMMENT '操作地点',
|
`time_consuming` bigint DEFAULT NULL COMMENT '耗时(毫秒)',
|
||||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
`status` tinyint DEFAULT NULL COMMENT '状态(1-成功,0-失败)',
|
||||||
`time_consuming` bigint DEFAULT NULL COMMENT '耗时(毫秒)',
|
`error_msg` varchar(2000) DEFAULT NULL COMMENT '错误信息'
|
||||||
`user_agent` varchar(500) DEFAULT NULL COMMENT '用户代理',
|
|
||||||
`status` tinyint DEFAULT NULL COMMENT '状态(1-成功,0-失败)',
|
|
||||||
`error_msg` varchar(2000) DEFAULT NULL COMMENT '错误信息',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_user_id` (`user_id`),
|
|
||||||
KEY `idx_create_time` (`create_time`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统操作日志';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统操作日志';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<!-- 引入Spring Boot默认的日志配置 -->
|
||||||
|
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||||
|
|
||||||
|
<!-- 从application.yml中读取配置 -->
|
||||||
|
<springProperty scope="context" name="LOG_FILE_ENABLED" source="logging.file.enabled"/>
|
||||||
|
|
||||||
|
<!-- 定义变量 -->
|
||||||
|
<property name="LOG_PATH" value="logs"/>
|
||||||
|
<property name="LOG_FILE" value="${LOG_PATH}/backend.log"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 文件输出 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${LOG_FILE}</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_PATH}/backend.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 异步写入文件 -->
|
||||||
|
<appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
|
<discardingThreshold>0</discardingThreshold>
|
||||||
|
<queueSize>512</queueSize>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 开发环境 -->
|
||||||
|
<springProfile name="dev">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
<if condition='property("LOG_FILE_ENABLED").equals("true")'>
|
||||||
|
<then>
|
||||||
|
<appender-ref ref="ASYNC_FILE"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
</root>
|
||||||
|
<logger name="com.guwan.backend" level="DEBUG"/>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<!-- 生产环境 -->
|
||||||
|
<springProfile name="prod">
|
||||||
|
<root level="INFO">
|
||||||
|
<if condition='property("LOG_FILE_ENABLED").equals("true")'>
|
||||||
|
<then>
|
||||||
|
<appender-ref ref="ASYNC_FILE"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
</root>
|
||||||
|
<logger name="com.guwan.backend" level="INFO"/>
|
||||||
|
</springProfile>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue