<?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.tofly.base.mapper.UserAscriptionMapper">

  <resultMap id="userParentMap" type="com.tofly.base.entity.UserAscription">
      <id property="id" column="ID"/>
      <result property="parentUserId" column="PARENT_USER_ID"/>
      <result property="userId" column="USER_ID"/>
      <association property="parentUserIdName" column="PARENT_USER_ID" select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
      <association property="userIdName" column="USER_ID" select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
      <association property="parentUserLonginName" column="PARENT_USER_ID" select="getUserLonginName"/>
      <association property="userLonginName" column="USER_ID" select="getUserLonginName"/>
  </resultMap>

    <select id="getUserLonginName" resultType="String">
        select USERNAME
        from  TF_SMPN_USER_X
        where id = #{userId}
    </select>

</mapper>
