<?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.jeeplus.test.changes.dimission.mapper.ChangesDimissionHandoverMapper">

    <resultMap id="BaseResultMap" type="com.jeeplus.test.changes.dimission.service.dto.ChangesDimissionHandoverDTO">
            <id property="id" column="id" jdbcType="VARCHAR"/>
            <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
            <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
            <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
            <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
            <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
            <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
            <result property="cdId" column="cd_id" jdbcType="VARCHAR"/>
            <result property="parentId" column="parent_id" jdbcType="VARCHAR"/>
            <result property="type" column="type" jdbcType="VARCHAR"/>
            <result property="content" column="content" jdbcType="VARCHAR"/>
            <result property="rosterId" column="roster_id" jdbcType="VARCHAR"/>
            <collection property="handoverDTOList" ofType="com.jeeplus.test.changes.dimission.service.dto.ChangesDimissionHandoverDTO" column="id" select="getListByParentId"></collection>
    </resultMap>

    <sql id="Base_Column_List">
        cdh.id,
        cdh.create_by,
        cdh.create_date,
        cdh.update_by,
        cdh.update_date,
        cdh.del_flag,
        cdh.remarks,
        cdh.cd_id,
        cdh.parent_id,
        cdh.type,
        cdh.content,
        cdh.roster_id
    </sql>

    <sql id="Child_Column_List">
        cdhc.id,
        cdhc.create_by,
        cdhc.create_date,
        cdhc.update_by,
        cdhc.update_date,
        cdhc.del_flag,
        cdhc.remarks,
        cdhc.cd_id,
        cdhc.parent_id,
        cdhc.type,
        cdhc.content,
        cdhc.roster_id
    </sql>

    <select id="getListByParentId" resultType="com.jeeplus.test.changes.dimission.service.dto.ChangesDimissionHandoverDTO">
        select
        <include refid="Child_Column_List"></include>
        from changes_dimission_handover cdhc
        where cdhc.parent_id = ${id} and cdhc.del_flag = '0'
    </select>

    <select id="findList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from changes_dimission_handover cdh
        ${ew.customSqlSegment}
    </select>

    <select id="queryByCdId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from changes_dimission_handover cdh
        where cdh.del_flag = '0' and cdh.cd_id = ${id} and cdh.parent_id = '0'
    </select>

</mapper>
