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

    <resultMap id="syschildcodeMap" type="com.tofly.base.entity.Syschildcode">
        <id property="id" column="ID"/>
        <result property="pcid" column="PCID"/>
        <result property="pcname" column="PCNAME"/>
        <result property="ccode" column="CCODE"/>
        <result property="cname" column="CNAME"/>
        <result property="ccontert" column="CCONTERT"/>
        <result property="cdisable" column="CDISABLE"/>
        <result property="sort" column="SORT"/>
        <result property="flag" column="FLAG"/>
    </resultMap>
    <select id="getCodeById" resultType="string">
        select CNAME from TF_YWPN_SYSCHILDCODE_D where ID=#{id}
    </select>

    <select id="getSort" resultType="long">
        select nvl(max(SORT),0)+1 from TF_YWPN_SYSCHILDCODE_D where PCID=#{pcid}
    </select>
    <select id="getBylistPcid" resultMap="syschildcodeMap">
        select * from TF_YWPN_SYSCHILDCODE_D
        where cdisable=1
        start with id in
        <foreach collection="list" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
        connect by prior id=pcid
        group by id,pcid,pcname,ccode,cname,ccontert,cdisable,sort,flag
        order by pcid,ccode
    </select>


</mapper>
