<?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.system.mapper.HouseManageMapper">
    
    <resultMap type="HouseManage" id="HouseManageResult">
        <result property="portalId"    column="portal_id"    />
        <result property="houseAddress"    column="house_address"    />
        <result property="houseOwnership"    column="house_ownership"    />
        <result property="floorage"    column="floorage"    />
        <result property="roomType"    column="room_type"    />
        <result property="purpose"    column="purpose"    />
        <result property="typeOfRights"    column="type_of_rights"    />
        <result property="termOfRights"    column="term_of_rights"    />
        <result property="isPark"    column="is_park"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectHouseManageVo">
        select portal_id, house_address, house_ownership, floorage, room_type, purpose, type_of_rights, term_of_rights, is_park, create_by, create_time, update_by, update_time, remark from house_manage
    </sql>

    <select id="selectHouseManageList" parameterType="HouseManage" resultMap="HouseManageResult">
        <include refid="selectHouseManageVo"/>
        <where>  
            <if test="houseAddress != null  and houseAddress != ''"> and house_address = #{houseAddress}</if>
            <if test="houseOwnership != null  and houseOwnership != ''"> and house_ownership = #{houseOwnership}</if>
            <if test="floorage != null  and floorage != ''"> and floorage = #{floorage}</if>
            <if test="roomType != null  and roomType != ''"> and room_type = #{roomType}</if>
            <if test="purpose != null  and purpose != ''"> and purpose = #{purpose}</if>
            <if test="typeOfRights != null  and typeOfRights != ''"> and type_of_rights = #{typeOfRights}</if>
            <if test="termOfRights != null  and termOfRights != ''"> and term_of_rights = #{termOfRights}</if>
            <if test="isPark != null  and isPark != ''"> and is_park = #{isPark}</if>
        </where>
    </select>
    
    <select id="selectHouseManageByPortalId" parameterType="Long" resultMap="HouseManageResult">
        <include refid="selectHouseManageVo"/>
        where portal_id = #{portalId}
    </select>

    <insert id="insertHouseManage" parameterType="HouseManage" useGeneratedKeys="true" keyProperty="portalId">
        insert into house_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="houseAddress != null and houseAddress != ''">house_address,</if>
            <if test="houseOwnership != null and houseOwnership != ''">house_ownership,</if>
            <if test="floorage != null and floorage != ''">floorage,</if>
            <if test="roomType != null and roomType != ''">room_type,</if>
            <if test="purpose != null and purpose != ''">purpose,</if>
            <if test="typeOfRights != null and typeOfRights != ''">type_of_rights,</if>
            <if test="termOfRights != null and termOfRights != ''">term_of_rights,</if>
            <if test="isPark != null">is_park,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="houseAddress != null and houseAddress != ''">#{houseAddress},</if>
            <if test="houseOwnership != null and houseOwnership != ''">#{houseOwnership},</if>
            <if test="floorage != null and floorage != ''">#{floorage},</if>
            <if test="roomType != null and roomType != ''">#{roomType},</if>
            <if test="purpose != null and purpose != ''">#{purpose},</if>
            <if test="typeOfRights != null and typeOfRights != ''">#{typeOfRights},</if>
            <if test="termOfRights != null and termOfRights != ''">#{termOfRights},</if>
            <if test="isPark != null">#{isPark},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateHouseManage" parameterType="HouseManage">
        update house_manage
        <trim prefix="SET" suffixOverrides=",">
            <if test="houseAddress != null and houseAddress != ''">house_address = #{houseAddress},</if>
            <if test="houseOwnership != null and houseOwnership != ''">house_ownership = #{houseOwnership},</if>
            <if test="floorage != null and floorage != ''">floorage = #{floorage},</if>
            <if test="roomType != null and roomType != ''">room_type = #{roomType},</if>
            <if test="purpose != null and purpose != ''">purpose = #{purpose},</if>
            <if test="typeOfRights != null and typeOfRights != ''">type_of_rights = #{typeOfRights},</if>
            <if test="termOfRights != null and termOfRights != ''">term_of_rights = #{termOfRights},</if>
            <if test="isPark != null">is_park = #{isPark},</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="remark != null">remark = #{remark},</if>
        </trim>
        where portal_id = #{portalId}
    </update>

    <delete id="deleteHouseManageByPortalId" parameterType="Long">
        delete from house_manage where portal_id = #{portalId}
    </delete>

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