<?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="io.renren.modules.levelManage.dao.LevelRelationDao">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="io.renren.modules.levelManage.entity.LevelRelationEntity" id="levelRelationMap">
        <result property="id" column="id"/>
        <result property="parentTableId" column="parent_table_id"/>
        <result property="parentRowId" column="parent_row_id"/>
        <result property="sonTableId" column="son_table_id"/>
        <result property="sonRowId" column="son_row_id"/>
    </resultMap>

    <select id="selectBySon" resultMap="levelRelationMap">
        SELECT * from level_relation
        where son_table_id=${tableId} and son_row_id=${id};
    </select>

    <select id="selectByParent" resultMap="levelRelationMap">
        SELECT * FROM level_relation
        where parent_table_id=${tableId} and parent_row_id=${id};
    </select>
    
    <select id="selectByParentRowAndSonTable" resultMap="levelRelationMap">
        SELECT * FROM level_relation
        WHERE son_table_id=#{tableId} and parent_row_id=#{parentRowId}
    </select>
</mapper>