1、使用Promise,重写red.getJSON /red.post, 解决"回调地狱"问题

2、修改 数据源管理/平台信息管理
This commit is contained in:
2019-04-04 17:47:29 +08:00
parent 3de47eea46
commit 696222fcf0
15 changed files with 283 additions and 38 deletions

View File

@@ -4,6 +4,8 @@ import com.arangodb.ArangoCollection;
import com.arangodb.ArangoDBException;
import com.arangodb.ArangoDatabase;
import com.arangodb.entity.DocumentCreateEntity;
import net.tccn.base.PageBean;
import org.redkale.source.Flipper;
import javax.persistence.Table;
import java.lang.reflect.InvocationTargetException;
@@ -160,7 +162,7 @@ public abstract class Doc<T extends Doc> {
this.db = arangoSource.db(table.catalog());
this.collection = arangoSource.collection(this);
}
public final static <T extends Doc> T dao(Class<T> type) {
protected final static <T extends Doc> T dao(Class<T> type) {
if (daos.get(type) == null) {
try {
@@ -188,6 +190,16 @@ public abstract class Doc<T extends Doc> {
collection.updateDocument(this.getKey(), this.toDoc());
}
public <T extends Doc> PageBean<T> findPage(T t, Flipper flipper) {
if (flipper == null) {
flipper = new Flipper();
}
List<T> list = find(t, flipper.getOffset(), flipper.getLimit());
long count = count(t);
return PageBean.by(list, count);
}
public T findFirst(T t) {
return findFirst(arangoSource.parseAql(t, 0, 1), (Class<T>) t.getClass());
}
@@ -198,6 +210,9 @@ public abstract class Doc<T extends Doc> {
return find(t, 0, 1000);
}
public <T extends Doc> List<T> find(T t, int offset, int pn) {
if (t == null) {
t = (T) this;
}
return find(arangoSource.parseAql(t, offset, pn), (Class<T>)this.getClass());
}
@@ -226,6 +241,9 @@ public abstract class Doc<T extends Doc> {
return count(this);
}
public <T extends Doc> long count(T t) {
if (t == null) {
t = (T) this;
}
return db.query(arangoSource.parseAqlCount(t), long.class).first();
}
//ok