|
|
@@ -1,5 +1,6 @@ |
|
|
|
package cc.smtweb.system.bpm.web.design.table; |
|
|
|
|
|
|
|
import cc.smtweb.framework.core.common.SwEnum; |
|
|
|
import cc.smtweb.framework.core.common.SwMap; |
|
|
|
import cc.smtweb.framework.core.db.DbEngine; |
|
|
|
import cc.smtweb.framework.core.db.EntityDao; |
|
|
@@ -11,6 +12,8 @@ import cc.smtweb.framework.core.mvc.service.AbstractTreeHandler; |
|
|
|
import cc.smtweb.framework.core.mvc.service.TreeHelper; |
|
|
|
import cc.smtweb.framework.core.session.UserSession; |
|
|
|
import cc.smtweb.framework.core.util.CommUtil; |
|
|
|
import cc.smtweb.system.bpm.web.design.form.ModelForm; |
|
|
|
import cc.smtweb.system.bpm.web.design.form.ModelFormCache; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
@@ -19,11 +22,13 @@ import java.util.List; |
|
|
|
/** |
|
|
|
* Created by Akmm at 2022/3/21 18:22 |
|
|
|
*/ |
|
|
|
public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> { |
|
|
|
//查询类型:0-目录;1-表定义;2-页面定义 |
|
|
|
public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> { |
|
|
|
//查询类型:0-目录;1-表定义;2-页面;3-控件;4-页面和控件 |
|
|
|
private final static int TYPE_CATALOG = 0; |
|
|
|
private final static int TYPE_TABLE = 1; |
|
|
|
private final static int TYPE_PAGE = 2; |
|
|
|
private final static int TYPE_WIDGET = 3; |
|
|
|
private final static int TYPE_FORM = 4; |
|
|
|
|
|
|
|
private long prj_id;//所属项目 |
|
|
|
private int type;//查询类型:0-目录;1-表定义;2-页面定义 |
|
|
@@ -39,7 +44,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected List<Object> getChildren(Object bean) { |
|
|
|
protected List<DefaultEntity> getChildren(DefaultEntity bean) { |
|
|
|
if (bean instanceof ModelCatalog) { |
|
|
|
return super.getChildren(bean); |
|
|
|
} |
|
|
@@ -47,13 +52,12 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected List<Object> filterData() { |
|
|
|
List<Object> listRet = new ArrayList<>(); |
|
|
|
protected List<DefaultEntity> filterData() { |
|
|
|
|
|
|
|
EntityDao<ModelCatalog> dao = DbEngine.getInstance().findDao(ModelCatalog.ENTITY_NAME); |
|
|
|
String text = "%" + params.readString("text") + "%"; |
|
|
|
List<ModelCatalog> list = dao.queryWhere(" mc_prj_id=? and (mc_name like ? or mc_code like ?) order by mc_name", prj_id, text, text); |
|
|
|
listRet.addAll(list); |
|
|
|
List<DefaultEntity> listRet = new ArrayList<>(list); |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case TYPE_TABLE: |
|
|
@@ -62,55 +66,73 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> { |
|
|
|
listRet.addAll(l); |
|
|
|
break; |
|
|
|
case TYPE_PAGE: |
|
|
|
; |
|
|
|
case TYPE_WIDGET: |
|
|
|
case TYPE_FORM: |
|
|
|
EntityDao<ModelForm> formdao = DbEngine.getInstance().findDao(ModelForm.class); |
|
|
|
List<ModelForm> lf; |
|
|
|
if (type != TYPE_FORM) { |
|
|
|
lf = formdao.queryWhere(" mf_prj_id=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, text, text); |
|
|
|
} else { |
|
|
|
//数据库type 0-页面 1-控件 |
|
|
|
lf = formdao.queryWhere(" mf_prj_id=? and mf_type=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, type - 2, text, text); |
|
|
|
} |
|
|
|
listRet.addAll(lf); |
|
|
|
} |
|
|
|
return listRet; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected List<Object> getChildren(long id) { |
|
|
|
List<Object> listRet = new ArrayList<>(); |
|
|
|
protected List<DefaultEntity> getChildren(long id) { |
|
|
|
List<ModelCatalog> list; |
|
|
|
list = mcTreeHelper.getChildren(id, prj_id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); |
|
|
|
|
|
|
|
listRet.addAll(list); |
|
|
|
List<DefaultEntity> listRet = new ArrayList<>(list); |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case TYPE_TABLE: |
|
|
|
addTableChildren(listRet, id); |
|
|
|
break; |
|
|
|
case TYPE_PAGE: |
|
|
|
addPageChildren(listRet, id); |
|
|
|
case TYPE_WIDGET: |
|
|
|
case TYPE_FORM: |
|
|
|
addPageChildren(listRet, id, type); |
|
|
|
} |
|
|
|
return listRet; |
|
|
|
} |
|
|
|
|
|
|
|
//增加表 |
|
|
|
private void addTableChildren(List<Object> listRet, long id) { |
|
|
|
Collection<ModelTable> set = ModelTableCache.getInstance().getTablesByMc(id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); |
|
|
|
private void addTableChildren(List<DefaultEntity> listRet, long mcid) { |
|
|
|
Collection<ModelTable> set = ModelTableCache.getInstance().getTablesByMc(mcid, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); |
|
|
|
if (set == null || set.isEmpty()) return; |
|
|
|
|
|
|
|
listRet.addAll(set); |
|
|
|
} |
|
|
|
|
|
|
|
//增加页面定义 |
|
|
|
private void addPageChildren(List<Object> listRet, long id) { |
|
|
|
|
|
|
|
private void addPageChildren(List<DefaultEntity> listRet, long mcid, int type) { |
|
|
|
List<ModelForm> set = ModelFormCache.getInstance().getFormsByMc(mcid, (o1, o2) -> { |
|
|
|
if (o1.getType() != o2.getType()) return o1.getType() - o2.getType(); |
|
|
|
return CommUtil.chineseCompare(o1.getTitle(), o2.getTitle()); |
|
|
|
}); |
|
|
|
if (set == null || set.isEmpty()) return; |
|
|
|
if (type != TYPE_FORM) { |
|
|
|
for (ModelForm form: set) { |
|
|
|
if (form.getType() == type) { |
|
|
|
listRet.add(form); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
listRet.addAll(set); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected long getId(Object bean) { |
|
|
|
if (bean instanceof DefaultEntity) { |
|
|
|
return ((DefaultEntity) bean).getEntityId(); |
|
|
|
} |
|
|
|
if (bean instanceof ModelTable) { |
|
|
|
return ((ModelTable) bean).getId(); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
protected long getId(DefaultEntity bean) { |
|
|
|
return bean.getEntityId(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected String getText(Object bean) { |
|
|
|
protected String getText(DefaultEntity bean) { |
|
|
|
if (bean instanceof ModelCatalog) { |
|
|
|
return ((ModelCatalog) bean).getName(); |
|
|
|
} |
|
|
@@ -118,14 +140,14 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> { |
|
|
|
return ((ModelTable) bean).getTitle(); |
|
|
|
} |
|
|
|
|
|
|
|
/*if (bean instanceof ModelTable) { |
|
|
|
return ((ModelTable)bean).getTitle(); |
|
|
|
}*/ |
|
|
|
if (bean instanceof ModelForm) { |
|
|
|
return ((ModelForm)bean).getTitle(); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void buildNode(SwMap node, Object bean) { |
|
|
|
protected void buildNode(SwMap node, DefaultEntity bean) { |
|
|
|
super.buildNode(node, bean); |
|
|
|
if (bean instanceof ModelCatalog) { |
|
|
|
node.put("type", TYPE_CATALOG); |
|
|
|