Bläddra i källkod

树型加载

master
郑根木 2 år sedan
förälder
incheckning
a0e8138d5a
3 ändrade filer med 7 tillägg och 5 borttagningar
  1. +1
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java
  2. +5
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageTreeHandler.java
  3. +1
    -0
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java

+ 1
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java Visa fil

@@ -76,12 +76,11 @@ public class DynPageHelper {
}

//构建树型查询语句,插入parent_id=?
public static SqlNamedPara buildTreeSelectSql(PageDataset dataSet, SwMap params) {
public static SqlNamedPara buildTreeSelectSql(PageDataset dataSet, SwMap params, long parentId) {
ModelTable table = ModelTableCache.getInstance().get(dataSet.masterTable);
if (table == null) throw new SwException("没有找到指定的表:" + dataSet.masterTable);
SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params);
if (table.getType() == SwEnum.TableType.TYPE_TREE.value) {//是树型结构,才做处理
long parentId = params.readLong("parent_id");
ModelField field = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value);
if (field == null) throw new SwException("树型表(" + table.getName() + ")未定义上级id字段!");



+ 5
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageTreeHandler.java Visa fil

@@ -1,5 +1,6 @@
package cc.smtweb.system.bpm.web.engine.dynPage;

import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
@@ -51,8 +52,8 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> {
* 构建sql
* @return
*/
protected SqlNamedPara buildDataSqlPara() {
return DynPageHelper.buildTreeSelectSql(pageDataSet, filter);
protected SqlNamedPara buildDataSqlPara(long id) {
return DynPageHelper.buildTreeSelectSql(pageDataSet, filter, id);
}

/**
@@ -65,7 +66,8 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> {

@Override
protected List<SwMap> getChildren(long id) {
SqlNamedPara sqlPara = buildDataSqlPara();
if (id <= 0) id = SwConsts.DEF_ROOT_ID_LONG;
SqlNamedPara sqlPara = buildDataSqlPara(id);
return DbEngine.getInstance().queryN(sqlPara.sql, sqlPara.mapParas, SwMap.class);
}



+ 1
- 0
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java Visa fil

@@ -10,6 +10,7 @@ public interface SwConsts {
String SPLIT_CHAR = "-";
//默认根节点
String DEF_ROOT_ID = "-1";
long DEF_ROOT_ID_LONG = -1;

//列表分页的页码和每页记录数
String PARAM_PAGE = "page";


Laddar…
Avbryt
Spara