<?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.zongzhi.mapper.TcDengbaoUnitMapper">
    
    <resultMap type="TcDengbaoUnit" id="TcDengbaoUnitResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="unitName"    column="unit_name"    />
        <result property="postCode"    column="post_code"    />
        <result property="unitProvince"    column="unit_province"    />
        <result property="unitCity"    column="unit_city"    />
        <result property="unitCounty"    column="unit_county"    />
        <result property="unitStreet"    column="unit_street"    />
        <result property="areaCode"    column="area_code"    />
        <result property="affiliation"    column="affiliation"    />
        <result property="unitType"    column="unit_type"    />
        <result property="tmtType"    column="tmt_type"    />
        <result property="fuzeName"    column="fuze_name"    />
        <result property="fuzeDuty"    column="fuze_duty"    />
        <result property="fuzeTel"    column="fuze_tel"    />
        <result property="fuzeEmail"    column="fuze_email"    />
        <result property="createId"    column="create_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateId"    column="update_id"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTcDengbaoUnitVo">
        select id, area_id, unit_name, post_code, unit_province, unit_city, unit_county, unit_street, area_code, affiliation, unit_type, tmt_type, fuze_name, fuze_duty, fuze_tel, fuze_email, create_id, create_by, create_time, update_id, update_by, update_time, remark from tc_dengbao_unit
    </sql>

    <select id="selectTcDengbaoUnitList" parameterType="TcDengbaoUnit" resultMap="TcDengbaoUnitResult">
        <include refid="selectTcDengbaoUnitVo"/>
        <where>  
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="unitName != null  and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="postCode != null  and postCode != ''"> and post_code = #{postCode}</if>
            <if test="unitProvince != null  and unitProvince != ''"> and unit_province = #{unitProvince}</if>
            <if test="unitCity != null  and unitCity != ''"> and unit_city = #{unitCity}</if>
            <if test="unitCounty != null  and unitCounty != ''"> and unit_county = #{unitCounty}</if>
            <if test="unitStreet != null  and unitStreet != ''"> and unit_street = #{unitStreet}</if>
            <if test="areaCode != null  and areaCode != ''"> and area_code = #{areaCode}</if>
            <if test="affiliation != null  and affiliation != ''"> and affiliation = #{affiliation}</if>
            <if test="unitType != null  and unitType != ''"> and unit_type = #{unitType}</if>
            <if test="tmtType != null  and tmtType != ''"> and tmt_type = #{tmtType}</if>
            <if test="fuzeName != null  and fuzeName != ''"> and fuze_name like concat('%', #{fuzeName}, '%')</if>
            <if test="fuzeDuty != null  and fuzeDuty != ''"> and fuze_duty = #{fuzeDuty}</if>
            <if test="fuzeTel != null  and fuzeTel != ''"> and fuze_tel = #{fuzeTel}</if>
            <if test="fuzeEmail != null  and fuzeEmail != ''"> and fuze_email = #{fuzeEmail}</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="updateId != null "> and update_id = #{updateId}</if>
        </where>
    </select>
    
    <select id="selectTcDengbaoUnitById" parameterType="Long" resultMap="TcDengbaoUnitResult">
        <include refid="selectTcDengbaoUnitVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcDengbaoUnit" parameterType="TcDengbaoUnit" useGeneratedKeys="true" keyProperty="id">
        insert into tc_dengbao_unit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="unitName != null">unit_name,</if>
            <if test="postCode != null">post_code,</if>
            <if test="unitProvince != null">unit_province,</if>
            <if test="unitCity != null">unit_city,</if>
            <if test="unitCounty != null">unit_county,</if>
            <if test="unitStreet != null">unit_street,</if>
            <if test="areaCode != null">area_code,</if>
            <if test="affiliation != null">affiliation,</if>
            <if test="unitType != null">unit_type,</if>
            <if test="tmtType != null">tmt_type,</if>
            <if test="fuzeName != null">fuze_name,</if>
            <if test="fuzeDuty != null">fuze_duty,</if>
            <if test="fuzeTel != null">fuze_tel,</if>
            <if test="fuzeEmail != null">fuze_email,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateId != null">update_id,</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="areaId != null">#{areaId},</if>
            <if test="unitName != null">#{unitName},</if>
            <if test="postCode != null">#{postCode},</if>
            <if test="unitProvince != null">#{unitProvince},</if>
            <if test="unitCity != null">#{unitCity},</if>
            <if test="unitCounty != null">#{unitCounty},</if>
            <if test="unitStreet != null">#{unitStreet},</if>
            <if test="areaCode != null">#{areaCode},</if>
            <if test="affiliation != null">#{affiliation},</if>
            <if test="unitType != null">#{unitType},</if>
            <if test="tmtType != null">#{tmtType},</if>
            <if test="fuzeName != null">#{fuzeName},</if>
            <if test="fuzeDuty != null">#{fuzeDuty},</if>
            <if test="fuzeTel != null">#{fuzeTel},</if>
            <if test="fuzeEmail != null">#{fuzeEmail},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateId != null">#{updateId},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTcDengbaoUnit" parameterType="TcDengbaoUnit">
        update tc_dengbao_unit
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="unitName != null">unit_name = #{unitName},</if>
            <if test="postCode != null">post_code = #{postCode},</if>
            <if test="unitProvince != null">unit_province = #{unitProvince},</if>
            <if test="unitCity != null">unit_city = #{unitCity},</if>
            <if test="unitCounty != null">unit_county = #{unitCounty},</if>
            <if test="unitStreet != null">unit_street = #{unitStreet},</if>
            <if test="areaCode != null">area_code = #{areaCode},</if>
            <if test="affiliation != null">affiliation = #{affiliation},</if>
            <if test="unitType != null">unit_type = #{unitType},</if>
            <if test="tmtType != null">tmt_type = #{tmtType},</if>
            <if test="fuzeName != null">fuze_name = #{fuzeName},</if>
            <if test="fuzeDuty != null">fuze_duty = #{fuzeDuty},</if>
            <if test="fuzeTel != null">fuze_tel = #{fuzeTel},</if>
            <if test="fuzeEmail != null">fuze_email = #{fuzeEmail},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateId != null">update_id = #{updateId},</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 id = #{id}
    </update>

    <delete id="deleteTcDengbaoUnitById" parameterType="Long">
        delete from tc_dengbao_unit where id = #{id}
    </delete>

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