🎨 优化项目模块.
This commit is contained in:
@@ -105,4 +105,6 @@ public interface FieldConst {
|
|||||||
|
|
||||||
String ALL = "all";
|
String ALL = "all";
|
||||||
|
|
||||||
|
String CONFIG = "config";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,25 @@ public interface FileClient {
|
|||||||
*/
|
*/
|
||||||
byte[] getContent(String path) throws Exception;
|
byte[] getContent(String path) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件内容
|
||||||
|
*
|
||||||
|
* @param path path
|
||||||
|
* @return content
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
String getContentAsString(String path) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件内容
|
||||||
|
*
|
||||||
|
* @param path path
|
||||||
|
* @param charset charset
|
||||||
|
* @return content
|
||||||
|
* @throws Exception Exception
|
||||||
|
*/
|
||||||
|
String getContentAsString(String path, String charset) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件输入流
|
* 获取文件输入流
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ import org.dromara.visor.common.interfaces.RsaEncryptor;
|
|||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @since 2025/1/5 21:13
|
* @since 2025/1/5 21:13
|
||||||
*/
|
*/
|
||||||
public class RsaEncryptorUtils {
|
public class RsaEncryptUtils {
|
||||||
|
|
||||||
private static RsaEncryptor delegate;
|
private static RsaEncryptor delegate;
|
||||||
|
|
||||||
private RsaEncryptorUtils() {
|
private RsaEncryptUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,11 +60,11 @@ public class RsaEncryptorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setDelegate(RsaEncryptor delegate) {
|
public static void setDelegate(RsaEncryptor delegate) {
|
||||||
if (RsaEncryptorUtils.delegate != null) {
|
if (RsaEncryptUtils.delegate != null) {
|
||||||
// unmodified
|
// unmodified
|
||||||
throw Exceptions.state();
|
throw Exceptions.state();
|
||||||
}
|
}
|
||||||
RsaEncryptorUtils.delegate = delegate;
|
RsaEncryptUtils.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,10 @@
|
|||||||
package org.dromara.visor.framework.biz.operator.log.core.utils;
|
package org.dromara.visor.framework.biz.operator.log.core.utils;
|
||||||
|
|
||||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||||
|
import cn.orionsec.kit.lang.utils.Strings;
|
||||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||||
import org.dromara.visor.common.security.LoginUser;
|
import org.dromara.visor.common.security.LoginUser;
|
||||||
@@ -74,7 +76,7 @@ public class OperatorLogs implements ExtraFieldConst {
|
|||||||
* @param value value
|
* @param value value
|
||||||
*/
|
*/
|
||||||
public static void addJson(String key, Object value) {
|
public static void addJson(String key, Object value) {
|
||||||
EXTRA_HOLDER.get().put(key, JSON.parseObject(JSON.toJSONString(value, serializeFilters)));
|
EXTRA_HOLDER.get().put(key, JSON.parseObject(toJsonString(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,13 +98,25 @@ public class OperatorLogs implements ExtraFieldConst {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (obj instanceof Map) {
|
if (obj instanceof JSONObject || obj instanceof com.alibaba.fastjson2.JSONObject) {
|
||||||
|
EXTRA_HOLDER.get().putAll(JSON.parseObject(toJsonString(obj)));
|
||||||
|
} else if (obj instanceof Map) {
|
||||||
EXTRA_HOLDER.get().putAll((Map<String, ?>) obj);
|
EXTRA_HOLDER.get().putAll((Map<String, ?>) obj);
|
||||||
} else {
|
} else {
|
||||||
EXTRA_HOLDER.get().putAll(JSON.parseObject(JSON.toJSONString(obj, serializeFilters)));
|
EXTRA_HOLDER.get().putAll(JSON.parseObject(toJsonString(obj)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 json
|
||||||
|
*
|
||||||
|
* @param value value
|
||||||
|
* @return json
|
||||||
|
*/
|
||||||
|
public static String toJsonString(Object value) {
|
||||||
|
return JSON.toJSONString(value, serializeFilters);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置不保存
|
* 设置不保存
|
||||||
*/
|
*/
|
||||||
@@ -167,6 +181,29 @@ public class OperatorLogs implements ExtraFieldConst {
|
|||||||
USER_HOLDER.remove();
|
USER_HOLDER.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空 html tag
|
||||||
|
*
|
||||||
|
* @param log log
|
||||||
|
* @return cleared
|
||||||
|
*/
|
||||||
|
public static String clearHtmlTag(String log) {
|
||||||
|
if (Strings.isBlank(log)) {
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
return log.replaceAll("<sb 0>", "")
|
||||||
|
.replaceAll("<sb 2>", "")
|
||||||
|
.replaceAll("<sb>", "")
|
||||||
|
.replaceAll("</sb>", "")
|
||||||
|
.replaceAll("<sr 0>", "")
|
||||||
|
.replaceAll("<sr 2>", "")
|
||||||
|
.replaceAll("<sr>", "")
|
||||||
|
.replaceAll("</sr>", "")
|
||||||
|
.replaceAll("<b>", "")
|
||||||
|
.replaceAll("</b>", "")
|
||||||
|
.replaceAll("<br/>", "\n");
|
||||||
|
}
|
||||||
|
|
||||||
public static void setSerializeFilters(SerializeFilter[] serializeFilters) {
|
public static void setSerializeFilters(SerializeFilter[] serializeFilters) {
|
||||||
if (OperatorLogs.serializeFilters != null) {
|
if (OperatorLogs.serializeFilters != null) {
|
||||||
// unmodified
|
// unmodified
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.dromara.visor.common.constant.AutoConfigureOrderConst;
|
|||||||
import org.dromara.visor.common.interfaces.AesEncryptor;
|
import org.dromara.visor.common.interfaces.AesEncryptor;
|
||||||
import org.dromara.visor.common.interfaces.RsaEncryptor;
|
import org.dromara.visor.common.interfaces.RsaEncryptor;
|
||||||
import org.dromara.visor.common.utils.AesEncryptUtils;
|
import org.dromara.visor.common.utils.AesEncryptUtils;
|
||||||
import org.dromara.visor.common.utils.RsaEncryptorUtils;
|
import org.dromara.visor.common.utils.RsaEncryptUtils;
|
||||||
import org.dromara.visor.framework.encrypt.configuration.config.AesEncryptConfig;
|
import org.dromara.visor.framework.encrypt.configuration.config.AesEncryptConfig;
|
||||||
import org.dromara.visor.framework.encrypt.core.impl.AesEncryptorImpl;
|
import org.dromara.visor.framework.encrypt.core.impl.AesEncryptorImpl;
|
||||||
import org.dromara.visor.framework.encrypt.core.impl.RsaEncryptorImpl;
|
import org.dromara.visor.framework.encrypt.core.impl.RsaEncryptorImpl;
|
||||||
@@ -70,7 +70,7 @@ public class OrionEncryptAutoConfiguration {
|
|||||||
// 加密器
|
// 加密器
|
||||||
RsaEncryptor encryptor = new RsaEncryptorImpl(configStore);
|
RsaEncryptor encryptor = new RsaEncryptorImpl(configStore);
|
||||||
// 设置工具类
|
// 设置工具类
|
||||||
RsaEncryptorUtils.setDelegate(encryptor);
|
RsaEncryptUtils.setDelegate(encryptor);
|
||||||
return encryptor;
|
return encryptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,16 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentAsString(String path) throws Exception {
|
||||||
|
return this.getContentAsString(path, Const.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentAsString(String path, String charset) throws Exception {
|
||||||
|
return new String(this.getContent(path), charset);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream getContentOutputStream(String path) throws Exception {
|
public OutputStream getContentOutputStream(String path) throws Exception {
|
||||||
return this.getContentOutputStream(path, false);
|
return this.getContentOutputStream(path, false);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +53,7 @@ public class OrionMockRedisTestConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public RedisServer redisMockServer(RedisProperties properties) {
|
public RedisServer redisMockServer(RedisProperties properties) {
|
||||||
RedisServer server = new RedisServer(properties.getPort());
|
RedisServer server = new RedisServer(properties.getPort(), InetAddress.getLoopbackAddress());
|
||||||
try {
|
try {
|
||||||
server.start();
|
server.start();
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.DeserializationContext;
|
|||||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.dromara.visor.common.constant.ErrorMessage;
|
import org.dromara.visor.common.constant.ErrorMessage;
|
||||||
import org.dromara.visor.common.utils.RsaEncryptorUtils;
|
import org.dromara.visor.common.utils.RsaEncryptUtils;
|
||||||
import org.dromara.visor.common.utils.Valid;
|
import org.dromara.visor.common.utils.Valid;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -51,7 +51,7 @@ public class ParamDecryptDeserializer extends JsonDeserializer<String> {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
// 解密参数
|
// 解密参数
|
||||||
String decrypt = RsaEncryptorUtils.decrypt(value);
|
String decrypt = RsaEncryptUtils.decrypt(value);
|
||||||
return Valid.notNull(decrypt, ErrorMessage.DECRYPT_ERROR);
|
return Valid.notNull(decrypt, ErrorMessage.DECRYPT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class ReplaceVersion {
|
|||||||
*/
|
*/
|
||||||
private static void replaceViteEnvFiles() {
|
private static void replaceViteEnvFiles() {
|
||||||
for (String file : VITE_ENV_FILES) {
|
for (String file : VITE_ENV_FILES) {
|
||||||
readAndWrite(file, s -> s.replaceAll("VITE_APP_VERSION= '" + TARGET_VERSION + "'", "VITE_APP_VERSION= '" + REPLACE_VERSION + "'"));
|
readAndWrite(file, s -> s.replaceAll("VITE_APP_VERSION=" + TARGET_VERSION, "VITE_APP_VERSION=" + REPLACE_VERSION));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
VITE_API_BASE_URL= 'http://127.0.0.1:9200/orion-visor/api'
|
# api 路径
|
||||||
VITE_WS_BASE_URL= 'ws://127.0.0.1:9200/orion-visor/keep-alive'
|
VITE_API_BASE_URL=http://127.0.0.1:9200/orion-visor/api
|
||||||
VITE_APP_VERSION= '2.2.3'
|
# websocket 路径
|
||||||
|
VITE_WS_BASE_URL=ws://127.0.0.1:9200/orion-visor/keep-alive
|
||||||
|
# 版本号
|
||||||
|
VITE_APP_VERSION=2.2.3
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
VITE_API_BASE_URL= '/orion-visor/api'
|
# api 路径
|
||||||
VITE_WS_BASE_URL= '/orion-visor/keep-alive'
|
VITE_API_BASE_URL=/orion-visor/api
|
||||||
VITE_APP_VERSION= '2.2.3'
|
# websocket 路径
|
||||||
|
VITE_WS_BASE_URL=/orion-visor/keep-alive
|
||||||
|
# 版本号
|
||||||
|
VITE_APP_VERSION=2.2.3
|
||||||
|
|||||||
Reference in New Issue
Block a user