feat(file): 实现文件上传下载功能
- 新增文件上传接口,支持MultipartFile格式文件上传至MinIO - 新增文件下载接口,根据文件路径返回对应资源 - 集成MinIO客户端,实现文件存储与获取 - 添加文件信息服务,记录文件元数据 - 引入SpringDoc OpenAPI,为文件接口提供文档支持 - 配置Maven插件,生成源码包和JavaDoc包 - 升级项目版本至1.5,统一依赖管理
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>vip.jcfd</groupId>
|
||||
<artifactId>zkh-framework</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>zkh-log</artifactId>
|
||||
@ -18,6 +18,40 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
14
zkh-log/src/main/java/vip/jcfd/log/ConsoleLogService.java
Normal file
14
zkh-log/src/main/java/vip/jcfd/log/ConsoleLogService.java
Normal file
@ -0,0 +1,14 @@
|
||||
package vip.jcfd.log;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
public class ConsoleLogService implements ILogService {
|
||||
private final Logger logger = LoggerFactory.getLogger(ConsoleLogService.class);
|
||||
|
||||
@Override
|
||||
public void log(String message, Authentication authentication) {
|
||||
logger.debug("{} {}", authentication.getName(), message);
|
||||
}
|
||||
}
|
||||
8
zkh-log/src/main/java/vip/jcfd/log/ILogService.java
Normal file
8
zkh-log/src/main/java/vip/jcfd/log/ILogService.java
Normal file
@ -0,0 +1,8 @@
|
||||
package vip.jcfd.log;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
public interface ILogService {
|
||||
|
||||
void log(String message, Authentication authentication);
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
package vip.jcfd.log.annotation.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration("_logConfiguration")
|
||||
public class LogConfig {
|
||||
}
|
||||
50
zkh-log/src/main/java/vip/jcfd/log/config/LogConfig.java
Normal file
50
zkh-log/src/main/java/vip/jcfd/log/config/LogConfig.java
Normal file
@ -0,0 +1,50 @@
|
||||
package vip.jcfd.log.config;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import vip.jcfd.log.ConsoleLogService;
|
||||
import vip.jcfd.log.ILogService;
|
||||
import vip.jcfd.log.annotation.Log;
|
||||
|
||||
@Configuration("_logConfiguration")
|
||||
public class LogConfig {
|
||||
|
||||
@Bean("_defaultLogService")
|
||||
@ConditionalOnMissingBean
|
||||
@Order
|
||||
public ILogService defaultLogService() {
|
||||
return new ConsoleLogService();
|
||||
}
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
public static class LogAspect {
|
||||
private final ILogService logService;
|
||||
|
||||
public LogAspect(ILogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
@Pointcut("@annotation(vip.jcfd.log.annotation.Log)")
|
||||
public void logAspect() {
|
||||
}
|
||||
|
||||
@AfterReturning(value = "logAspect()")
|
||||
public void afterReturning(JoinPoint joinPoint) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Log log = signature.getMethod().getAnnotation(Log.class);
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
logService.log(log.value(), authentication);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user