<?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.dc.mapper.InterfaceManageMapper">

    <resultMap id="interfaceManageMap" type="com.tofly.dc.entity.InterfaceManage">
        <id property="id" column="ID"/>
        <result property="code" column="CODE"/>
        <result property="name" column="NAME"/>
        <result property="note" column="NOTE"/>
        <result property="ownershipSystem" column="OWNERSHIP_SYSTEM"/>
        <result property="ownershipBusiness" column="OWNERSHIP_BUSINESS"/>
        <result property="url" column="URL"/>
        <result property="runningStatus" column="RUNNING_STATUS"/>
        <result property="del" column="DEL"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="type" column="TYPE"/>
        <result property="contentType" column="CONTENT_TYPE"/>
        <association property="ownershipSystemName" column="OWNERSHIP_SYSTEM" select="getOwnershipSystemName"/>
        <association property="ownershipBusinessName" column="OWNERSHIP_BUSINESS" select="getOwnershipBusinessName"/>
        <association property="runningStatusName" column="RUNNING_STATUS" select="getRunningStatusName"/>
        <association property="delName" column="DEL" select="getDelName"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.dc.mapper.InterfaceLogMapper.getRealName"/>
        <association property="typeName" column="TYPE" select="getTypeName"/>
        <association property="contentTypeName" column="CONTENT_TYPE" select="getContentTypeName"/>
    </resultMap>

    <select id="getOwnershipSystemName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
        PCID =50001
        AND
        CCODE = #{ownershipSystem}
    </select>

    <select id="getOwnershipBusinessName" resultType="string">
        SELECT CNAME
        FROM
        TF_YWPN_SYSCHILDCODE_D
        WHERE
        PCID =50100
        AND
        CCODE = #{ownershipBusiness}
    </select>
    <select id="getRunningStatusName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
        PCID =50300
        AND
        CCODE = #{runningStatus}
    </select>
    <select id="getDelName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
        PCID =50600
        AND
        CCODE = #{del}
    </select>
    <select id="getTypeName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
        PCID =50200
        AND
        CCODE = #{type}
    </select>
    <select id="getContentTypeName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
        PCID =50400
        AND
        CCODE = #{contentType}
    </select>

    <select id="getByIdInterfaceManage" resultMap="interfaceManageMap">
        select * from TF_INTERFACE_MANAGE
        where ID = #{id}
    </select>
</mapper>
