@@ -76,12 +76,11 @@ public class DynPageHelper { | |||||
} | } | ||||
//构建树型查询语句,插入parent_id=? | //构建树型查询语句,插入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); | ModelTable table = ModelTableCache.getInstance().get(dataSet.masterTable); | ||||
if (table == null) throw new SwException("没有找到指定的表:" + dataSet.masterTable); | if (table == null) throw new SwException("没有找到指定的表:" + dataSet.masterTable); | ||||
SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params); | SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params); | ||||
if (table.getType() == SwEnum.TableType.TYPE_TREE.value) {//是树型结构,才做处理 | if (table.getType() == SwEnum.TableType.TYPE_TREE.value) {//是树型结构,才做处理 | ||||
long parentId = params.readLong("parent_id"); | |||||
ModelField field = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value); | ModelField field = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value); | ||||
if (field == null) throw new SwException("树型表(" + table.getName() + ")未定义上级id字段!"); | if (field == null) throw new SwException("树型表(" + table.getName() + ")未定义上级id字段!"); | ||||
@@ -1,5 +1,6 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | 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.SwEnum; | ||||
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; | ||||
@@ -51,8 +52,8 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> { | |||||
* 构建sql | * 构建sql | ||||
* @return | * @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 | @Override | ||||
protected List<SwMap> getChildren(long id) { | 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); | return DbEngine.getInstance().queryN(sqlPara.sql, sqlPara.mapParas, SwMap.class); | ||||
} | } | ||||
@@ -10,6 +10,7 @@ public interface SwConsts { | |||||
String SPLIT_CHAR = "-"; | String SPLIT_CHAR = "-"; | ||||
//默认根节点 | //默认根节点 | ||||
String DEF_ROOT_ID = "-1"; | String DEF_ROOT_ID = "-1"; | ||||
long DEF_ROOT_ID_LONG = -1; | |||||
//列表分页的页码和每页记录数 | //列表分页的页码和每页记录数 | ||||
String PARAM_PAGE = "page"; | String PARAM_PAGE = "page"; | ||||