Newer
Older
huludao / src / main / resources / mapper / MeetAreaMapper.xml
<?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.newfiber.api.pc.dao.MeetAreaMapper">
    <resultMap id="meetAreaSiteMap" type="com.newfiber.api.pc.model.vo.MeetAreaSiteVo">
        <id column="a_id" property="aId" />
        <result column="area_name" property="areaName"/>
        <collection property="siteInfos" ofType="com.newfiber.api.pc.model.entity.ProSiteInfoEntity">
            <id property="id" column="id"/>
            <result property="siteNo" column="site_no"/>
            <result property="siteName" column="site_name"/>
        </collection>
    </resultMap>

    <select id="selectAreaById" resultMap="meetAreaSiteMap">
        select `ma`.a_id,`ma`.area_name,psi.site_no,psi.site_name,psi.id from
            meet_area `ma`
                LEFT JOIN
            meet_area_site `mas`
            on `ma`.a_id = `mas`.area_id
                LEFT JOIN pro_site_info psi
                          on `mas`.site_id = psi.site_no
        where `ma`.a_id = #{id}
    </select>

    <select id="selectAreaBySiteNo" resultType="com.newfiber.api.pc.model.meet.MeetArea">
        select a_id,area_name from meet_area where a_id = (select area_id from meet_area_site where site_id = #{siteNo})
    </select>

    <select id="queryAreaSiteCount" resultType="int">
        select count(*) from
                meet_area_site mas
            left join
                pro_site_info psi
            on mas.site_id = psi.site_no
        where
            mas.area_id = #{areaId}
        <if test="siteName != null and siteName != ''">
            and psi.site_name like concat('%','${siteName}','%')
        </if>
     </select>

     <select id="queryAreaSitePage" resultMap="meetAreaSiteMap">
         select `ma`.a_id,`ma`.area_name,psi.site_no,psi.site_name,psi.id from
             meet_area `ma`
                 LEFT JOIN
             meet_area_site `mas`
             on `ma`.a_id = `mas`.area_id
                 LEFT JOIN pro_site_info psi
                           on `mas`.site_id = psi.site_no
         where `ma`.a_id = #{areaId}
         <if test="siteName != null and siteName != ''">
             and psi.site_name like concat('%','${siteName}','%')
         </if>
         limit #{current},#{size}
     </select>

    <select id="queryAreaSite" resultMap="meetAreaSiteMap">
        select `ma`.a_id,`ma`.area_name,psi.site_no,psi.site_name,psi.id from
            meet_area `ma`
                LEFT JOIN
            meet_area_site `mas`
            on `ma`.a_id = `mas`.area_id
                LEFT JOIN pro_site_info psi
                          on `mas`.site_id = psi.site_no
        where `ma`.a_id = #{areaId}
    </select>

</mapper>