/**
*实体定义
*/
public class TreeNode {
/**
* id主键
* */
private Long id;
/**
* text显示的文本
* */
private String text;
/**
*state节点状态,'open' 或 'closed',默认:'open'。如果为'closed'的时候,将不自动展开该节点。
* */
private String state="open";
/**
*iconCls 节点图标id
* */
private String iconCls;
/**
* checked 是否被选中
* */
private boolean checked;
/**
*attributes 自定义属性
* */
private String attributes;
/**
* children 子节点
* */
private List<TreeNode> children;
}
/**
*service调用
*/
public List<TreeNode> getOrganizationTree(Long id)throws Exception {
return organizationMapperEx.getNodeTree(id);
}
/**
*mapper接口定义
*/
List<TreeNode> getNodeTree(@Param("currentId")Long currentId);
List<TreeNode> getNextNodeTree(Map<String, Object> parameterMap);
/**
*mapper实现
*重点关注{currentId=currentId,org_no=org_no}多参数传递
*/
<resultMap id="BaseTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNode">
<result column="id" property="id"/>
<result column="org_abr" property="text"/>
<result column="org_no" property="attributes"/>
<collection column="{currentId=currentId,org_no=org_no}" property="children" javaType="java.util.ArrayList"
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
</resultMap>
<resultMap id="NextTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNode">
<result column="id" property="id"/>
<result column="org_abr" property="text"/>
<result column="org_no" property="attributes"/>
<collection column="{currentId=currentId,org_no=org_no}" property="children" javaType="java.util.ArrayList"
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
</resultMap>
<sql id="Base_Column_List">
id, org_abr,org_no
</sql>
<select id="getNextNodeTree" resultMap="NextTreeResultMap">
SELECT
<include refid="Base_Column_List"/>,#{currentId} as currentId
FROM jsh_organization
WHERE org_parent_no = #{org_no}
<if test="currentId != null">
and id !=#{currentId}
</if>
and ifnull(org_stcd,'0') !='5'
order by sort asc
</select>
<select id="getNodeTree" resultMap="BaseTreeResultMap">
SELECT
<include refid="Base_Column_List"/>,#{currentId} as currentId
FROM jsh_organization
WHERE org_parent_no = -1
<if test="currentId != null">
and id !=#{currentId}
</if>
and ifnull(org_stcd,'0') !='5'
order by sort asc
</select>