<?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.gpsboot.mapper.plan.PlanMtRelMapper">

    <resultMap id="planMtRelMap" type="com.tofly.pojo.plan.PlanMtRel">
        <id property="id" column="ID"/>
        <result property="maintainId" column="MAINTAIN_ID"/>
        <result property="contentId" column="CONTENT_ID"/>
        <result property="state" column="STATE"/>
        <result property="note" column="NOTE"/>
        <association property="contentName" column="CONTENT_ID" select="getContentName"/>
        <association property="stateName" column="STATE" select="getMaintainStateName"/>
    </resultMap>

    <select id="getContentName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
            PCID =51900
          AND
            CCODE = #{contentId}
    </select>
    <select id="getMaintainStateName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
            PCID =51800
          AND
            CCODE = #{state}
    </select>


    <select id="getContentList" resultMap="planMtRelMap">
        select * from TF_YMPN_PLAN_MT_REL_W
        where MAINTAIN_ID = #{id}
    </select>
</mapper>
