<?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=".dao.TabContactConfigDao">
    <resultMap type=".entity.TabContactConfig" id="TabContactConfigMap">
        <result property="configId" column="config_id" jdbcType="INTEGER"/>
        <result property="contactAuto" column="contact_auto" jdbcType="VARCHAR"/>
        <result property="remarkFlag" column="remark_flag" jdbcType="INTEGER"/>
        <result property="remarkContent" column="remark_content" jdbcType="VARCHAR"/>
        <result property="enterpriseId" column="enterprise_id" jdbcType="VARCHAR"/>
        <result property="deleteFlag" column="delete_flag" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="TabContactConfigMap">
        select
        config_idcontact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time
        from tab_contact_config
        where config_id = #{configId}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TabContactConfigMap">
        select
        config_idcontact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time
        from tab_contact_config
        <where>
            <if test="configId != null">
                and config_id = #{configId}
            </if>
            <if test="contactAuto != null and contactAuto != ''">
                and contact_auto = #{contactAuto}
            </if>
            <if test="remarkFlag != null">
                and remark_flag = #{remarkFlag}
            </if>
            <if test="remarkContent != null and remarkContent != ''">
                and remark_content = #{remarkContent}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="deleteFlag != null">
                and delete_flag = #{deleteFlag}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from tab_contact_config
        <where>
            <if test="configId != null">
                and config_id = #{configId}
            </if>
            <if test="contactAuto != null and contactAuto != ''">
                and contact_auto = #{contactAuto}
            </if>
            <if test="remarkFlag != null">
                and remark_flag = #{remarkFlag}
            </if>
            <if test="remarkContent != null and remarkContent != ''">
                and remark_content = #{remarkContent}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="deleteFlag != null">
                and delete_flag = #{deleteFlag}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="configId" useGeneratedKeys="true">
        insert into
        tab_contact_config(contact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time)
        values (#{contactAuto}#{remarkFlag}#{remarkContent}#{enterpriseId}#{deleteFlag}#{createTime}#{updateTime})
    </insert>

    <insert id="insertBatch" keyProperty="configId" useGeneratedKeys="true">
        insert into
        tab_contact_config(contact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.contactAuto}#{entity.remarkFlag}#{entity.remarkContent}#{entity.enterpriseId}#{entity.deleteFlag}#{entity.createTime}#{entity.updateTime})
        </foreach>
    </insert>

    <insert id="insertOrUpdateBatch" keyProperty="configId" useGeneratedKeys="true">
        insert into
        tab_contact_config(contact_autoremark_flagremark_contententerprise_iddelete_flagcreate_timeupdate_time)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.contactAuto}#{entity.remarkFlag}#{entity.remarkContent}#{entity.enterpriseId}#{entity.deleteFlag}#{entity.createTime}#{entity.updateTime})
        </foreach>
        on duplicate key update
        contact_auto = values(contact_auto)remark_flag = values(remark_flag)remark_content =
        values(remark_content)enterprise_id = values(enterprise_id)delete_flag = values(delete_flag)create_time =
        values(create_time)update_time = values(update_time)
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update tab_contact_config
        <set>
            <if test="contactAuto != null and contactAuto != ''">
                contact_auto = #{contactAuto},
            </if>
            <if test="remarkFlag != null">
                remark_flag = #{remarkFlag},
            </if>
            <if test="remarkContent != null and remarkContent != ''">
                remark_content = #{remarkContent},
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                enterprise_id = #{enterpriseId},
            </if>
            <if test="deleteFlag != null">
                delete_flag = #{deleteFlag},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime},
            </if>
        </set>
        where config_id = #{configId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from tab_contact_config where config_id = #{configId}
    </delete>
</mapper>

