DO.java
@Data
public class SysOrgTreeModel {
private String sysOrgId;
private String tenantId;
private String pid;
private String dictOrgType;
private String name;
private Integer level;
private String description;
private String address;
private String email;
private String contactPersonName;
private String contactPersonPhone;
private String dictSysOrgStatus;
private Long createTime;
private Long updateTime;
private List<SysOrgTreeModel> childList;
}
Mapper.java
public interface SysOrgMapper {
List<SysOrgTreeModel> listChildOrgTree(@Param("tenantId") String tenantId, @Param("pid") String pid);
}
Mapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.foo.mapperSysOrgMapper">
<resultMap id="BaseTreeResultMap" type="com.foo.model.SysOrgTreeModel">
<id column="sys_org_id" property="sysOrgId" jdbcType="VARCHAR"/>
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
<result column="pid" property="pid" jdbcType="VARCHAR"/>
<result column="dict_org_type" property="dictOrgType" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="contact_person_name" property="contactPersonName" jdbcType="VARCHAR"/>
<result column="contact_person_phone" property="contactPersonPhone" jdbcType="VARCHAR"/>
<result column="dict_sys_org_status" property="dictSysOrgStatus" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="BIGINT"/>
<collection column="tenantId=tenant_id, pid=sys_org_id" property="childList" javaType="java.util.ArrayList"
ofType="com.foo.model.SysOrgTreeModel" select="getNextSysOrgTree"/>
</resultMap>
<!--定义嵌套集合,并指定下一嵌套集合的查询条件-->
<resultMap id="NextTreeResultMap" type="com.foo.model.SysOrgTreeModel">
<id column="sys_org_id" property="sysOrgId" jdbcType="VARCHAR"/>
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
<result column="pid" property="pid" jdbcType="VARCHAR"/>
<result column="dict_org_type" property="dictOrgType" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="contact_person_name" property="contactPersonName" jdbcType="VARCHAR"/>
<result column="contact_person_phone" property="contactPersonPhone" jdbcType="VARCHAR"/>
<result column="dict_sys_org_status" property="dictSysOrgStatus" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="BIGINT"/>
<collection column="tenantId=tenant_id, pid=sys_org_id" property="childList" javaType="java.util.ArrayList"
ofType="com.foo.model.SysOrgTreeModel" select="getNextSysOrgTree"/>
</resultMap>
<sql id="Base_Column_List">
sys_org_id, tenant_id, pid, dict_org_type, name, level, description, address, email,
contact_person_name, contact_person_phone, dict_sys_org_status, create_time, update_time
</sql>
<!--定义嵌套集合查询语句,查询条件由调用处通过column设定-->
<select id="getNextSysOrgTree" resultMap="NextTreeResultMap" parameterType="java.util.Map">
SELECT
<include refid="Base_Column_List"/>
FROM sys_org
WHERE tenant_id = #{tenantId}
and pid = #{pid}
</select>
<select id="listChildOrgTree" resultMap="BaseTreeResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys_org
WHERE tenant_id = #{tenantId}
and pid = #{pid}
</select>
</mapper>
网友评论