feat:依赖修复,完善core和mybatis还有log模块,log模块待完成
This commit is contained in:
6
.idea/CoolRequestCommonStatePersistent.xml
generated
Normal file
6
.idea/CoolRequestCommonStatePersistent.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CoolRequestCommonStatePersistent">
|
||||||
|
<option name="searchCache" value="/*" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
5
.idea/encodings.xml
generated
5
.idea/encodings.xml
generated
@@ -9,6 +9,7 @@
|
|||||||
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-bom/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-bom/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-bom/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-bom/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-core/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-core/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-feign/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-log/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-log/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-mybatis/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-mybatis/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-starter/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/aioj-backend-common/aioj-backend-common-starter/src/main/java" charset="UTF-8" />
|
||||||
@@ -32,7 +33,7 @@
|
|||||||
<file url="file://$PROJECT_DIR$/aioj-backend-user-service/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/aioj-backend-user-service/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/../../../../../Windows/System32/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/../../../../Windows/System32/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/../../../../../Windows/System32/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/../../../../Windows/System32/src/main/resources" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -18,10 +18,19 @@
|
|||||||
<mybatis-plus.version>3.5.14</mybatis-plus.version>
|
<mybatis-plus.version>3.5.14</mybatis-plus.version>
|
||||||
<spring-boot.version>3.5.7</spring-boot.version>
|
<spring-boot.version>3.5.7</spring-boot.version>
|
||||||
<spring-cloud-alibaba.version>2025.0.0.0</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2025.0.0.0</spring-cloud-alibaba.version>
|
||||||
<mysql.version>9.5.0</mysql.version>
|
<mysql.version>9.4.0</mysql.version>
|
||||||
|
<jackson.bom>3.0.2</jackson.bom>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/tools.jackson/jackson-bom -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>tools.jackson</groupId>
|
||||||
|
<artifactId>jackson-bom</artifactId>
|
||||||
|
<version>${jackson.bom}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-bom -->
|
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-bom -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
@@ -72,7 +81,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-test</artifactId>
|
<artifactId>spring-security-test</artifactId>
|
||||||
<version>6.5.7</version>
|
<version>6.5.6</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -82,6 +91,7 @@
|
|||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
<version>3.5.7</version>
|
<version>3.5.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
</project>
|
</project>
|
||||||
@@ -26,5 +26,29 @@
|
|||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-core</artifactId>
|
<artifactId>hutool-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-extra</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-http</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<!--json模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-json</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--hibernate-validator-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package cn.meowrain.aioj.backend.framework.core.banner;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class BannerApplicationRunner implements ApplicationRunner {
|
||||||
|
private final Environment env;
|
||||||
|
@Value("${spring.application.name:unknown}")
|
||||||
|
private String appName;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
// Active profiles
|
||||||
|
String profiles = String.join(",", env.getActiveProfiles());
|
||||||
|
if (profiles.isEmpty()) {
|
||||||
|
profiles = "default";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Port
|
||||||
|
String port = env.getProperty("server.port", "unknown");
|
||||||
|
|
||||||
|
// JVM info
|
||||||
|
String jvm = System.getProperty("java.version") + " (" + System.getProperty("java.vendor") + ")";
|
||||||
|
|
||||||
|
// PID
|
||||||
|
String pid = ManagementFactory.getRuntimeMXBean().getPid() + "";
|
||||||
|
|
||||||
|
// Time
|
||||||
|
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
|
||||||
|
// Git commit id (如果没有 git.properties,不会报错)
|
||||||
|
String gitCommit = env.getProperty("git.commit.id.abbrev", "N/A");
|
||||||
|
|
||||||
|
printBanner(appName, profiles, port, jvm, pid, time, gitCommit);
|
||||||
|
}
|
||||||
|
private void printBanner(String appName, String profiles, String port, String jvm, String pid, String time,
|
||||||
|
String gitCommit) {
|
||||||
|
|
||||||
|
String banner = "\n" + "------------------------------------------------------------\n"
|
||||||
|
+ " ✨AI Online Judge✨ - " + appName + "\n" + " Environment : " + profiles + "\n" + " Port : "
|
||||||
|
+ port + "\n" + " Git Commit : " + gitCommit + "\n" + " JVM : " + jvm + "\n"
|
||||||
|
+ " PID : " + pid + "\n" + " Started At : " + time + "\n"
|
||||||
|
+ "------------------------------------------------------------\n";
|
||||||
|
System.out.println(banner);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Deprecated
|
||||||
public class EnvironmentBanner implements ApplicationListener<ApplicationReadyEvent> {
|
public class EnvironmentBanner implements ApplicationListener<ApplicationReadyEvent> {
|
||||||
|
|
||||||
@Value("${spring.application.name:unknown}")
|
@Value("${spring.application.name:unknown}")
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package cn.meowrain.aioj.backend.framework.core.banner.config;
|
||||||
|
|
||||||
|
import cn.meowrain.aioj.backend.framework.core.banner.BannerApplicationRunner;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
|
@AutoConfiguration
|
||||||
|
public class AIOJBannerAutoConfiguration {
|
||||||
|
@Bean
|
||||||
|
public BannerApplicationRunner bannerApplicationRunner(Environment env) {
|
||||||
|
return new BannerApplicationRunner(env);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package cn.meowrain.aioj.backend.framework.core.config;
|
package cn.meowrain.aioj.backend.framework.core.config;
|
||||||
|
|
||||||
import cn.meowrain.aioj.backend.framework.core.exception.handler.GlobalExceptionHandler;
|
import cn.meowrain.aioj.backend.framework.core.exception.handler.GlobalExceptionHandler;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册为bean,全局异常拦截器
|
* 注册为bean,全局异常拦截器
|
||||||
*/
|
*/
|
||||||
|
@AutoConfiguration
|
||||||
public class WebAutoConfiguration {
|
public class WebAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package cn.meowrain.aioj.backend.framework.core.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局服务名称
|
||||||
|
*/
|
||||||
|
public class ServiceNameConstants {
|
||||||
|
/**
|
||||||
|
* 用户服务 SERVICE NAME
|
||||||
|
*/
|
||||||
|
public static final String USER_SERVICE = "user-service";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 认证服务 SERVICE NAME
|
||||||
|
*/
|
||||||
|
public static final String AUTH_SERVICE = "auth-service";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UPMS模块
|
||||||
|
*/
|
||||||
|
public static final String UPMS_SERVICE = "upms-service";
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package cn.meowrain.aioj.backend.framework.core.jackson;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.PackageVersion;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.deser.*;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.*;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.time.*;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
|
||||||
|
public class JavaTimeModule extends SimpleModule {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JavaTimeModule构造函数,用于初始化时间序列化和反序列化规则
|
||||||
|
*/
|
||||||
|
public JavaTimeModule() {
|
||||||
|
super(PackageVersion.VERSION);
|
||||||
|
|
||||||
|
// ======================= 时间序列化规则 ===============================
|
||||||
|
// yyyy-MM-dd HH:mm:ss
|
||||||
|
this.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DatePattern.NORM_DATETIME_FORMATTER));
|
||||||
|
// yyyy-MM-dd
|
||||||
|
this.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
// HH:mm:ss
|
||||||
|
this.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ISO_LOCAL_TIME));
|
||||||
|
// Instant 类型序列化
|
||||||
|
this.addSerializer(Instant.class, InstantSerializer.INSTANCE);
|
||||||
|
// Duration 类型序列化
|
||||||
|
this.addSerializer(Duration.class, DurationSerializer.INSTANCE);
|
||||||
|
|
||||||
|
// ======================= 时间反序列化规则 ==============================
|
||||||
|
// yyyy-MM-dd HH:mm:ss
|
||||||
|
this.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DatePattern.NORM_DATETIME_FORMATTER));
|
||||||
|
// yyyy-MM-dd
|
||||||
|
this.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
// HH:mm:ss
|
||||||
|
this.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ISO_LOCAL_TIME));
|
||||||
|
// Instant 反序列化
|
||||||
|
this.addDeserializer(Instant.class, InstantDeserializer.INSTANT);
|
||||||
|
// Duration 反序列化
|
||||||
|
this.addDeserializer(Duration.class, DurationDeserializer.INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
cn.meowrain.aioj.backend.framework.core.banner.config.AIOJBannerAutoConfiguration
|
||||||
|
cn.meowrain.aioj.backend.framework.core.config.WebAutoConfiguration
|
||||||
60
aioj-backend-common/aioj-backend-common-feign/pom.xml
Normal file
60
aioj-backend-common/aioj-backend-common-feign/pom.xml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>aioj-backend-common-feign</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-common-core</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--feign 依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- okhttp 扩展 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.openfeign</groupId>
|
||||||
|
<artifactId>feign-okhttp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- LB 扩展 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--caffeine 替换LB 默认缓存实现-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||||
|
<artifactId>caffeine</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--oauth server 依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 异常枚举 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webmvc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package cn.meowrain.aioj.backend.framework.feign;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
|
||||||
|
@AutoConfiguration
|
||||||
|
public class FeignAutoConfiguration {
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.meowrain.aioj.backend.framework.feign.annotation;
|
||||||
|
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@EnableFeignClients
|
||||||
|
public @interface EnableAIOJFeignClients {
|
||||||
|
String[] basePackages() default {};
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package cn.meowrain.aioj.backend.framework.feign.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务无token调用声明注解
|
||||||
|
* <p>
|
||||||
|
* 只有发起方没有 token 时候才需要添加此注解, @NoToken + @Inner
|
||||||
|
* <p>
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface NoToken {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,4 +17,17 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-common-core</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-upms-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -2,6 +2,7 @@ package cn.meowrain.aioj.backend.framework.log.aspect;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.meowrain.aioj.backend.framework.log.annotation.SysLog;
|
import cn.meowrain.aioj.backend.framework.log.annotation.SysLog;
|
||||||
|
import cn.meowrain.aioj.backend.framework.log.utils.SysLogUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
@@ -25,7 +26,7 @@ public class SysLogAspect {
|
|||||||
if (StrUtil.isNotBlank(expression)) {
|
if (StrUtil.isNotBlank(expression)) {
|
||||||
// 解析SPEL
|
// 解析SPEL
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
EvaluationContext context = SysLogUtils.getContext(point.getArgs(), signature.getMethod());
|
EvaluationContext context = SysLogUtils.getContext(joinPoint.getArgs(), signature.getMethod());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ package cn.meowrain.aioj.backend.framework.log.config;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ConfigurationProperties(AIOJLogPropertiesConfiguration.PREFIX)
|
@ConfigurationProperties(AIOJLogPropertiesConfiguration.PREFIX)
|
||||||
@@ -21,4 +24,11 @@ public class AIOJLogPropertiesConfiguration {
|
|||||||
*/
|
*/
|
||||||
private Integer maxLength = 20000;
|
private Integer maxLength = 20000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 放行字段,password,mobile,idcard,phone
|
||||||
|
*/
|
||||||
|
@Value("${log.exclude-fields:password,mobile,idcard,phone}")
|
||||||
|
private List<String> excludeFields;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
package cn.meowrain.aioj.backend.framework.log.entity;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志对象
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class SysLog implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编号
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志类型
|
|
||||||
*/
|
|
||||||
private String logType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志标题
|
|
||||||
*/
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者
|
|
||||||
*/
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作IP地址
|
|
||||||
*/
|
|
||||||
private String remoteAddr;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户代理
|
|
||||||
*/
|
|
||||||
private String userAgent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求URI
|
|
||||||
*/
|
|
||||||
private String requestUri;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作方式
|
|
||||||
*/
|
|
||||||
private String method;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作提交的数据
|
|
||||||
*/
|
|
||||||
private String params;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行时间
|
|
||||||
*/
|
|
||||||
private Long time;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 异常信息
|
|
||||||
*/
|
|
||||||
private String exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务ID
|
|
||||||
*/
|
|
||||||
private String serviceId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标记
|
|
||||||
*/
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
package cn.meowrain.aioj.backend.framework.log.event;
|
package cn.meowrain.aioj.backend.framework.log.event;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.meowrain.aioj.backend.framework.core.jackson.JavaTimeModule;
|
||||||
import cn.meowrain.aioj.backend.framework.log.config.AIOJLogPropertiesConfiguration;
|
import cn.meowrain.aioj.backend.framework.log.config.AIOJLogPropertiesConfiguration;
|
||||||
import cn.meowrain.aioj.backend.framework.log.entity.SysLog;
|
import cn.meowrain.aioj.backend.upms.api.entity.SysLog;
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.feign.RemoteLogService;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFilter;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.ser.FilterProvider;
|
||||||
|
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
|
||||||
|
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@@ -11,6 +18,8 @@ import org.springframework.context.event.EventListener;
|
|||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SysLogListener implements InitializingBean {
|
public class SysLogListener implements InitializingBean {
|
||||||
|
|
||||||
@@ -29,11 +38,38 @@ public class SysLogListener implements InitializingBean {
|
|||||||
SysLog sysLog = new SysLog();
|
SysLog sysLog = new SysLog();
|
||||||
BeanUtils.copyProperties(source, sysLog);
|
BeanUtils.copyProperties(source, sysLog);
|
||||||
|
|
||||||
|
// json 格式刷参数放在异步中处理,提升性能
|
||||||
|
if (Objects.nonNull(source.getBody())) {
|
||||||
|
String params = objectMapper.writeValueAsString(source.getBody());
|
||||||
|
sysLog.setParams(StrUtil.subPre(params, logProperties.getMaxLength()));
|
||||||
|
}
|
||||||
|
|
||||||
|
remoteLogService.saveLog(sysLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在 Bean 初始化后执行,用于初始化 ObjectMapper
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
//给 ObjectMapper 添加 MixIn(用于过滤字段)
|
||||||
|
objectMapper.addMixIn(Object.class, PropertyFilterMixIn.class);
|
||||||
|
String[] ignorableFieldNames = logProperties.getExcludeFields().toArray(new String[0]);
|
||||||
|
|
||||||
|
FilterProvider filters = new SimpleFilterProvider().addFilter("filter properties by name",
|
||||||
|
SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames));
|
||||||
|
objectMapper.setFilterProvider(filters);
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 属性过滤混合类:用于通过名称过滤属性
|
||||||
|
*
|
||||||
|
* @author lengleng
|
||||||
|
* @date 2025/05/31
|
||||||
|
*/
|
||||||
|
@JsonFilter("filter properties by name")
|
||||||
|
class PropertyFilterMixIn {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,11 @@
|
|||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-core</artifactId>
|
<artifactId>hutool-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- orm 模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
<!--mybatis-->
|
<!--mybatis-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package cn.meowrain.backend.common.mybaits;
|
|||||||
import cn.meowrain.backend.common.mybaits.config.MybatisPlusMetaObjectHandler;
|
import cn.meowrain.backend.common.mybaits.config.MybatisPlusMetaObjectHandler;
|
||||||
import cn.meowrain.backend.common.mybaits.plugins.PaginationInterceptor;
|
import cn.meowrain.backend.common.mybaits.plugins.PaginationInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@AutoConfiguration
|
||||||
public class MybatisPlusAutoConfiguration {
|
public class MybatisPlusAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<module>aioj-backend-common-starter</module>
|
<module>aioj-backend-common-starter</module>
|
||||||
<module>aioj-backend-common-mybatis</module>
|
<module>aioj-backend-common-mybatis</module>
|
||||||
<module>aioj-backend-common-bom</module>
|
<module>aioj-backend-common-bom</module>
|
||||||
|
<module>aioj-backend-common-feign</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -17,4 +17,22 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-common-core</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-common-mybatis</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<!--feign 注解依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-common-feign</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package cn.meowrain.aioj.backend.upms.api.dto;
|
package cn.meowrain.aioj.backend.upms.api.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
* Author: lengleng (wangiegie@gmail.com)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.meowrain.aioj.backend.upms.api.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 日志表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author lengleng
|
||||||
|
* @since 2017-11-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "日志")
|
||||||
|
public class SysLog implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
// @ExcelProperty("日志编号")
|
||||||
|
@Schema(description = "日志编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志类型
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "日志类型不能为空")
|
||||||
|
// @ExcelProperty("日志类型(0-正常 9-错误)")
|
||||||
|
@Schema(description = "日志类型")
|
||||||
|
private String logType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志标题
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "日志标题不能为空")
|
||||||
|
// @ExcelProperty("日志标题")
|
||||||
|
@Schema(description = "日志标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("创建人")
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
@Schema(description = "创建人")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("创建时间")
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
// @ExcelIgnore
|
||||||
|
@TableField(fill = FieldFill.UPDATE)
|
||||||
|
@Schema(description = "更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作IP地址
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("操作ip地址")
|
||||||
|
@Schema(description = "操作ip地址")
|
||||||
|
private String remoteAddr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户代理
|
||||||
|
*/
|
||||||
|
@Schema(description = "用户代理")
|
||||||
|
private String userAgent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求URI
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("浏览器")
|
||||||
|
@Schema(description = "请求uri")
|
||||||
|
private String requestUri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作方式
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("操作方式")
|
||||||
|
@Schema(description = "操作方式")
|
||||||
|
private String method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作提交的数据
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("提交数据")
|
||||||
|
@Schema(description = "提交数据")
|
||||||
|
private String params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行时间
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("执行时间")
|
||||||
|
@Schema(description = "方法执行时间")
|
||||||
|
private Long time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常信息
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("异常信息")
|
||||||
|
@Schema(description = "异常信息")
|
||||||
|
private String exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务ID
|
||||||
|
*/
|
||||||
|
// @ExcelProperty("应用标识")
|
||||||
|
@Schema(description = "应用标识")
|
||||||
|
private String serviceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标记
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
// @ExcelIgnore
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
@Schema(description = "删除标记,1:已删除,0:正常")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package cn.meowrain.aioj.backend.upms.api.feign;
|
||||||
|
|
||||||
|
import cn.meowrain.aioj.backend.framework.core.constants.ServiceNameConstants;
|
||||||
|
import cn.meowrain.aioj.backend.framework.core.web.Result;
|
||||||
|
import cn.meowrain.aioj.backend.framework.feign.annotation.NoToken;
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.entity.SysLog;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
@FeignClient(contextId = "remoteLogService", value = ServiceNameConstants.UPMS_SERVICE)
|
||||||
|
public interface RemoteLogService {
|
||||||
|
/**
|
||||||
|
* 保存日志 (异步多线程调用,无token)
|
||||||
|
* @param sysLog 日志实体
|
||||||
|
* @return succes、false
|
||||||
|
*/
|
||||||
|
@NoToken
|
||||||
|
@PostMapping("/log/save")
|
||||||
|
Result<Boolean> saveLog(@RequestBody SysLog sysLog);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
cn.meowrain.aioj.backend.upms.api.feign.RemoteLogService
|
||||||
@@ -17,4 +17,16 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-common-mybatis</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-upms-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.meowrain.aioj.backend.upms.biz;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class AIOJAdminApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AIOJAdminApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package cn.meowrain.aioj.backend.upms.biz.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.meowrain.aioj.backend.framework.core.web.Result;
|
||||||
|
import cn.meowrain.aioj.backend.framework.core.web.Results;
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.dto.SysLogDTO;
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.entity.SysLog;
|
||||||
|
import cn.meowrain.aioj.backend.upms.biz.service.SysLogService;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springdoc.core.annotations.ParameterObject;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/log")
|
||||||
|
@Tag(description = "log", name = "日志管理模块")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SysLogController {
|
||||||
|
|
||||||
|
private final SysLogService sysLogService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询系统日志
|
||||||
|
*
|
||||||
|
* @param page 分页参数对象
|
||||||
|
* @param sysLog 系统日志查询条件
|
||||||
|
* @return 包含分页结果的响应对象
|
||||||
|
*/
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "分页查询系统日志", description = "分页查询系统日志")
|
||||||
|
public Result<Page> getLogPage(@ParameterObject Page page, @ParameterObject SysLogDTO sysLog) {
|
||||||
|
return Results.success(sysLogService.getLogPage(page, sysLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除日志
|
||||||
|
*
|
||||||
|
* @param ids 要删除的日志ID数组
|
||||||
|
* @return 操作结果,成功返回success,失败返回false
|
||||||
|
*/
|
||||||
|
@DeleteMapping
|
||||||
|
// @HasPermission("sys_log_del")
|
||||||
|
@Operation(summary = "批量删除日志", description = "批量删除日志")
|
||||||
|
public Result<Boolean> removeByIds(@RequestBody Long[] ids) {
|
||||||
|
return Results.success(sysLogService.removeBatchByIds(CollUtil.toList(ids)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存日志
|
||||||
|
*
|
||||||
|
* @param sysLog 日志实体
|
||||||
|
* @return 操作结果,成功返回success,失败返回false
|
||||||
|
*/
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
@Operation(summary = "保存日志", description = "保存日志")
|
||||||
|
public Result<Boolean> saveLog(@Valid @RequestBody SysLog sysLog) {
|
||||||
|
return Results.success(sysLogService.saveLog(sysLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出系统日志到Excel表格
|
||||||
|
* @param sysLog 系统日志查询条件DTO
|
||||||
|
* @return 符合查询条件的系统日志列表
|
||||||
|
*/
|
||||||
|
// @ResponseExcel
|
||||||
|
// @GetMapping("/export")
|
||||||
|
// @HasPermission("sys_log_export")
|
||||||
|
// @Operation(summary = "导出系统日志到Excel表格", description = "导出系统日志到Excel表格")
|
||||||
|
// public List<SysLog> exportLogs(SysLogDTO sysLog) {
|
||||||
|
// return sysLogService.listLogs(sysLog);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package cn.meowrain.aioj.backend.upms.biz.mapper;
|
||||||
|
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.entity.SysLog;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统日志表 Mapper 接口
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysLogMapper extends BaseMapper<SysLog> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package cn.meowrain.aioj.backend.upms.biz.service;
|
||||||
|
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.dto.SysLogDTO;
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.entity.SysLog;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SysLogService extends IService<SysLog> {
|
||||||
|
/**
|
||||||
|
* 分页查询系统日志
|
||||||
|
*
|
||||||
|
* @param page 分页对象
|
||||||
|
* @param sysLog 系统日志
|
||||||
|
* @return 系统日志分页数据
|
||||||
|
*/
|
||||||
|
Page getLogPage(Page page, SysLogDTO sysLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存日志
|
||||||
|
*
|
||||||
|
* @param sysLog 日志实体
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
Boolean saveLog(SysLog sysLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询日志列表
|
||||||
|
*
|
||||||
|
* @param sysLog 查询条件
|
||||||
|
* @return 日志列表
|
||||||
|
*/
|
||||||
|
List<SysLog> listLogs(SysLogDTO sysLog);
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package cn.meowrain.aioj.backend.upms.biz.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.dto.SysLogDTO;
|
||||||
|
import cn.meowrain.aioj.backend.upms.api.entity.SysLog;
|
||||||
|
import cn.meowrain.aioj.backend.upms.biz.mapper.SysLogMapper;
|
||||||
|
import cn.meowrain.aioj.backend.upms.biz.service.SysLogService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {
|
||||||
|
/**
|
||||||
|
* 分页查询系统日志
|
||||||
|
*
|
||||||
|
* @param page 分页参数
|
||||||
|
* @param sysLog 日志查询条件
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Page getLogPage(Page page, SysLogDTO sysLog) {
|
||||||
|
return baseMapper.selectPage(page, buildQuery(sysLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存日志
|
||||||
|
*
|
||||||
|
* @param sysLog 日志对象
|
||||||
|
* @return 保存成功返回true
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean saveLog(SysLog sysLog) {
|
||||||
|
baseMapper.insert(sysLog);
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询日志列表
|
||||||
|
*
|
||||||
|
* @param sysLog 查询条件DTO对象
|
||||||
|
* @return 日志列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysLog> listLogs(SysLogDTO sysLog) {
|
||||||
|
return baseMapper.selectList(buildQuery(sysLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param sysLog 前端查询条件DTO
|
||||||
|
* @return 构建好的LambdaQueryWrapper对象
|
||||||
|
*/
|
||||||
|
private LambdaQueryWrapper buildQuery(SysLogDTO sysLog) {
|
||||||
|
LambdaQueryWrapper<SysLog> wrapper = Wrappers.lambdaQuery();
|
||||||
|
if (StrUtil.isNotBlank(sysLog.getLogType())) {
|
||||||
|
wrapper.eq(SysLog::getLogType, sysLog.getLogType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ArrayUtil.isNotEmpty(sysLog.getCreateTime())) {
|
||||||
|
wrapper.ge(SysLog::getCreateTime, sysLog.getCreateTime()[0])
|
||||||
|
.le(SysLog::getCreateTime, sysLog.getCreateTime()[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,15 +23,16 @@
|
|||||||
<artifactId>aioj-backend-common-starter</artifactId>
|
<artifactId>aioj-backend-common-starter</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.meowrain</groupId>
|
||||||
|
<artifactId>aioj-backend-common-mybatis</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-openapi3-jakarta-spring-boot-starter -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
|
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
|||||||
86
pom.xml
86
pom.xml
@@ -30,8 +30,11 @@
|
|||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<spring-boot.version>3.5.7</spring-boot.version>
|
<spring-boot.version>3.5.7</spring-boot.version>
|
||||||
|
<spring-cloud.version>2025.0.0</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2025.0.0.0</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2025.0.0.0</spring-cloud-alibaba.version>
|
||||||
<spring.checkstyle.plugin>0.0.47</spring.checkstyle.plugin>
|
<spring.checkstyle.plugin>0.0.47</spring.checkstyle.plugin>
|
||||||
|
<git.commit.plugin>9.0.2</git.commit.plugin>
|
||||||
|
<docker.spring.active>dev</docker.spring.active>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -72,6 +75,14 @@
|
|||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Spring Cloud依赖-->
|
<!-- Spring Cloud依赖-->
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
@@ -123,7 +134,82 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<!--打包jar 与git commit 关联插件-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>io.github.git-commit-id</groupId>
|
||||||
|
<artifactId>git-commit-id-maven-plugin</artifactId>
|
||||||
|
<version>${git.commit.plugin}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>get-the-git-infos</id>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||||
|
<generateGitPropertiesFile>true</generateGitPropertiesFile>
|
||||||
|
<!--因为项目定制了jackson的日期时间序列化/反序列化格式,因此这里要进行配置,不然通过management.info.git.mode=full进行完整git信息监控时会存在问题-->
|
||||||
|
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
|
||||||
|
<includeOnlyProperties>
|
||||||
|
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
|
||||||
|
<includeOnlyProperty>^git.commit.(id|message|time).*$</includeOnlyProperty>
|
||||||
|
</includeOnlyProperties>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.google.cloud.tools</groupId>
|
||||||
|
<artifactId>jib-maven-plugin</artifactId>
|
||||||
|
<version>3.4.5</version>
|
||||||
|
<configuration>
|
||||||
|
<allowInsecureRegistries>true</allowInsecureRegistries>
|
||||||
|
<from>
|
||||||
|
<!--使用openjdk官方镜像,tag是8-jdk-stretch,表示镜像的操作系统是debian9,装好了jdk8-->
|
||||||
|
<image>registry.cn-shanghai.aliyuncs.com/all_lib/eclipse-temurin:17.0.10_7-jdk-jammy</image>
|
||||||
|
</from>
|
||||||
|
<to>
|
||||||
|
<!-- 前缀名/命名空间/项目名:项目版本-->
|
||||||
|
<image>10.0.0.3/aioj/${project.artifactId}:${project.version}</image>
|
||||||
|
<tags>
|
||||||
|
<!--版本号-->
|
||||||
|
<tag>${project.version}</tag>
|
||||||
|
</tags>
|
||||||
|
<auth>
|
||||||
|
<username></username>
|
||||||
|
<password></password>
|
||||||
|
</auth>
|
||||||
|
</to>
|
||||||
|
<outputPaths>
|
||||||
|
<tar>${project.build.directory}/${project.artifactId}-${project.version}.tar</tar>
|
||||||
|
</outputPaths>
|
||||||
|
<!--容器相关的属性-->
|
||||||
|
<container>
|
||||||
|
<environment>
|
||||||
|
<TZ>Asia/Shanghai</TZ>
|
||||||
|
<PROFILES_ACTIVE>${docker.spring.active}</PROFILES_ACTIVE>
|
||||||
|
</environment>
|
||||||
|
<!--jvm内存参数-->
|
||||||
|
<jvmFlags>
|
||||||
|
<jvmFlag>-Xms512m</jvmFlag>
|
||||||
|
<jvmFlag>-Xmx512m</jvmFlag>
|
||||||
|
</jvmFlags>
|
||||||
|
</container>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build</goal>
|
||||||
|
<goal>buildTar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
<profiles>
|
<profiles>
|
||||||
<!--开发环境-->
|
<!--开发环境-->
|
||||||
|
|||||||
Reference in New Issue
Block a user