@@ -1,10 +1,8 @@ | |||||
package cc.smtweb.system.bpm.web.design.form; | package cc.smtweb.system.bpm.web.design.form; | ||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.common.SwConsts; | |||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
@@ -93,14 +91,14 @@ public class ModelFormHelper { | |||||
PageModel pageInfo = parsePageInfo(jsonStr); | PageModel pageInfo = parsePageInfo(jsonStr); | ||||
if (pageInfo == null) return ""; | if (pageInfo == null) return ""; | ||||
for (Map<String, Object> model : pageInfo.model) { | for (Map<String, Object> model : pageInfo.model) { | ||||
buildSaveModelFields(datasets, pageInfo, model, true); | |||||
buildSaveModelFields(datasets, pageInfo, model, false); | |||||
buildSaveModelFields(datasets, model, true); | |||||
buildSaveModelFields(datasets, model, false); | |||||
} | } | ||||
return JsonUtil.encodeString(pageInfo); | return JsonUtil.encodeString(pageInfo); | ||||
} | } | ||||
//处理model的fields和filters | //处理model的fields和filters | ||||
private static void buildSaveModelFields(PageDatasets datasets, PageModel pageInfo, Map<String, Object> model, boolean isField) { | |||||
private static void buildSaveModelFields(PageDatasets datasets, Map<String, Object> model, boolean isField) { | |||||
String db = (String) model.get("dataset"); | String db = (String) model.get("dataset"); | ||||
//没有配置db,配置有误,不处理 | //没有配置db,配置有误,不处理 | ||||
if (StringUtils.isEmpty(db)) throw new BizException("model未配置数据集db,无法解析!"); | if (StringUtils.isEmpty(db)) throw new BizException("model未配置数据集db,无法解析!"); | ||||
@@ -111,7 +109,7 @@ public class ModelFormHelper { | |||||
for (Map<String, Object> field : fields) { | for (Map<String, Object> field : fields) { | ||||
String fn = (String) field.get("field"); | String fn = (String) field.get("field"); | ||||
if (StringUtils.isEmpty(fn)) throw new BizException("model[" + db + "]." + key + "未配置字段名field,无法解析!"); | if (StringUtils.isEmpty(fn)) throw new BizException("model[" + db + "]." + key + "未配置字段名field,无法解析!"); | ||||
PageDatasetField pdf = isField ? pds.findFieldByName(fn) : pds.findFilterByName(fn); | |||||
BaseDatasetField pdf = isField ? pds.findFieldByName(fn) : pds.findFilterByName(fn); | |||||
if (pdf == null) throw new BizException("model[" + db + "]." + key + "未找到定义的数据集字段(" + fn + "),无法解析!"); | if (pdf == null) throw new BizException("model[" + db + "]." + key + "未找到定义的数据集字段(" + fn + "),无法解析!"); | ||||
if (CommUtil.isStrEquals(MapUtil.readString(field, "label"), pdf.label)) { | if (CommUtil.isStrEquals(MapUtil.readString(field, "label"), pdf.label)) { | ||||
@@ -152,9 +150,9 @@ public class ModelFormHelper { | |||||
* @return | * @return | ||||
* @throws JsonProcessingException | * @throws JsonProcessingException | ||||
*/ | */ | ||||
public static void buildSaveDataSetFields(List<? extends PageDatasetField> fields) { | |||||
public static void buildSaveDataSetFields(List<? extends BaseDatasetField> fields) { | |||||
ModelTable table = null; | ModelTable table = null; | ||||
for (PageDatasetField field : fields) { | |||||
for (BaseDatasetField field : fields) { | |||||
if (field.table <= 0) continue; | if (field.table <= 0) continue; | ||||
if (table == null || table.getEntityId() != field.table) { | if (table == null || table.getEntityId() != field.table) { | ||||
table = ModelTableCache.getInstance().get(field.table); | table = ModelTableCache.getInstance().get(field.table); | ||||
@@ -212,7 +210,7 @@ public class ModelFormHelper { | |||||
for (Map<String, Object> field : fields) { | for (Map<String, Object> field : fields) { | ||||
String fn = (String) field.get("field"); | String fn = (String) field.get("field"); | ||||
if (StringUtils.isEmpty(fn)) continue; | if (StringUtils.isEmpty(fn)) continue; | ||||
PageDatasetField pdf = isField ? dataSet.findFieldByName(fn) : dataSet.findFilterByName(fn); | |||||
BaseDatasetField pdf = isField ? dataSet.findFieldByName(fn) : dataSet.findFilterByName(fn); | |||||
if (pdf == null) continue; | if (pdf == null) continue; | ||||
if (!field.containsKey("label")) { | if (!field.containsKey("label")) { | ||||
field.put("label", pdf.label); | field.put("label", pdf.label); | ||||
@@ -431,7 +429,7 @@ public class ModelFormHelper { | |||||
if (dataset == null) throw new BizException("没有找到指定数据集:" + dsId); | if (dataset == null) throw new BizException("没有找到指定数据集:" + dsId); | ||||
} | } | ||||
String fn = MapUtil.readString(field, "field"); | String fn = MapUtil.readString(field, "field"); | ||||
PageDatasetField pdf; | |||||
BaseDatasetField pdf; | |||||
if (!isField) { | if (!isField) { | ||||
pdf = dataset.findFilterById(fn); | pdf = dataset.findFilterById(fn); | ||||
} else { | } else { | ||||
@@ -0,0 +1,39 @@ | |||||
package cc.smtweb.system.bpm.web.design.form.define; | |||||
import com.fasterxml.jackson.annotation.JsonIgnore; | |||||
/** | |||||
* Created by Akmm at 2022/4/20 18:15 | |||||
*/ //字段要素 | |||||
public class BaseDatasetField { | |||||
public String id; | |||||
//表 | |||||
public long table; | |||||
public String table_text; | |||||
//字段 | |||||
public String field = ""; | |||||
//有别名取别名,无别名同字段名 | |||||
public String name; | |||||
public String label; | |||||
public String remark; | |||||
//字段类型,如编码字段,参见FieldTypeDef | |||||
public int fieldType; | |||||
/** | |||||
* 数据类型,参见DataType | |||||
*/ | |||||
public String dataType; | |||||
/** | |||||
* '禁止为空' | |||||
*/ | |||||
public int notNull; | |||||
//外键关联表 | |||||
public long link; | |||||
//控件类型:TEXT/TextArea/NUMBER/COMBO | |||||
public String editor; | |||||
@JsonIgnore | |||||
public boolean isFieldNotNull() { | |||||
return notNull == 1; | |||||
} | |||||
} |
@@ -2,7 +2,6 @@ package cc.smtweb.system.bpm.web.design.form.define; | |||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
@@ -52,6 +51,7 @@ public class PageDataset { | |||||
//依赖的数据集 | //依赖的数据集 | ||||
private Set<String> linkDs = new HashSet<>(); | private Set<String> linkDs = new HashSet<>(); | ||||
private boolean calcField = false; | |||||
public PageDatasetField findFieldByName(String name) { | public PageDatasetField findFieldByName(String name) { | ||||
if (mapFieldName == null) resetFields(); | if (mapFieldName == null) resetFields(); | ||||
@@ -84,15 +84,9 @@ public class PageDataset { | |||||
mapFilterName = new HashMap<>(); | mapFilterName = new HashMap<>(); | ||||
mapFilterId = new HashMap<>(); | mapFilterId = new HashMap<>(); | ||||
resetFields(mapFilterName, mapFilterId, filters, true); | resetFields(mapFilterName, mapFilterId, filters, true); | ||||
for (PageDatasetFilter filter : filters) { | |||||
if (StringUtils.isEmpty(filter.sqlName)) { | |||||
filter.sqlName = filter.field; | |||||
} | |||||
} | |||||
} | } | ||||
private <T extends PageDatasetField> void resetFields(Map<String, T> mapName, Map<String, T> mapId, List<T> list, boolean isFilter) { | |||||
private <T extends BaseDatasetField> void resetFields(Map<String, T> mapName, Map<String, T> mapId, List<T> list, boolean isFilter) { | |||||
ModelTableCache cache = ModelTableCache.getInstance(); | ModelTableCache cache = ModelTableCache.getInstance(); | ||||
ModelTable table = null; | ModelTable table = null; | ||||
for (T field : list) { | for (T field : list) { | ||||
@@ -118,6 +112,12 @@ public class PageDataset { | |||||
if (isFilter) { | if (isFilter) { | ||||
PageDatasetFilter filter = (PageDatasetFilter) field; | PageDatasetFilter filter = (PageDatasetFilter) field; | ||||
if (StringUtils.isNotEmpty(filter.linkDb)) linkDs.add(filter.linkDb); | if (StringUtils.isNotEmpty(filter.linkDb)) linkDs.add(filter.linkDb); | ||||
if (StringUtils.isEmpty(filter.sqlName)) { | |||||
filter.sqlName = filter.field; | |||||
} | |||||
} else { | |||||
calcField = calcField || ((PageDatasetField)field).fieldIsCalc(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -131,7 +131,13 @@ public class PageDataset { | |||||
return null; | return null; | ||||
} | } | ||||
//是否依赖指定数据集 | |||||
public boolean hasDepends(String dsName) { | public boolean hasDepends(String dsName) { | ||||
return linkDs.contains(dsName); | return linkDs.contains(dsName); | ||||
} | } | ||||
//是否有计算字段 | |||||
public boolean hasCalcField() { | |||||
return calcField; | |||||
} | |||||
} | } |
@@ -1,41 +1,25 @@ | |||||
package cc.smtweb.system.bpm.web.design.form.define; | package cc.smtweb.system.bpm.web.design.form.define; | ||||
import com.fasterxml.jackson.annotation.JsonIgnore; | |||||
/** | /** | ||||
* Created by Akmm at 2022/4/20 18:15 | * Created by Akmm at 2022/4/20 18:15 | ||||
*/ //字段要素 | |||||
public class PageDatasetField { | |||||
public String id; | |||||
//表 | |||||
public long table; | |||||
public String table_text; | |||||
//字段 | |||||
public String field = ""; | |||||
//有别名取别名,无别名同字段名 | |||||
public String name; | |||||
public String label; | |||||
* 字段信息 | |||||
*/ | |||||
public class PageDatasetField extends BaseDatasetField { | |||||
//一般字段 | |||||
private final static int TYPE_N = 0; | |||||
//计算字段 | |||||
private final static int TYPE_C = 1; | |||||
//合计栏 | //合计栏 | ||||
public String summary; | public String summary; | ||||
//类型-0-一般字段 1-计算字段 | |||||
public int type; | |||||
//计算字段公式 | |||||
public String expr; | |||||
public String remark; | |||||
//字段类型,如编码字段,参见FieldTypeDef | |||||
public int fieldType; | |||||
/** | |||||
* 数据类型,参见DataType | |||||
*/ | |||||
public String dataType; | |||||
/** | |||||
* '禁止为空' | |||||
*/ | |||||
public int notNull; | |||||
//外键关联表 | |||||
public long link; | |||||
//控件类型:TEXT/TextArea/NUMBER/COMBO | |||||
public String editor; | |||||
@JsonIgnore | |||||
public boolean isFieldNotNull() { | |||||
return notNull == 1; | |||||
//字段是否计算字段 | |||||
public boolean fieldIsCalc() { | |||||
return TYPE_C == type; | |||||
} | } | ||||
} | } |
@@ -3,7 +3,7 @@ package cc.smtweb.system.bpm.web.design.form.define; | |||||
/** | /** | ||||
* Created by Akmm at 2022/4/20 18:15 | * Created by Akmm at 2022/4/20 18:15 | ||||
*/ //过滤条件信息 | */ //过滤条件信息 | ||||
public class PageDatasetFilter extends PageDatasetField { | |||||
public class PageDatasetFilter extends BaseDatasetField { | |||||
//param-参数/link/const | //param-参数/link/const | ||||
public String type; | public String type; | ||||
public String title; | public String title; | ||||
@@ -3,7 +3,6 @@ package cc.smtweb.system.bpm.web.engine.dynPage; | |||||
import cc.smtweb.framework.core.common.SwConsts; | import cc.smtweb.framework.core.common.SwConsts; | ||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
@@ -12,6 +11,7 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.mvc.service.SqlNamedPara; | import cc.smtweb.framework.core.mvc.service.SqlNamedPara; | ||||
import cc.smtweb.framework.core.util.MapUtil; | import cc.smtweb.framework.core.util.MapUtil; | ||||
import cc.smtweb.framework.core.util.NumberUtil; | |||||
import cc.smtweb.system.bpm.web.design.form.define.*; | import cc.smtweb.system.bpm.web.design.form.define.*; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
@@ -71,12 +71,19 @@ public class DynPageHelper { | |||||
return sqlNamedPara; | return sqlNamedPara; | ||||
} | } | ||||
/** | |||||
* 构建合计栏sql | |||||
* @param dataSet | |||||
* @param params | |||||
* @return | |||||
*/ | |||||
public static SqlNamedPara buildSumSql(PageDataset dataSet, Map<String, Object> params) { | public static SqlNamedPara buildSumSql(PageDataset dataSet, Map<String, Object> params) { | ||||
SqlNamedPara sqlNamedPara = buildSelectSql(dataSet, params); | SqlNamedPara sqlNamedPara = buildSelectSql(dataSet, params); | ||||
StringBuilder sql = new StringBuilder(256); | StringBuilder sql = new StringBuilder(256); | ||||
sql.append("select count(1) " + TOTAL_KEY); | sql.append("select count(1) " + TOTAL_KEY); | ||||
for (PageDatasetField field : dataSet.fields) { | for (PageDatasetField field : dataSet.fields) { | ||||
if (StringUtils.isEmpty(field.summary)) continue; | if (StringUtils.isEmpty(field.summary)) continue; | ||||
if (field.fieldIsCalc()) continue; | |||||
sql.append(","); | sql.append(","); | ||||
if (!SwEnum.SummaryType.instance.isText(field.summary)) { | if (!SwEnum.SummaryType.instance.isText(field.summary)) { | ||||
sql.append(field.summary).append("(").append(field.name).append(") ").append(field.name); | sql.append(field.summary).append("(").append(field.name).append(") ").append(field.name); | ||||
@@ -96,6 +103,7 @@ public class DynPageHelper { | |||||
if (!SwEnum.DatasetType.LIST.equals(dataSet.type) || StringUtils.isEmpty(dataSet.sql)) { | if (!SwEnum.DatasetType.LIST.equals(dataSet.type) || StringUtils.isEmpty(dataSet.sql)) { | ||||
sql.append("select "); | sql.append("select "); | ||||
for (PageDatasetField field : dataSet.fields) { | for (PageDatasetField field : dataSet.fields) { | ||||
if (field.fieldIsCalc()) continue; | |||||
sql.append(field.field); | sql.append(field.field); | ||||
//加别名 | //加别名 | ||||
if (!field.field.equalsIgnoreCase(field.name)) { | if (!field.field.equalsIgnoreCase(field.name)) { | ||||
@@ -198,6 +206,19 @@ public class DynPageHelper { | |||||
return builder.build(dynCond.opt, filter.sqlName, ns, value, args); | return builder.build(dynCond.opt, filter.sqlName, ns, value, args); | ||||
} | } | ||||
/** | |||||
* 处理计算字段 | |||||
* @param data | |||||
* @param dataset | |||||
*/ | |||||
public static void setCalcFields(SwMap data, PageDataset dataset) { | |||||
if (!dataset.hasCalcField()) return; | |||||
for (PageDatasetField field: dataset.fields) { | |||||
if (!field.fieldIsCalc()) continue; | |||||
data.put(field.name, NumberUtil.calcExprMapObject(field.expr, data)); | |||||
} | |||||
} | |||||
private static Map<String, IBuilderExpr> mapBuilder; | private static Map<String, IBuilderExpr> mapBuilder; | ||||
private static IBuilderExpr baseBuilder; | private static IBuilderExpr baseBuilder; | ||||
@@ -17,6 +17,7 @@ import static cc.smtweb.framework.core.common.SwConsts.TOTAL_KEY; | |||||
/** | /** | ||||
* Created by Akmm at 2022/5/26 15:58 | * Created by Akmm at 2022/5/26 15:58 | ||||
* 动态页面列表服务 | |||||
*/ | */ | ||||
public class DynPageListHandler extends AbstractListHandler { | public class DynPageListHandler extends AbstractListHandler { | ||||
protected long pageId; | protected long pageId; | ||||
@@ -58,6 +59,9 @@ public class DynPageListHandler extends AbstractListHandler { | |||||
} | } | ||||
ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ||||
EntityHelper.loadBeanLink(masterTable.getName(), list, sp.mapFieldAlias); | EntityHelper.loadBeanLink(masterTable.getName(), list, sp.mapFieldAlias); | ||||
for (SwMap map: list) { | |||||
DynPageHelper.setCalcFields(map, pageDataSet); | |||||
} | |||||
return list; | return list; | ||||
} | } | ||||
@@ -25,6 +25,13 @@ public class DynPageLoadHandler extends AbstractDynPageHandler { | |||||
return listHandler; | return listHandler; | ||||
} | } | ||||
//树工具类 | |||||
public DynPageTreeHandler getTreeWorker(SwMap filter, PageDataset pageDataSet) { | |||||
DynPageTreeHandler listHandler = new DynPageTreeHandler(pageId, filter, pageDataSet); | |||||
listHandler.init(params, us); | |||||
return listHandler; | |||||
} | |||||
//新增操作,初始化定义的数据集 | //新增操作,初始化定义的数据集 | ||||
public R add() { | public R add() { | ||||
//返回的数据,以dataset.name为key,查出的结果(bean或list)为value | //返回的数据,以dataset.name为key,查出的结果(bean或list)为value | ||||
@@ -85,7 +92,7 @@ public class DynPageLoadHandler extends AbstractDynPageHandler { | |||||
if (SwEnum.DatasetType.LIST.value.equals(pageDataSet.type)) {//列表类 | if (SwEnum.DatasetType.LIST.value.equals(pageDataSet.type)) {//列表类 | ||||
bean = DynRetBean.createList(getListWorker(filter, pageDataSet).buildListData()); | bean = DynRetBean.createList(getListWorker(filter, pageDataSet).buildListData()); | ||||
} else if (SwEnum.DatasetType.TREE.value.equals(pageDataSet.type)) {//树类 | } else if (SwEnum.DatasetType.TREE.value.equals(pageDataSet.type)) {//树类 | ||||
// return new DynRetBean(loadTree()); | |||||
// return DynRetBean.createList(SwListData.create(getTreeWorker(filter, pageDataSet).buildData())); | |||||
} else {//列表类 | } else {//列表类 | ||||
bean = DynRetBean.createBean(provider.loadData(filter, pageDataSet)); | bean = DynRetBean.createBean(provider.loadData(filter, pageDataSet)); | ||||
} | } | ||||
@@ -9,7 +9,10 @@ import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.mvc.service.AbstractCompProvider; | import cc.smtweb.framework.core.mvc.service.AbstractCompProvider; | ||||
import cc.smtweb.framework.core.mvc.service.SqlNamedPara; | import cc.smtweb.framework.core.mvc.service.SqlNamedPara; | ||||
import cc.smtweb.framework.core.util.CommUtil; | |||||
import cc.smtweb.framework.core.util.NumberUtil; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | ||||
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetField; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDatasets; | import cc.smtweb.system.bpm.web.design.form.define.PageDatasets; | ||||
/** | /** | ||||
@@ -29,8 +32,10 @@ public class DynPageProvider extends AbstractCompProvider { | |||||
} | } | ||||
ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ||||
EntityHelper.loadBeanLink(masterTable.getName(), map, sqlPara.mapFieldAlias); | EntityHelper.loadBeanLink(masterTable.getName(), map, sqlPara.mapFieldAlias); | ||||
DynPageHelper.setCalcFields(map, pageDataSet); | |||||
return map; | return map; | ||||
}); | }); | ||||
} | } | ||||
} | } |
@@ -0,0 +1,61 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
import cc.smtweb.framework.core.db.vo.ModelCatalog; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.mvc.service.AbstractTreeHandler; | |||||
import cc.smtweb.system.bpm.web.design.form.ModelForm; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | |||||
* Created by Akmm at 2022/7/5 11:51 | |||||
* 动态页面树型服务 | |||||
*/ | |||||
public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> { | |||||
protected long pageId; | |||||
//过滤条件 | |||||
private SwMap filter; | |||||
//对应的数据集定义 | |||||
private PageDataset pageDataSet; | |||||
public DynPageTreeHandler(long pageId, SwMap filter, PageDataset pageDataSet) { | |||||
this.pageId = pageId; | |||||
this.filter = filter; | |||||
this.pageDataSet = pageDataSet; | |||||
} | |||||
@Override | |||||
protected List<SwMap> filterData() { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | |||||
if (table == null) throw new BizException("未找到数据集表定义:" + pageDataSet.masterTable); | |||||
EntityDao dao = DbEngine.getInstance().findDao(table.getName()); | |||||
String text = "%" + params.readString("text") + "%"; | |||||
List<SwMap> list = null;//dao.queryWhere(" mc_prj_id=? and (mc_name like ? or mc_code like ?) order by mc_name", prj_id, text, text); | |||||
return list; | |||||
} | |||||
@Override | |||||
protected List<SwMap> getChildren(long id) { | |||||
return null; | |||||
} | |||||
@Override | |||||
protected long getId(SwMap bean) { | |||||
return 0; | |||||
} | |||||
@Override | |||||
protected String getText(SwMap bean) { | |||||
return null; | |||||
} | |||||
} |
@@ -15,16 +15,24 @@ import java.util.List; | |||||
public abstract class AbstractTreeHandler<T> extends AbstractHandler { | public abstract class AbstractTreeHandler<T> extends AbstractHandler { | ||||
//树过滤 | //树过滤 | ||||
public R filter() { | public R filter() { | ||||
return R.success(buildFilter()); | |||||
} | |||||
//构建过滤数据 | |||||
public List<SwMap> buildFilter() { | |||||
List<T> rows = filterData(); | List<T> rows = filterData(); | ||||
List<SwMap> listRet = buildNodes(rows, true); | |||||
return R.success(listRet); | |||||
return buildNodes(rows, true); | |||||
} | } | ||||
//下拉数据 | |||||
public R data() { | public R data() { | ||||
List<T> rows = getChildren(params.readLong("parent_id")); | |||||
List<SwMap> listRet = buildNodes(rows, params.readBool("lazy")); | |||||
return R.success(buildData()); | |||||
} | |||||
return R.success(listRet); | |||||
//构建 | |||||
public List<SwMap> buildData() { | |||||
List<T> rows = getChildren(params.readLong("parent_id")); | |||||
return buildNodes(rows, params.readBool("lazy")); | |||||
} | } | ||||
//搜索 | //搜索 | ||||