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

    <resultMap type="TdPropertyManager" id="TdPropertyManagerResult">
        <result property="useId"    column="use_id"    />
        <result property="useDepart"    column="use_depart"    />
        <result property="userName"    column="user_name"    />
        <result property="useDate"    column="use_date"    />
        <result property="frameworkId"    column="framework_id"    />
        <result property="recoverDepart"    column="recover_depart"    />
        <result property="recoverName"    column="recover_name"    />
        <result property="recoverDate"    column="recover_date"    />
        <result property="shemichengdu"    column="shemichengdu"    />
        <result property="part"    column="part"    />
        <result property="areaId"    column="area_id"    />
        <result property="propertyNum"    column="property_num"    />
    </resultMap>

    <sql id="selectTdPropertyManagerVo">
        select use_id, use_depart, user_name, use_date, framework_id, recover_depart, recover_name, recover_date, shemichengdu, part, area_id, property_num from td_property_manager
    </sql>

    <select id="selectTdPropertyManagerList" parameterType="TdPropertyManager" resultMap="TdPropertyManagerResult">
        <include refid="selectTdPropertyManagerVo"/>
        <where>
            <if test="useId != null  and useId != ''"> and use_id = #{useId}</if>
            <if test="useDepart != null  and useDepart != ''"> and use_depart = #{useDepart}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="useDate != null "> and use_date = #{useDate}</if>
            <if test="frameworkId != null  and frameworkId != ''"> and framework_id = #{frameworkId}</if>
            <if test="recoverDepart != null  and recoverDepart != ''"> and recover_depart = #{recoverDepart}</if>
            <if test="recoverName != null  and recoverName != ''"> and recover_name like concat('%', #{recoverName}, '%')</if>
            <if test="recoverDate != null "> and recover_date = #{recoverDate}</if>
            <if test="shemichengdu != null "> and shemichengdu = #{shemichengdu}</if>
            <if test="part != null  and part != ''"> and part = #{part}</if>
            <if test="areaId != null  and areaId != ''"> and area_id = #{areaId}</if>
            <if test="propertyNum != null "> and property_num = #{propertyNum}</if>
        </where>
    </select>

    <select id="selectTdPropertyManagerByUseId" parameterType="String" resultMap="TdPropertyManagerResult">
        <include refid="selectTdPropertyManagerVo"/>
        where use_id = #{useId}
    </select>

    <insert id="insertTdPropertyManager" parameterType="TdPropertyManager">
        insert into td_property_manager
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="useId != null">use_id,</if>
            <if test="useDepart != null">use_depart,</if>
            <if test="userName != null">user_name,</if>
            <if test="useDate != null">use_date,</if>
            <if test="frameworkId != null">framework_id,</if>
            <if test="recoverDepart != null">recover_depart,</if>
            <if test="recoverName != null">recover_name,</if>
            <if test="recoverDate != null">recover_date,</if>
            <if test="shemichengdu != null">shemichengdu,</if>
            <if test="part != null">part,</if>
            <if test="areaId != null">area_id,</if>
            <if test="propertyNum != null">property_num,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="useId != null">#{useId},</if>
            <if test="useDepart != null">#{useDepart},</if>
            <if test="userName != null">#{userName},</if>
            <if test="useDate != null">#{useDate},</if>
            <if test="frameworkId != null">#{frameworkId},</if>
            <if test="recoverDepart != null">#{recoverDepart},</if>
            <if test="recoverName != null">#{recoverName},</if>
            <if test="recoverDate != null">#{recoverDate},</if>
            <if test="shemichengdu != null">#{shemichengdu},</if>
            <if test="part != null">#{part},</if>
            <if test="areaId != null">#{areaId},</if>
            <if test="propertyNum != null">#{propertyNum},</if>
        </trim>
    </insert>

    <update id="updateTdPropertyManager" parameterType="TdPropertyManager">
        update td_property_manager
        <trim prefix="SET" suffixOverrides=",">
            <if test="useDepart != null">use_depart = #{useDepart},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="useDate != null">use_date = #{useDate},</if>
            <if test="frameworkId != null">framework_id = #{frameworkId},</if>
            <if test="recoverDepart != null">recover_depart = #{recoverDepart},</if>
            <if test="recoverName != null">recover_name = #{recoverName},</if>
            <if test="recoverDate != null">recover_date = #{recoverDate},</if>
            <if test="shemichengdu != null">shemichengdu = #{shemichengdu},</if>
            <if test="part != null">part = #{part},</if>
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="propertyNum != null">property_num = #{propertyNum},</if>
        </trim>
        where use_id = #{useId}
    </update>

    <delete id="deleteTdPropertyManagerByUseId" parameterType="String">
        delete from td_property_manager where use_id = #{useId}
    </delete>

    <delete id="deleteTdPropertyManagerByUseIds" parameterType="String">
        delete from td_property_manager where use_id in
        <foreach item="useId" collection="array" open="(" separator="," close=")">
            #{useId}
        </foreach>
    </delete>

</mapper>