diff --git a/orion-ops-dependencies/pom.xml b/orion-ops-dependencies/pom.xml
index 7b84a94a..a6a1ac5b 100644
--- a/orion-ops-dependencies/pom.xml
+++ b/orion-ops-dependencies/pom.xml
@@ -113,6 +113,11 @@
orion-ops-spring-boot-starter-storage
${revision}
+
+ com.orion.ops
+ orion-ops-spring-boot-starter-security
+ ${revision}
+
diff --git a/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/constant/Const.java b/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/constant/Const.java
index 90b787f3..9f024669 100644
--- a/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/constant/Const.java
+++ b/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/constant/Const.java
@@ -12,4 +12,8 @@ public class Const implements com.orion.lang.constant.Const {
private Const() {
}
+ public static final Integer NOT_DELETE = 0;
+
+ public static final Integer IS_DELETED = 1;
+
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/utils/Utils.java b/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/utils/ConfigUtils.java
similarity index 91%
rename from orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/utils/Utils.java
rename to orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/utils/ConfigUtils.java
index f5078cbe..6a41cc59 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/utils/Utils.java
+++ b/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/utils/ConfigUtils.java
@@ -1,4 +1,4 @@
-package com.orion.ops.framework.log.core.utils;
+package com.orion.ops.framework.common.utils;
import com.orion.lang.constant.Const;
@@ -16,9 +16,9 @@ import java.util.stream.Stream;
* @version 1.0.0
* @since 2023/6/28 23:21
*/
-public class Utils {
+public class ConfigUtils {
- private Utils() {
+ private ConfigUtils() {
}
public static List parseStringList(List list) {
diff --git a/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/utils/SwaggerUtils.java b/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/utils/SwaggerUtils.java
new file mode 100644
index 00000000..8047d274
--- /dev/null
+++ b/orion-ops-framework/orion-ops-common/src/main/java/com/orion/ops/framework/common/utils/SwaggerUtils.java
@@ -0,0 +1,51 @@
+package com.orion.ops.framework.common.utils;
+
+import com.orion.lang.utils.collect.Maps;
+import com.orion.lang.utils.reflect.Annotations;
+import com.orion.ops.framework.common.constant.Const;
+import io.swagger.v3.oas.annotations.Operation;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+/**
+ * swagger 工具类
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2023/7/6 14:52
+ */
+public class SwaggerUtils {
+
+ /**
+ * api 描述
+ */
+ private static final Map SUMMARY_MAPPING = Maps.newMap();
+
+ private SwaggerUtils() {
+ }
+
+ /**
+ * 获取 api 描述
+ *
+ * @param m method
+ * @return summary
+ */
+ public static String getOperationSummary(Method m) {
+ // 缓存中获取描述
+ String key = m.toString();
+ String cache = SUMMARY_MAPPING.get(key);
+ if (cache != null) {
+ return cache;
+ }
+ // 获取注解描述
+ Operation operation = Annotations.getAnnotation(m, Operation.class);
+ String summary = Const.EMPTY;
+ if (operation != null) {
+ summary = operation.summary();
+ }
+ SUMMARY_MAPPING.put(key, summary);
+ return summary;
+ }
+
+}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/config/LogPrinterConfig.java b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/config/LogPrinterConfig.java
index 6f5d7b80..1a51272c 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/config/LogPrinterConfig.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/config/LogPrinterConfig.java
@@ -1,6 +1,6 @@
package com.orion.ops.framework.log.core.config;
-import com.orion.ops.framework.log.core.utils.Utils;
+import com.orion.ops.framework.common.utils.ConfigUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -32,7 +32,7 @@ public class LogPrinterConfig {
}
public void setHeaders(List headers) {
- this.headers = Utils.parseStringList(headers, String::toLowerCase);
+ this.headers = ConfigUtils.parseStringList(headers, String::toLowerCase);
}
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/config/LogPrinterFieldConfig.java b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/config/LogPrinterFieldConfig.java
index 3e2872dc..4eb6b6b3 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/config/LogPrinterFieldConfig.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/config/LogPrinterFieldConfig.java
@@ -1,6 +1,6 @@
package com.orion.ops.framework.log.core.config;
-import com.orion.ops.framework.log.core.utils.Utils;
+import com.orion.ops.framework.common.utils.ConfigUtils;
import lombok.Data;
import java.util.List;
@@ -26,11 +26,11 @@ public class LogPrinterFieldConfig {
private List desensitize;
public void setIgnore(List ignore) {
- this.ignore = Utils.parseStringList(ignore);
+ this.ignore = ConfigUtils.parseStringList(ignore);
}
public void setDesensitize(List desensitize) {
- this.desensitize = Utils.parseStringList(desensitize);
+ this.desensitize = ConfigUtils.parseStringList(desensitize);
}
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/AbstractLogPrinterInterceptor.java b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/AbstractLogPrinterInterceptor.java
index e0b1cbc8..577ad9fd 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/AbstractLogPrinterInterceptor.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/AbstractLogPrinterInterceptor.java
@@ -9,13 +9,10 @@ import com.orion.lang.utils.Desensitizes;
import com.orion.lang.utils.Objects1;
import com.orion.lang.utils.collect.Lists;
import com.orion.lang.utils.collect.Maps;
-import com.orion.lang.utils.reflect.Annotations;
import com.orion.lang.utils.reflect.Classes;
import com.orion.ops.framework.common.annotation.IgnoreLog;
-import com.orion.ops.framework.common.constant.Const;
import com.orion.ops.framework.common.meta.TraceIdHolder;
import com.orion.ops.framework.log.core.config.LogPrinterConfig;
-import io.swagger.v3.oas.annotations.Operation;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -53,11 +50,6 @@ public abstract class AbstractLogPrinterInterceptor implements LogPrinterInterce
*/
private final LogPrinterConfig config;
- /**
- * api 描述
- */
- private final Map summaryMapping;
-
/**
* 忽略的参数
*/
@@ -70,7 +62,6 @@ public abstract class AbstractLogPrinterInterceptor implements LogPrinterInterce
public AbstractLogPrinterInterceptor(LogPrinterConfig config) {
this.config = config;
- this.summaryMapping = Maps.newMap();
this.ignoreParameter = Maps.newMap();
}
@@ -146,29 +137,6 @@ public abstract class AbstractLogPrinterInterceptor implements LogPrinterInterce
*/
protected abstract void errorPrinter(Date startTime, String traceId, Throwable throwable);
- /**
- * 获取 api 描述
- *
- * @param m method
- * @return summary
- */
- protected String getApiSummary(Method m) {
- // 缓存中获取描述
- String key = m.toString();
- String cache = summaryMapping.get(key);
- if (cache != null) {
- return cache;
- }
- // 获取注解描述
- Operation operation = Annotations.getAnnotation(m, Operation.class);
- String summary = Const.EMPTY;
- if (operation != null) {
- summary = operation.summary();
- }
- summaryMapping.put(key, summary);
- return summary;
- }
-
/**
* 请求参数 json
*
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/PrettyLogPrinterInterceptor.java b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/PrettyLogPrinterInterceptor.java
index f0ee86fb..e0d8f952 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/PrettyLogPrinterInterceptor.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/PrettyLogPrinterInterceptor.java
@@ -3,6 +3,7 @@ package com.orion.ops.framework.log.core.interceptor;
import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.time.Dates;
+import com.orion.ops.framework.common.utils.SwaggerUtils;
import com.orion.ops.framework.log.core.config.LogPrinterConfig;
import com.orion.web.servlet.web.Servlets;
import lombok.extern.slf4j.Slf4j;
@@ -47,7 +48,7 @@ public class PrettyLogPrinterInterceptor extends AbstractLogPrinterInterceptor {
// 开始时间
requestLog.append("\tstart: ").append(Dates.format(startTime, Dates.YMD_HMSS)).append('\n');
// api 描述
- String summary = this.getApiSummary(invocation.getMethod());
+ String summary = SwaggerUtils.getOperationSummary(invocation.getMethod());
if (!Strings.isEmpty(summary)) {
requestLog.append("\tsummary: ").append(summary).append('\n');
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/RowLogPrinterInterceptor.java b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/RowLogPrinterInterceptor.java
index 07d458a8..c51b5e5b 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/RowLogPrinterInterceptor.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-log/src/main/java/com/orion/ops/framework/log/core/interceptor/RowLogPrinterInterceptor.java
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.time.Dates;
+import com.orion.ops.framework.common.utils.SwaggerUtils;
import com.orion.ops.framework.log.core.config.LogPrinterConfig;
import com.orion.ops.framework.log.core.enums.LogFieldConst;
import com.orion.web.servlet.web.Servlets;
@@ -51,7 +52,7 @@ public class RowLogPrinterInterceptor extends AbstractLogPrinterInterceptor impl
// 开始时间
fields.put(START, Dates.format(startTime, Dates.YMD_HMSS));
// api 描述
- String summary = this.getApiSummary(invocation.getMethod());
+ String summary = SwaggerUtils.getOperationSummary(invocation.getMethod());
if (!Strings.isEmpty(summary)) {
fields.put(SUMMARY, summary);
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/domain/BaseDO.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/domain/BaseDO.java
index 9072f91d..cebae6bc 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/domain/BaseDO.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/domain/BaseDO.java
@@ -44,10 +44,10 @@ public class BaseDO implements Serializable {
private String updater;
/**
- * 是否删除 1未删除 2已删除
+ * 是否删除 0未删除 1已删除
*
- * @see com.orion.lang.constant.Const#NOT_DELETED
- * @see com.orion.lang.constant.Const#IS_DELETED
+ * @see com.orion.ops.framework.common.constant.Const#NOT_DELETE
+ * @see com.orion.ops.framework.common.constant.Const#IS_DELETED
*/
@TableLogic
private Boolean deleted;
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/query/CacheQuery.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/query/CacheQuery.java
index eedd72e9..274842b0 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/query/CacheQuery.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/query/CacheQuery.java
@@ -6,6 +6,8 @@ import com.orion.lang.utils.Valid;
import com.orion.ops.framework.mybatis.cache.RowCacheHolder;
import java.io.Serializable;
+import java.util.Optional;
+import java.util.function.Function;
/**
* 缓存查询器
@@ -63,30 +65,26 @@ public class CacheQuery {
return this;
}
- @SuppressWarnings("unchecked")
- public R get(Class c) {
- T row = this.get();
- // FIXME mapstruct
- return (R) row;
+ public Optional get(Function mapper) {
+ Valid.notNull(mapper, "convert function is null");
+ return this.get().map(mapper);
}
@SuppressWarnings("unchecked")
- public T get() {
+ public Optional get() {
Class extends BaseMapper> mapperClass = (Class extends BaseMapper>) dao.getClass();
// 不查询缓存
if (!force) {
// 从缓存中获取
Store store = RowCacheHolder.get(mapperClass, id);
- // 设置过缓存
- if (store != null) {
- return store.get();
- }
+ return Optional.ofNullable(store)
+ .map(Store::get);
}
// 查询
T row = dao.selectById(id);
// 设置缓存
RowCacheHolder.set(mapperClass, id, row);
- return row;
+ return Optional.ofNullable(row);
}
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/query/DataQuery.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/query/DataQuery.java
index 64fe377b..c8537571 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/query/DataQuery.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/query/DataQuery.java
@@ -7,7 +7,6 @@ import com.orion.lang.define.wrapper.PageRequest;
import com.orion.lang.define.wrapper.Pager;
import com.orion.lang.utils.Valid;
import com.orion.lang.utils.collect.Lists;
-import com.orion.lang.utils.convert.Converts;
import java.util.List;
import java.util.Optional;
@@ -53,19 +52,19 @@ public class DataQuery {
return Optional.ofNullable(dao.selectOne(wrapper));
}
- // FIXME mapstruct
- public Optional get(Class c) {
+ public Optional get(Function mapper) {
+ Valid.notNull(mapper, "convert function is null");
return Optional.ofNullable(dao.selectOne(wrapper))
- .map(s -> Converts.to(s, c));
+ .map(mapper);
}
public Stream list() {
return dao.selectList(wrapper).stream();
}
- // FIXME mapstruct
- public List list(Class c) {
- return Converts.toList(dao.selectList(wrapper), c);
+ public List list(Function mapper) {
+ Valid.notNull(mapper, "convert function is null");
+ return Lists.map(dao.selectList(wrapper), mapper);
}
public Long count() {
@@ -80,13 +79,8 @@ public class DataQuery {
return this.dataGrid(Function.identity());
}
- // FIXME mapstruct
- public DataGrid dataGrid(Class c) {
- return this.dataGrid(t -> Converts.to(t, c));
- }
-
- public DataGrid dataGrid(Function convert) {
- Valid.notNull(convert, "convert is null");
+ public DataGrid dataGrid(Function mapper) {
+ Valid.notNull(mapper, "convert function is null");
Valid.notNull(page, "page is null");
Valid.notNull(wrapper, "wrapper is null");
Long count = dao.selectCount(wrapper);
@@ -96,7 +90,7 @@ public class DataQuery {
if (next) {
wrapper.last(pager.getSql());
List rows = dao.selectList(wrapper).stream()
- .map(convert)
+ .map(mapper)
.collect(Collectors.toList());
pager.setRows(rows);
} else {
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/pom.xml b/orion-ops-framework/orion-ops-spring-boot-starter-security/pom.xml
new file mode 100644
index 00000000..924aad7f
--- /dev/null
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/pom.xml
@@ -0,0 +1,36 @@
+
+
+
+ com.orion.ops
+ orion-ops-framework
+ ${revision}
+
+
+ 4.0.0
+ orion-ops-spring-boot-starter-security
+ ${project.artifactId}
+ jar
+
+ 项目 security 配置包
+ https://github.com/lijiahangmax/orion-ops-pro
+
+
+
+ com.orion.ops
+ orion-ops-common
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
+
+
+
\ No newline at end of file
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-storage/src/main/java/com/orion/ops/framework/storage/core/client/local/LocalFileClient.java b/orion-ops-framework/orion-ops-spring-boot-starter-storage/src/main/java/com/orion/ops/framework/storage/core/client/local/LocalFileClient.java
index f4675309..52e7facb 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-storage/src/main/java/com/orion/ops/framework/storage/core/client/local/LocalFileClient.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-storage/src/main/java/com/orion/ops/framework/storage/core/client/local/LocalFileClient.java
@@ -1,11 +1,10 @@
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.lang.utils.io.Streams;
import com.orion.ops.framework.storage.core.client.AbstractFileClient;
import java.io.InputStream;
-import java.io.OutputStream;
/**
* 本地文件客户端
@@ -31,13 +30,7 @@ public class LocalFileClient extends AbstractFileClient {
// 获取实际文件路径
String absolutePath = this.getAbsolutePath(returnPath);
// 上传文件
- try (OutputStream out = Files1.openOutputStreamFast(absolutePath)) {
- Streams.transfer(in, out);
- } finally {
- if (autoClose) {
- Streams.close(in);
- }
- }
+ FileWriters.writeFast(absolutePath, in, autoClose);
return returnPath;
}
diff --git a/orion-ops-framework/pom.xml b/orion-ops-framework/pom.xml
index 7b9b0ddc..032d3b24 100644
--- a/orion-ops-framework/pom.xml
+++ b/orion-ops-framework/pom.xml
@@ -28,6 +28,7 @@
orion-ops-spring-boot-starter-desensitize
orion-ops-spring-boot-starter-log
orion-ops-spring-boot-starter-storage
+ orion-ops-spring-boot-starter-security
\ No newline at end of file
diff --git a/orion-ops-launch/pom.xml b/orion-ops-launch/pom.xml
index 3181ff21..9424c250 100644
--- a/orion-ops-launch/pom.xml
+++ b/orion-ops-launch/pom.xml
@@ -67,7 +67,10 @@
com.orion.ops
orion-ops-spring-boot-starter-storage
- ${revision}
+
+
+ com.orion.ops
+ orion-ops-spring-boot-starter-security
diff --git a/orion-ops-launch/src/main/resources/application.yaml b/orion-ops-launch/src/main/resources/application.yaml
index 0a9fb9f1..8311bdca 100644
--- a/orion-ops-launch/src/main/resources/application.yaml
+++ b/orion-ops-launch/src/main/resources/application.yaml
@@ -75,8 +75,8 @@ mybatis-plus:
global-config:
db-config:
logic-delete-field: deleted
- logic-not-delete-value: 1
- logic-delete-value: 2
+ logic-not-delete-value: 0
+ logic-delete-value: 1
springdoc:
api-docs: