1、使用Promise,重写red.getJSON /red.post, 解决"回调地狱"问题
2、修改 数据源管理/平台信息管理
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -15,6 +15,8 @@ public class DbExecutors {
|
||||
|
||||
String[] sqls = PARSER.parse(fBean);
|
||||
|
||||
|
||||
|
||||
return PageBean.by(Arrays.asList(Kv.of("findSql:", sqls[0]).set("countSql", sqls[1]) ), 0);
|
||||
}
|
||||
}
|
||||
|
||||
96
src/main/java/net/tccn/plat/DbPlat.java
Normal file
96
src/main/java/net/tccn/plat/DbPlat.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package net.tccn.plat;
|
||||
|
||||
import net.tccn.base.arango.Doc;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据库平台
|
||||
* @author: liangxianyou at 2018/11/14 12:58.
|
||||
*/
|
||||
@Table(name = "db_plat", catalog = "db_dev")
|
||||
public class DbPlat extends Doc<DbPlat> {
|
||||
public static DbPlat dao = dao(DbPlat.class);
|
||||
|
||||
private String name; //名称
|
||||
private String cate; //类型 mysql|ArangoDb
|
||||
private String remark; //备注
|
||||
private String url; //数据库连接地址
|
||||
private String user; //账号
|
||||
private String pwd; //密码
|
||||
private List<String> catalogs; //库
|
||||
private Integer status;//状态 1启用, 0 未启用
|
||||
|
||||
//------------- setter/getter ---------------
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCate() {
|
||||
return cate;
|
||||
}
|
||||
|
||||
public void setCate(String cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPwd() {
|
||||
return pwd;
|
||||
}
|
||||
|
||||
public void setPwd(String pwd) {
|
||||
this.pwd = pwd;
|
||||
}
|
||||
|
||||
public List<String> getCatalogs() {
|
||||
return catalogs;
|
||||
}
|
||||
|
||||
public void setCatalogs(List<String> catalogs) {
|
||||
this.catalogs = catalogs;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
}
|
||||
69
src/main/java/net/tccn/plat/PlatService.java
Normal file
69
src/main/java/net/tccn/plat/PlatService.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package net.tccn.plat;
|
||||
|
||||
import net.tccn.base.JBean;
|
||||
import net.tccn.base.Kv;
|
||||
import net.tccn.base.PageBean;
|
||||
import net.tccn.service.BaseService;
|
||||
import org.redkale.net.http.RestMapping;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.source.Flipper;
|
||||
import org.redkale.util.Comment;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestService(name = "plat", automapping = true, comment = "业务/数据平台")
|
||||
public class PlatService extends BaseService {
|
||||
|
||||
@RestMapping(name = "list", comment = "平台列表")
|
||||
public JBean list(SysPlat plat, Flipper flipper) {
|
||||
JBean jBean = new JBean();
|
||||
|
||||
PageBean<SysPlat> page = SysPlat.dao.findPage(plat, flipper);
|
||||
|
||||
return jBean.setBody(page);
|
||||
}
|
||||
|
||||
@Comment("平台信息保存")
|
||||
public JBean save(SysPlat plat) {
|
||||
if (plat.getKey() == null) {
|
||||
plat.save();
|
||||
} else {
|
||||
plat.update();
|
||||
}
|
||||
|
||||
return new JBean();
|
||||
}
|
||||
|
||||
@RestMapping(name = "info", comment = "平台详情")
|
||||
public void info(int key) {
|
||||
|
||||
}
|
||||
|
||||
//------------------------
|
||||
|
||||
@RestMapping(name = "db_list", comment = "数据源列表")
|
||||
public JBean dbList(DbPlat plat, Flipper flipper) {
|
||||
JBean jBean = new JBean();
|
||||
|
||||
PageBean<DbPlat> page = DbPlat.dao.findPage(plat, flipper);
|
||||
|
||||
return jBean.setBody(page);
|
||||
}
|
||||
|
||||
@RestMapping(name = "db_save", comment = "数据源信息保存")
|
||||
public JBean dbSave(String plat) {
|
||||
Map map = gson.fromJson(plat, Map.class);
|
||||
DbPlat dbPlat = Kv.toBean(map, DbPlat.class);
|
||||
|
||||
// todo: Kv.toBean 的内部属性深度转换,
|
||||
/*if (dbPlat.getKey() == null) {
|
||||
dbPlat.save();
|
||||
} else {
|
||||
dbPlat.update();
|
||||
}*/
|
||||
|
||||
return new JBean().setBody(dbPlat);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.tccn.dbq.qtask;
|
||||
package net.tccn.plat;
|
||||
|
||||
import net.tccn.base.arango.Doc;
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.tccn.base.JBean;
|
||||
import net.tccn.base.Kv;
|
||||
import net.tccn.dbq.Field;
|
||||
import net.tccn.dbq.jdbc.api.DbAccount;
|
||||
import net.tccn.dbq.qtask.SysPlat;
|
||||
import net.tccn.plat.SysPlat;
|
||||
import net.tccn.meta.MetaKit;
|
||||
import net.tccn.meta.MetaService;
|
||||
import net.tccn.meta.MetaTable;
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.tccn.base.JBean;
|
||||
import net.tccn.base.Kv;
|
||||
import net.tccn.dbq.jdbc.api.DbAccount;
|
||||
import net.tccn.dbq.qtask.Qtask;
|
||||
import net.tccn.dbq.qtask.SysPlat;
|
||||
import net.tccn.plat.SysPlat;
|
||||
import org.redkale.net.http.RestMapping;
|
||||
import org.redkale.net.http.RestParam;
|
||||
import org.redkale.net.http.RestService;
|
||||
|
||||
@@ -131,7 +131,7 @@ public class RunTest<T> {
|
||||
}).min().orElseGet(()-> 0);
|
||||
|
||||
System.out.println(xx);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user