Commit a88b41e4 by inrgihc

代码问题优化

parent 17de3fc7
......@@ -10,15 +10,16 @@
package org.dromara.sqlrest.cache.redis;
import cn.hutool.json.JSONUtil;
import org.dromara.sqlrest.cache.DistributedCache;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.dromara.sqlrest.cache.DistributedCache;
public class RedisDistributedCache implements DistributedCache {
private final String FORMAT = "%s#%s";
private static final String FORMAT = "%s#%s";
private final String name;
private JedisClient client;
private final JedisClient client;
public RedisDistributedCache(String name, JedisClient client) {
this.name = Objects.requireNonNull(name, "cache name must not be null");
......
......@@ -18,6 +18,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.sql.DataSource;
......@@ -59,11 +60,7 @@ public class DbVarModule implements VarModuleInterface {
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.productType = productType;
this.params = params;
if (null == strategy) {
strategy = NamingStrategyEnum.NONE;
}
this.converter = strategy.getFunction();
this.converter = Optional.ofNullable(strategy).orElse(NamingStrategyEnum.NONE).getFunction();
this.printSqlLog = printSqlLog;
}
......@@ -84,10 +81,7 @@ public class DbVarModule implements VarModuleInterface {
}
private Map<String, Object> build(Map<String, Object> row) {
if (null == row) {
return null;
}
return ConvertUtils.to(row, converter);
return Optional.ofNullable(row).map(r -> ConvertUtils.to(r, converter)).orElse(null);
}
private List<Map<String, Object>> build(List<Map<String, Object>> rows) {
......
......@@ -9,12 +9,12 @@
/////////////////////////////////////////////////////////////
package org.dromara.sqlrest.core.exec.module;
import java.text.MessageFormat;
import lombok.NoArgsConstructor;
import org.dromara.sqlrest.common.service.VarModuleInterface;
import org.dromara.sqlrest.core.exec.annotation.Comment;
import org.dromara.sqlrest.core.exec.annotation.Module;
import org.dromara.sqlrest.core.exec.logger.DebugExecuteLogger;
import org.slf4j.helpers.MessageFormatter;
import org.springframework.stereotype.Service;
@Service
......@@ -31,6 +31,7 @@ public class LogVarModule implements VarModuleInterface {
@Comment("打印调试日志信息")
public void print(@Comment("message") String message, Object... arguments) {
DebugExecuteLogger.add(MessageFormat.format(message, arguments));
// https://blog.csdn.net/weixin_44792849/article/details/131854226
DebugExecuteLogger.add(MessageFormatter.arrayFormat(message, arguments).getMessage());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment