优化RowBound
This commit is contained in:
@@ -415,7 +415,7 @@ public final class ClassFilter<T> {
|
||||
* 例如:
|
||||
* *.platf.** 转成 ^(\w+)\.platf\.(.*)$
|
||||
*
|
||||
* @param regx
|
||||
* @param regx 正则表达式
|
||||
* @return Pattern
|
||||
*/
|
||||
public static String formatPackageRegx(String regx) {
|
||||
|
||||
@@ -116,7 +116,7 @@ public class CachedManagerService implements CachedManager, CachedActionFunc, Se
|
||||
}
|
||||
this.name = conf.getValue("name", "");
|
||||
this.enabled = conf.getBoolValue("enabled", true);
|
||||
this.schema = conf.getValue("schema", DEFAULT_SCHEMA);
|
||||
this.schema = checkSchema(conf.getValue("schema", DEFAULT_SCHEMA));
|
||||
if (this.enabled) {
|
||||
this.localSource.init(conf);
|
||||
String remoteSourceName = conf.getValue("remote", "");
|
||||
@@ -135,6 +135,23 @@ public class CachedManagerService implements CachedManager, CachedActionFunc, Se
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查name是否含特殊字符
|
||||
*
|
||||
* @param value 参数
|
||||
* @return
|
||||
*/
|
||||
protected String checkSchema(String value) {
|
||||
if (value != null && !value.isEmpty()) {
|
||||
for (char ch : value.toCharArray()) {
|
||||
if (ch == ':' || ch == '#' || ch == '@') { // 不能含特殊字符
|
||||
throw new RedkaleException("schema cannot contains : # @");
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(AnyValue conf) {
|
||||
if (this.enabled) {
|
||||
|
||||
@@ -2877,7 +2877,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
return flipper;
|
||||
}
|
||||
if (maxLimit < 1) {
|
||||
maxLimit = org.redkale.source.Flipper.DEFAULT_LIMIT;
|
||||
maxLimit = org.redkale.source.Flipper.getDefaultLimit();
|
||||
}
|
||||
return new org.redkale.source.Flipper(maxLimit);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public @interface Entity {
|
||||
/**
|
||||
* (Optional) 表名和字段名是否将驼峰式改成下划线式
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @return boolean
|
||||
*/
|
||||
boolean camelCase() default false;
|
||||
|
||||
@@ -166,13 +166,13 @@ public interface DataSqlSource extends DataSource {
|
||||
}
|
||||
|
||||
@ClassDepends
|
||||
default <V> Sheet<V> nativeQuerySheet(Class<V> type, String sql, Flipper flipper) {
|
||||
return nativeQuerySheet(type, sql, flipper, Collections.emptyMap());
|
||||
default <V> Sheet<V> nativeQuerySheet(Class<V> type, String sql, RowBound round) {
|
||||
return nativeQuerySheet(type, sql, round, Collections.emptyMap());
|
||||
}
|
||||
|
||||
@ClassDepends
|
||||
default <V> CompletableFuture<Sheet<V>> nativeQuerySheetAsync(Class<V> type, String sql, Flipper flipper) {
|
||||
return nativeQuerySheetAsync(type, sql, flipper, Collections.emptyMap());
|
||||
default <V> CompletableFuture<Sheet<V>> nativeQuerySheetAsync(Class<V> type, String sql, RowBound round) {
|
||||
return nativeQuerySheetAsync(type, sql, round, Collections.emptyMap());
|
||||
}
|
||||
|
||||
@ClassDepends
|
||||
@@ -417,15 +417,15 @@ public interface DataSqlSource extends DataSource {
|
||||
Copier.copyToMap(bean, Copier.OPTION_SKIP_NULL_VALUE));
|
||||
}
|
||||
|
||||
default <V> Sheet<V> nativeQuerySheet(Class<V> type, String sql, Flipper flipper, Serializable bean) {
|
||||
default <V> Sheet<V> nativeQuerySheet(Class<V> type, String sql, RowBound round, Serializable bean) {
|
||||
return nativeQuerySheet(
|
||||
type, sql, flipper, (Map<String, Object>) Copier.copyToMap(bean, Copier.OPTION_SKIP_NULL_VALUE));
|
||||
type, sql, round, (Map<String, Object>) Copier.copyToMap(bean, Copier.OPTION_SKIP_NULL_VALUE));
|
||||
}
|
||||
|
||||
default <V> CompletableFuture<Sheet<V>> nativeQuerySheetAsync(
|
||||
Class<V> type, String sql, Flipper flipper, Serializable bean) {
|
||||
Class<V> type, String sql, RowBound round, Serializable bean) {
|
||||
return nativeQuerySheetAsync(
|
||||
type, sql, flipper, (Map<String, Object>) Copier.copyToMap(bean, Copier.OPTION_SKIP_NULL_VALUE));
|
||||
type, sql, round, (Map<String, Object>) Copier.copyToMap(bean, Copier.OPTION_SKIP_NULL_VALUE));
|
||||
}
|
||||
|
||||
default <V> Sheet<V> nativeQuerySheet(Class<V> type, String sql, PageBean pageBean) {
|
||||
|
||||
@@ -18,8 +18,6 @@ import org.redkale.convert.ConvertColumn;
|
||||
*/
|
||||
public final class Flipper extends RowBound {
|
||||
|
||||
public static int DEFAULT_LIMIT = 20;
|
||||
|
||||
@ConvertColumn(index = 3)
|
||||
@Comment("排序字段, 可多字段排序")
|
||||
private String sort = "";
|
||||
|
||||
@@ -13,12 +13,15 @@ import org.redkale.convert.ConvertColumn;
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @see org.redkale.source.Flipper
|
||||
* @see org.redkale.source.PageBean
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public class RowBound implements Serializable, Cloneable {
|
||||
|
||||
public static int DEFAULT_LIMIT = 20;
|
||||
private static int DEFAULT_LIMIT = 20;
|
||||
|
||||
@ConvertColumn(index = 1)
|
||||
@Comment("记录行的偏移量,从0开始")
|
||||
@@ -148,7 +151,17 @@ public class RowBound implements Serializable, Cloneable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static boolean validLimit(RowBound flipper) {
|
||||
return flipper != null && flipper.getLimit() > 0;
|
||||
public static boolean validLimit(RowBound round) {
|
||||
return round != null && round.getLimit() > 0;
|
||||
}
|
||||
|
||||
public static int getDefaultLimit() {
|
||||
return DEFAULT_LIMIT;
|
||||
}
|
||||
|
||||
public static void setDefaultLimit(int limit) {
|
||||
if (limit > 0) {
|
||||
DEFAULT_LIMIT = limit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user