<?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.ChangesDimissionHandoverInitializeMapper">

    <resultMap id="BaseResultMap" type="com.jeeplus.test.changes.dimission.service.dto.ChangesDimissionHandoverInitializeDTO">
            <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="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.ChangesDimissionHandoverInitializeDTO" column="id" select="getListByParentId"></collection>
    </resultMap>

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

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

    <select id="getListByParentId" resultType="com.jeeplus.test.changes.dimission.service.dto.ChangesDimissionHandoverInitializeDTO">
        select
        <include refid="Child_Column_List"></include>
        from changes_dimission_handover_initialize cdhic
        where cdhic.del_flag = '0' and cdhic.parent_id = #{id}
    </select>

    <select id="getList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from changes_dimission_handover_initialize cdhi
        where cdhi.del_flag = '0' and cdhi.parent_id = '0'
    </select>
</mapper>
