refactor: 阿里云OSS文件上传路径调整和Security代码优化
This commit is contained in:
@@ -65,7 +65,6 @@ public class SecurityConfig {
|
||||
|
||||
/**
|
||||
* 不走过滤器链的放行配置
|
||||
*
|
||||
*/
|
||||
@Bean
|
||||
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.stereotype.Component;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -71,7 +72,7 @@ public class JwtTokenManager {
|
||||
|
||||
// 角色放入JWT的claims
|
||||
Set<String> roles = userDetails.getAuthorities().stream()
|
||||
.map(item -> item.getAuthority()).collect(Collectors.toSet());
|
||||
.map(GrantedAuthority::getAuthority).collect(Collectors.toSet());
|
||||
claims.put("authorities", roles);
|
||||
|
||||
// 权限数据多放入Redis
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AliyunOssService implements OssService {
|
||||
// 生成文件名(日期文件夹)
|
||||
String suffix = FileUtil.getSuffix(file.getOriginalFilename());
|
||||
String uuid = IdUtil.simpleUUID();
|
||||
String fileName = DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd") + "/" + uuid + "." + suffix;
|
||||
String fileName = DateUtil.format(LocalDateTime.now(), "yyyyMMdd") + "/" + uuid + "." + suffix;
|
||||
// try-with-resource 语法糖自动释放流
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* MinIO 文件上传服务类
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2023/6/2
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user