<?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="org.dromara.system.mapper.TblDzbcPathSiteMapper">

    <resultMap type="org.dromara.system.domain.vo.TblDzbcPathSiteVo" id="TblDzbcPathSiteResult">
        <result property="id"    column="id"    />
        <result property="pathId"    column="path_id"    />
        <result property="siteId"    column="site_id"    />
        <result property="siteName"    column="site_name"    />
        <result property="siteAddr"    column="site_addr"    />
        <result property="siteOrder"    column="site_order"    />
        <result property="remark"    column="remark"    />
        <result property="ext1"    column="ext1"    />
        <result property="ext2"    column="ext2"    />
    </resultMap>

    <select id="selectVoList" parameterType="org.dromara.system.domain.vo.TblDzbcPathSiteVo" resultMap="TblDzbcPathSiteResult">
        select ps.id, ps.path_id, ps.site_id, ps.site_order, ps.remark, ps.ext1, ps.ext2,
               s.name as site_name, s.addr as site_addr
        from tbl_dzbc_path_site ps
        left join tbl_dzbc_site s on ps.site_id = s.id
        <where>
            <if test="pathId != null">
                and ps.path_id = #{pathId}
            </if>
            <if test="siteId != null">
                and ps.site_id = #{siteId}
            </if>
        </where>
        order by ps.site_order asc
    </select>

    <select id="selectVoById" parameterType="Long" resultMap="TblDzbcPathSiteResult">
        select ps.id, ps.path_id, ps.site_id, ps.site_order, ps.remark, ps.ext1, ps.ext2,
               s.name as site_name, s.addr as site_addr
        from tbl_dzbc_path_site ps
        left join tbl_dzbc_site s on ps.site_id = s.id
        where ps.id = #{id}
    </select>

    <select id="selectVoByIds" parameterType="Collection" resultMap="TblDzbcPathSiteResult">
        select ps.id, ps.path_id, ps.site_id, ps.site_order, ps.remark, ps.ext1, ps.ext2,
               s.name as site_name, s.addr as site_addr
        from tbl_dzbc_path_site ps
        left join tbl_dzbc_site s on ps.site_id = s.id
        where ps.id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <select id="selectByPathId" parameterType="Long" resultMap="TblDzbcPathSiteResult">
        select ps.id, ps.path_id, ps.site_id, ps.site_order, ps.remark, ps.ext1, ps.ext2,
               s.name as site_name, s.addr as site_addr
        from tbl_dzbc_path_site ps
        left join tbl_dzbc_site s on ps.site_id = s.id
        where ps.path_id = #{pathId}
        order by ps.site_order asc
    </select>

</mapper>
