review code.
This commit is contained in:
@@ -40,15 +40,11 @@ public class ValidateLambdaWrapper<T> extends LambdaQueryWrapper<T> {
|
||||
}
|
||||
// 字符串 非空校验
|
||||
if (object instanceof String) {
|
||||
if (Strings.isBlank((String) object)) {
|
||||
return true;
|
||||
}
|
||||
return Strings.isEmpty((String) object);
|
||||
}
|
||||
// 集合 非空校验
|
||||
if (object instanceof Collection<?>) {
|
||||
if (((Collection<?>) object).isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return ((Collection<?>) object).isEmpty();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -6,7 +6,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -22,7 +21,7 @@ import java.io.IOException;
|
||||
public class AuthenticationEntryPointHandler implements AuthenticationEntryPoint {
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException {
|
||||
log.debug("AuthenticationEntryPoint-commence-未登录 {}", request.getRequestURI(), e);
|
||||
Servlets.writeHttpWrapper(response, ErrorCode.UNAUTHORIZED.getWrapper());
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"description": "匿名接口."
|
||||
},
|
||||
{
|
||||
"name": "orion.crypto.primary.enabled",
|
||||
"name": "orion.crypto.aes.primary",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "是否为默认加密器.",
|
||||
"defaultValue": "false"
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.orion.ops.framework.storage.core.client;
|
||||
|
||||
import com.orion.lang.id.UUIds;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.lang.utils.io.Streams;
|
||||
import com.orion.ops.framework.common.meta.TraceIdHolder;
|
||||
import com.orion.lang.utils.time.Dates;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 文件客户端 基类
|
||||
@@ -107,24 +108,27 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
||||
* @return 文件名称
|
||||
*/
|
||||
protected String getFilePath(String path) {
|
||||
// 无需拼接
|
||||
if (!config.isNameAppendTraceId()) {
|
||||
return path;
|
||||
}
|
||||
// 名称前缀
|
||||
String traceId = TraceIdHolder.get();
|
||||
if (traceId == null) {
|
||||
traceId = UUIds.random32();
|
||||
}
|
||||
String prefix = traceId + "_";
|
||||
// 文件名称
|
||||
String name = Files1.getFileName(path);
|
||||
// 只是文件名
|
||||
if (name.equals(path)) {
|
||||
return prefix + name;
|
||||
// 名称前缀
|
||||
String prefix = Const.EMPTY;
|
||||
long current = System.currentTimeMillis();
|
||||
if (config.isTimestampPrefix()) {
|
||||
prefix = current + "_";
|
||||
}
|
||||
// 时间文件夹
|
||||
String dateDir = Const.EMPTY;
|
||||
if (config.isDateDirectory()) {
|
||||
dateDir = Dates.format(new Date(current), config.getDatePattern()) + Const.SLASH;
|
||||
}
|
||||
if (name.equals(path)) {
|
||||
// 文件名称
|
||||
return dateDir + prefix + name;
|
||||
} else {
|
||||
// 包含路径
|
||||
String parentPath = Files1.getParentPath(path);
|
||||
return dateDir + parentPath + prefix + name;
|
||||
}
|
||||
// 包含路径
|
||||
String parentPath = Files1.getParentPath(path);
|
||||
return parentPath + prefix + name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ public interface FileClient {
|
||||
*/
|
||||
String upload(String path, InputStream in, boolean autoClose, boolean overrideIfExist) throws Exception;
|
||||
|
||||
// TODO getOutputStream
|
||||
|
||||
/**
|
||||
* 检测文件是否存在
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orion.ops.framework.storage.core.client;
|
||||
|
||||
import com.orion.lang.utils.time.Dates;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -23,8 +24,18 @@ public class FileClientConfig {
|
||||
protected boolean enabled;
|
||||
|
||||
/**
|
||||
* 是否自动拼接 traceId 前缀. 没有则使用 UUID
|
||||
* 是否使用时间戳作为文件名称前缀
|
||||
*/
|
||||
protected boolean nameAppendTraceId;
|
||||
protected boolean timestampPrefix;
|
||||
|
||||
/**
|
||||
* 是否拼接时间作为文件夹
|
||||
*/
|
||||
protected boolean dateDirectory = true;
|
||||
|
||||
/**
|
||||
* 时间文件夹格式
|
||||
*/
|
||||
protected String datePattern = Dates.YMD;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orion.ops.framework.storage.core.client.local;
|
||||
|
||||
import com.orion.lang.utils.io.FileWriters;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.storage.core.client.AbstractFileClient;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -20,7 +21,7 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doUpload(String path, InputStream in, boolean autoClose, boolean overrideIfExist) throws Exception {
|
||||
protected String doUpload(String path, InputStream in, boolean autoClose, boolean overrideIfExist) {
|
||||
// 获取返回文件路径
|
||||
String returnPath = this.getReturnPath(path);
|
||||
// 检测文件是否存在
|
||||
@@ -51,14 +52,14 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
|
||||
|
||||
@Override
|
||||
protected String getReturnPath(String path) {
|
||||
// 拼接前缀
|
||||
return Files1.getPath(config.getBasePath() + "/" + this.getFilePath(path));
|
||||
// 拼接公共路径
|
||||
return Files1.getPath(config.getBasePath() + Const.SLASH + this.getFilePath(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAbsolutePath(String returnPath) {
|
||||
// 拼接存储路径
|
||||
return Files1.getPath(config.getStoragePath() + "/" + returnPath);
|
||||
return Files1.getPath(config.getStoragePath() + Const.SLASH + returnPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,22 +25,32 @@
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "orion.storage.local.name-append-trace-id",
|
||||
"name": "orion.storage.local.timestamp-prefix",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "是否自动拼接 traceId 前缀. 没有则使用 UUID.",
|
||||
"description": "是否使用时间戳作为文件名称前缀.",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "orion.storage.local.date-directory",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "是否拼接时间作为文件夹.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "orion.storage.local.date-pattern",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "时间文件夹格式.",
|
||||
"defaultValue": "yyyy-MM-dd"
|
||||
},
|
||||
{
|
||||
"name": "orion.storage.local.storage-path",
|
||||
"type": "java.lang.String",
|
||||
"description": "存储路径.",
|
||||
"defaultValue": ""
|
||||
"description": "存储路径."
|
||||
},
|
||||
{
|
||||
"name": "orion.storage.local.base-path",
|
||||
"type": "java.lang.String",
|
||||
"description": "基础路径.",
|
||||
"defaultValue": ""
|
||||
"description": "基础路径."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -167,7 +167,7 @@ orion:
|
||||
local:
|
||||
primary: true
|
||||
enabled: true
|
||||
name-append-trace-id: true
|
||||
timestamp-prefix: true
|
||||
storage-path: ${user.home}
|
||||
base-path: /orion/storage/orion-ops-pro
|
||||
security:
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.orion.ops.module.infra.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 菜单 实体对象
|
||||
*
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.orion.ops.module.infra.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 角色 实体对象
|
||||
*
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.orion.ops.module.infra.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 角色菜单关联 实体对象
|
||||
*
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.orion.ops.module.infra.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 用户角色关联 实体对象
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user