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

    <resultMap type="com.ruoyi.zdsz.domain.ZComprehensive" id="ZComprehensiveResult">
        <result property="id" column="id"/>
        <result property="areaId" column="area_id"/>
        <result property="buildingId" column="building_id"/>
        <result property="unitId" column="unit_id"/>
        <result property="houseId" column="house_id"/>
        <result property="type" column="type"/>
        <result property="isQualified" column="is_qualified"/>
        <result property="isMaintenance" column="is_maintenance"/>
        <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="getPageList" resultType="com.ruoyi.zdsz.domain.vo.ZComprehensiveVo">
        SELECT
        zc.*,
        zh.NAME AS houseName,
        zt.NAME AS unitName,
        zb.NAME AS buildingName,
        za.NAME AS areaName
        FROM
        z_comprehensive AS zc
        LEFT JOIN z_house AS zh ON zh.id = zc.house_id
        LEFT JOIN z_unit AS zt ON zh.unit_id = zt.id
        LEFT JOIN z_building AS zb ON zt.building_id = zb.id
        LEFT JOIN z_area AS za ON zb.area_id = za.id
        where 1=1
           and zc.del_flag = '0'
          and zc.type = #{p.type}
            <if test="p.areaId != null  and p.areaId != ''">
                and zc.area_id = #{p.areaId}
            </if>
            <if test="p.buildingId != null  and p.buildingId != ''">
                and zc.building_id = #{p.buildingId}
            </if>
            <if test="p.unitId != null  and p.unitId != ''">
                and zc.unit_id = #{p.unitId}
            </if>
            <if test="p.houseId != null  and p.houseId != ''">
                and zc.house_id = #{p.houseId}
            </if>
    </select>

</mapper>
