Commit a88b41e4 by inrgihc

代码问题优化

parent 17de3fc7
...@@ -10,15 +10,16 @@ ...@@ -10,15 +10,16 @@
package org.dromara.sqlrest.cache.redis; package org.dromara.sqlrest.cache.redis;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import org.dromara.sqlrest.cache.DistributedCache;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.dromara.sqlrest.cache.DistributedCache;
public class RedisDistributedCache implements DistributedCache { public class RedisDistributedCache implements DistributedCache {
private final String FORMAT = "%s#%s"; private static final String FORMAT = "%s#%s";
private final String name; private final String name;
private JedisClient client; private final JedisClient client;
public RedisDistributedCache(String name, JedisClient client) { public RedisDistributedCache(String name, JedisClient client) {
this.name = Objects.requireNonNull(name, "cache name must not be null"); this.name = Objects.requireNonNull(name, "cache name must not be null");
......
...@@ -18,6 +18,7 @@ import java.util.Arrays; ...@@ -18,6 +18,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.sql.DataSource; import javax.sql.DataSource;
...@@ -59,11 +60,7 @@ public class DbVarModule implements VarModuleInterface { ...@@ -59,11 +60,7 @@ public class DbVarModule implements VarModuleInterface {
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
this.productType = productType; this.productType = productType;
this.params = params; this.params = params;
this.converter = Optional.ofNullable(strategy).orElse(NamingStrategyEnum.NONE).getFunction();
if (null == strategy) {
strategy = NamingStrategyEnum.NONE;
}
this.converter = strategy.getFunction();
this.printSqlLog = printSqlLog; this.printSqlLog = printSqlLog;
} }
...@@ -84,10 +81,7 @@ public class DbVarModule implements VarModuleInterface { ...@@ -84,10 +81,7 @@ public class DbVarModule implements VarModuleInterface {
} }
private Map<String, Object> build(Map<String, Object> row) { private Map<String, Object> build(Map<String, Object> row) {
if (null == row) { return Optional.ofNullable(row).map(r -> ConvertUtils.to(r, converter)).orElse(null);
return null;
}
return ConvertUtils.to(row, converter);
} }
private List<Map<String, Object>> build(List<Map<String, Object>> rows) { private List<Map<String, Object>> build(List<Map<String, Object>> rows) {
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package org.dromara.sqlrest.core.exec.module; package org.dromara.sqlrest.core.exec.module;
import java.text.MessageFormat;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.dromara.sqlrest.common.service.VarModuleInterface; import org.dromara.sqlrest.common.service.VarModuleInterface;
import org.dromara.sqlrest.core.exec.annotation.Comment; import org.dromara.sqlrest.core.exec.annotation.Comment;
import org.dromara.sqlrest.core.exec.annotation.Module; import org.dromara.sqlrest.core.exec.annotation.Module;
import org.dromara.sqlrest.core.exec.logger.DebugExecuteLogger; import org.dromara.sqlrest.core.exec.logger.DebugExecuteLogger;
import org.slf4j.helpers.MessageFormatter;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
...@@ -31,6 +31,7 @@ public class LogVarModule implements VarModuleInterface { ...@@ -31,6 +31,7 @@ public class LogVarModule implements VarModuleInterface {
@Comment("打印调试日志信息") @Comment("打印调试日志信息")
public void print(@Comment("message") String message, Object... arguments) { 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