<?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.szxc.mapper.SzxcHouseInfoMapper">

    <resultMap type="SzxcHouseInfo" id="SzxcHouseInfoResult">
        <result property="id"    column="id"    />
        <result property="ownerId"    column="owner_id"    />
        <result property="ownerName"    column="owner_name"    />
        <result property="cardId"    column="card_id"    />
        <result property="xqId"    column="xq_id"    />
        <result property="houseName"    column="house_name"    />
        <result property="buildId"    column="build_id"    />
        <result property="ldName"    column="ld_name"    />
        <result property="unit"    column="unit"    />
        <result property="doorNo"    column="door_no"    />
        <result property="houseType"    column="house_type"    />
        <result property="houseArea"    column="house_area"    />
        <result property="houseProp"    column="house_prop"    />
        <result property="qnfs"    column="qnfs"    />
        <result property="toiletType"    column="toilet_type"    />
        <result property="houseIntro"    column="house_intro"    />
        <result property="housePicture"    column="house_picture"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcHouseInfoVo">
        select id, owner_id, owner_name, card_id, xq_id, house_name, build_id, ld_name, unit, door_no, house_type, house_area, house_prop, qnfs, toilet_type, house_intro, house_picture, create_by, create_time, update_by, update_time, dept_id, dept_name, user_id from szxc_house_info
    </sql>

    <select id="selectSzxcHouseInfoList" parameterType="SzxcHouseInfo" resultMap="SzxcHouseInfoResult">
        <include refid="selectSzxcHouseInfoVo"/> as h
        <where>
            <if test="ownerId != null "> and owner_id = #{ownerId}</if>
            <if test="ownerName != null  and ownerName != ''"> and owner_name like concat('%', #{ownerName}, '%')</if>
            <if test="cardId != null  and cardId != ''"> and card_id = #{cardId}</if>
            <if test="xqId != null "> and xq_id = #{xqId}</if>
            <if test="houseName != null  and houseName != ''"> and house_name like concat('%', #{houseName}, '%')</if>
            <if test="buildId != null "> and build_id = #{buildId}</if>
            <if test="ldName != null  and ldName != ''"> and ld_name like concat('%', #{ldName}, '%')</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="doorNo != null  and doorNo != ''"> and door_no = #{doorNo}</if>
            <if test="houseType != null  and houseType != ''"> and house_type = #{houseType}</if>
            <if test="houseArea != null  and houseArea != ''"> and house_area = #{houseArea}</if>
            <if test="houseProp != null  and houseProp != ''"> and house_prop = #{houseProp}</if>
            <if test="qnfs != null  and qnfs != ''"> and qnfs = #{qnfs}</if>
            <if test="toiletType != null  and toiletType != ''"> and toilet_type = #{toiletType}</if>
            <if test="houseIntro != null  and houseIntro != ''"> and house_intro = #{houseIntro}</if>
            <if test="housePicture != null  and housePicture != ''"> and house_picture = #{housePicture}</if>
          <!--<if test="deptId != null "> and dept_id = #{deptId}</if>-->
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="params.dataScope != null and params.dataScope !=''">
                ${params.dataScope}
            </if>
        </where>
    </select>

    <select id="selectSzxcHouseInfoById" parameterType="Long" resultMap="SzxcHouseInfoResult">
        <include refid="selectSzxcHouseInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcHouseInfo" parameterType="SzxcHouseInfo" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_house_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ownerId != null">owner_id,</if>
            <if test="ownerName != null and ownerName != ''">owner_name,</if>
            <if test="cardId != null">card_id,</if>
            <if test="xqId != null">xq_id,</if>
            <if test="houseName != null and houseName != ''">house_name,</if>
            <if test="buildId != null">build_id,</if>
            <if test="ldName != null">ld_name,</if>
            <if test="unit != null">unit,</if>
            <if test="doorNo != null">door_no,</if>
            <if test="houseType != null">house_type,</if>
            <if test="houseArea != null">house_area,</if>
            <if test="houseProp != null">house_prop,</if>
            <if test="qnfs != null">qnfs,</if>
            <if test="toiletType != null">toilet_type,</if>
            <if test="houseIntro != null">house_intro,</if>
            <if test="housePicture != null">house_picture,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="userId != null">user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ownerId != null">#{ownerId},</if>
            <if test="ownerName != null and ownerName != ''">#{ownerName},</if>
            <if test="cardId != null">#{cardId},</if>
            <if test="xqId != null">#{xqId},</if>
            <if test="houseName != null and houseName != ''">#{houseName},</if>
            <if test="buildId != null">#{buildId},</if>
            <if test="ldName != null">#{ldName},</if>
            <if test="unit != null">#{unit},</if>
            <if test="doorNo != null">#{doorNo},</if>
            <if test="houseType != null">#{houseType},</if>
            <if test="houseArea != null">#{houseArea},</if>
            <if test="houseProp != null">#{houseProp},</if>
            <if test="qnfs != null">#{qnfs},</if>
            <if test="toiletType != null">#{toiletType},</if>
            <if test="houseIntro != null">#{houseIntro},</if>
            <if test="housePicture != null">#{housePicture},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="userId != null">#{userId},</if>
        </trim>
    </insert>

    <update id="updateSzxcHouseInfo" parameterType="SzxcHouseInfo">
        update szxc_house_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="ownerId != null">owner_id = #{ownerId},</if>
            <if test="ownerName != null and ownerName != ''">owner_name = #{ownerName},</if>
            <if test="cardId != null">card_id = #{cardId},</if>
            <if test="xqId != null">xq_id = #{xqId},</if>
            <if test="houseName != null and houseName != ''">house_name = #{houseName},</if>
            <if test="buildId != null">build_id = #{buildId},</if>
            <if test="ldName != null">ld_name = #{ldName},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="doorNo != null">door_no = #{doorNo},</if>
            <if test="houseType != null">house_type = #{houseType},</if>
            <if test="houseArea != null">house_area = #{houseArea},</if>
            <if test="houseProp != null">house_prop = #{houseProp},</if>
            <if test="qnfs != null">qnfs = #{qnfs},</if>
            <if test="toiletType != null">toilet_type = #{toiletType},</if>
            <if test="houseIntro != null">house_intro = #{houseIntro},</if>
            <if test="housePicture != null">house_picture = #{housePicture},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcHouseInfoById" parameterType="Long">
        delete from szxc_house_info where id = #{id}
    </delete>

    <delete id="deleteSzxcHouseInfoByIds" parameterType="String">
        delete from szxc_house_info where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>