DistributeTableStrategy增加getSource接口,待实现
This commit is contained in:
@@ -46,7 +46,7 @@ redkale.datasource.platf.password = pwd123
|
||||
</dependency>
|
||||
```
|
||||
|
||||
   使用vertx-mysql-client实现, 需要依赖官方扩展包 ```redkale-plugins```:
|
||||
   异步场景可使用vertx-mysql-client实现, 需要依赖官方扩展包 ```redkale-plugins```:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.redkalex</groupId>
|
||||
|
||||
@@ -2951,7 +2951,7 @@ public abstract class AbstractDataSqlSource extends AbstractDataSource implement
|
||||
|
||||
protected <T> CompletableFuture<Boolean> existsDBApply(EntityInfo<T> info, CompletableFuture<? extends DataResultSet> future, boolean onlypk) {
|
||||
return future.thenApply((DataResultSet pgset) -> {
|
||||
boolean rs = pgset.next() ? (((Number) pgset.getObject(1)).intValue() > 0) : false;
|
||||
boolean rs = pgset.next() && (((Number) pgset.getObject(1)).intValue() > 0);
|
||||
pgset.close();
|
||||
return rs;
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.io.Serializable;
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
*
|
||||
* @see org.redkale.source.DistributeTable
|
||||
*
|
||||
* @author zhangjx
|
||||
@@ -22,6 +22,48 @@ import java.io.Serializable;
|
||||
*/
|
||||
public interface DistributeTableStrategy<T> {
|
||||
|
||||
/**
|
||||
* 获取DataSource资源名,为null表示没有分布物理库 <br>
|
||||
* 查询单个对象(DataSource.find)时调用本方法 <br>
|
||||
*
|
||||
* @param primary 记录主键
|
||||
*
|
||||
* @return DataSource资源名
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
default String getSource(Serializable primary) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取DataSource资源名,为null表示没有分布物理库 <br>
|
||||
* 新增对象或更新单个对象(DataSource.insert、DataSource.update)时调用本方法 <br>
|
||||
*
|
||||
* @param bean 实体对象
|
||||
*
|
||||
* @return DataSource资源名
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
default String getSource(T bean) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取DataSource资源名,为null表示没有分布物理库 <br>
|
||||
* 查询、修改、删除对象(DataSource.find、DataSource.query、DataSource.delete、DataSource.update)时调用本方法 <br>
|
||||
*
|
||||
* @param node 过滤条件
|
||||
*
|
||||
* @return DataSource资源名
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
default String getSource(FilterNode node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象的表名 <br>
|
||||
* 查询单个对象(DataSource.find)时调用本方法获取表名 <br>
|
||||
@@ -63,7 +105,7 @@ public interface DistributeTableStrategy<T> {
|
||||
* 注意: 需保证FilterNode过滤的结果集合必须在一个数据库表中 <br>
|
||||
*
|
||||
* @deprecated 2.8.0 replaced by getTables(String table, FilterNode node)
|
||||
* @see #getTables(java.lang.String, org.redkale.source.FilterNode)
|
||||
* @see #getTables(java.lang.String, org.redkale.source.FilterNode)
|
||||
*
|
||||
* @param table 模板表的表名
|
||||
* @param node 过滤条件
|
||||
|
||||
@@ -1195,6 +1195,48 @@ public final class EntityInfo<T> {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取DataSource资源名,为null表示没有分布物理库
|
||||
*
|
||||
* @param primary Entity主键值
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getSource(Serializable primary) {
|
||||
if (tableStrategy == null) {
|
||||
return null;
|
||||
}
|
||||
return tableStrategy.getSource(primary);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取DataSource资源名,为null表示没有分布物理库
|
||||
*
|
||||
* @param bean Entity实体
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getSource(T bean) {
|
||||
if (tableStrategy == null) {
|
||||
return null;
|
||||
}
|
||||
return tableStrategy.getSource(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取DataSource资源名,为null表示没有分布物理库
|
||||
*
|
||||
* @param node FilterNode
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getSource(FilterNode node) {
|
||||
if (tableStrategy == null) {
|
||||
return null;
|
||||
}
|
||||
return tableStrategy.getSource(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键值获取Entity的表名
|
||||
*
|
||||
|
||||
@@ -18,6 +18,8 @@ import org.redkale.convert.ConvertDisabled;
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AnyValueWriter extends AnyValue {
|
||||
|
||||
@@ -7,7 +7,7 @@ package org.redkale.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.BinaryOperator;
|
||||
|
||||
/**
|
||||
* 简单的xml读取器, 只读element节点信息,其他信息(如: namespace、comment、docdecl等)都会丢弃
|
||||
@@ -31,7 +31,7 @@ public class XmlReader {
|
||||
|
||||
protected int columnNumber;
|
||||
|
||||
protected BiFunction<String, String, String> attrFunc;
|
||||
protected BinaryOperator<String> attrFunc;
|
||||
|
||||
private static class TagNode {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class XmlReader {
|
||||
this.limit = start + len - 1;
|
||||
}
|
||||
|
||||
public XmlReader attrFunc(BiFunction<String, String, String> func) {
|
||||
public XmlReader attrFunc(BinaryOperator<String> func) {
|
||||
this.attrFunc = func;
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user