<?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.ruoyi.zdsz.mapper.ZBuildingMapper">

    <resultMap type="com.ruoyi.zdsz.domain.ZBuilding" id="ZBuildingResult">
        <result property="id" column="id"/>
        <result property="areaId" column="area_id"/>
        <result property="name" column="name"/>
        <result property="remark" column="remark"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <select id="getBuildingList" resultType="com.ruoyi.zdsz.domain.vo.ZBuildingVo">
        select id   as id,
               name as name
        from z_building
        where del_flag = '0'
        <if test="areaId != null and areaId != ''">
            and area_id = #{areaId}
        </if>
    </select>

    <select id="getPageList" resultType="com.ruoyi.zdsz.domain.vo.ZBuildingVo">
        select a.id as id,
        a.name as name,
        (select b.name from z_area b where b.id = a.area_id) as areaName
        from z_building a
        <where>
            a.del_flag = '0'
            <if test="p.name != null  and p.name != ''">
                and a.name LIKE CONCAT('%',#{p.name},'%')
            </if>
            <if test="p.areaId != null  and p.areaId != ''">
                and a.area_id = #{p.areaId}
            </if>
        </where>
    </select>

</mapper>
