🎨 优化项目模块.

This commit is contained in:
lijiahang
2025-01-09 10:02:22 +08:00
parent 41797e41d2
commit 72579c7e83
11 changed files with 94 additions and 19 deletions

View File

@@ -23,8 +23,10 @@
package org.dromara.visor.framework.biz.operator.log.core.utils;
import cn.orionsec.kit.lang.utils.Exceptions;
import cn.orionsec.kit.lang.utils.Strings;
import cn.orionsec.kit.lang.utils.collect.Maps;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializeFilter;
import org.dromara.visor.common.constant.ExtraFieldConst;
import org.dromara.visor.common.security.LoginUser;
@@ -74,7 +76,7 @@ public class OperatorLogs implements ExtraFieldConst {
* @param value 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) {
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);
} 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();
}
/**
* 清空 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) {
if (OperatorLogs.serializeFilters != null) {
// unmodified

View File

@@ -27,7 +27,7 @@ import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.interfaces.AesEncryptor;
import org.dromara.visor.common.interfaces.RsaEncryptor;
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.core.impl.AesEncryptorImpl;
import org.dromara.visor.framework.encrypt.core.impl.RsaEncryptorImpl;
@@ -70,7 +70,7 @@ public class OrionEncryptAutoConfiguration {
// 加密器
RsaEncryptor encryptor = new RsaEncryptorImpl(configStore);
// 设置工具类
RsaEncryptorUtils.setDelegate(encryptor);
RsaEncryptUtils.setDelegate(encryptor);
return encryptor;
}

View File

@@ -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
public OutputStream getContentOutputStream(String path) throws Exception {
return this.getContentOutputStream(path, false);

View File

@@ -32,6 +32,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Profile;
import java.net.InetAddress;
import java.util.function.Supplier;
/**
@@ -52,7 +53,7 @@ public class OrionMockRedisTestConfiguration {
*/
@Bean
public RedisServer redisMockServer(RedisProperties properties) {
RedisServer server = new RedisServer(properties.getPort());
RedisServer server = new RedisServer(properties.getPort(), InetAddress.getLoopbackAddress());
try {
server.start();
} catch (Exception ignore) {

View File

@@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
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 java.io.IOException;
@@ -51,7 +51,7 @@ public class ParamDecryptDeserializer extends JsonDeserializer<String> {
return value;
}
// 解密参数
String decrypt = RsaEncryptorUtils.decrypt(value);
String decrypt = RsaEncryptUtils.decrypt(value);
return Valid.notNull(decrypt, ErrorMessage.DECRYPT_ERROR);
}