<?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.gic.haoban.manage.service.dao.mapper.TabHaobanFriendSettingMapper">

    <resultMap type="com.gic.haoban.manage.service.entity.TabHaobanFriendSetting" id="TabHaobanFriendSettingMap">
        <result property="friendSettingId" column="friend_setting_id" jdbcType="BIGINT"/>
        <result property="wxEnterpriseId" column="wx_enterprise_id" jdbcType="VARCHAR"/>
        <result property="friendSettingType" column="friend_setting_type" jdbcType="INTEGER"/>
        <result property="updateId" column="update_id" jdbcType="VARCHAR"/>
        <result property="updateName" column="update_name" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="deleteFlag" column="delete_flag" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="Base_Column_List">
        friend_setting_id
        , wx_enterprise_id, friend_setting_type, update_id, update_name, create_time, update_time, delete_flag     </sql>

    <!--新增所有列-->
    <insert id="insert" keyProperty="friendSettingId" useGeneratedKeys="true"
            parameterType="com.gic.haoban.manage.service.entity.TabHaobanFriendSetting">
        INSERT INTO tab_haoban_friend_setting
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="friendSettingId != null">
                friend_setting_id,
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                wx_enterprise_id,
            </if>
            <if test="friendSettingType != null">
                friend_setting_type,
            </if>
            <if test="updateId != null and updateId != ''">
                update_id,
            </if>
            <if test="updateName != null and updateName != ''">
                update_name,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="deleteFlag != null">
                delete_flag,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="friendSettingId != null">
                #{friendSettingId},
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                #{wxEnterpriseId},
            </if>
            <if test="friendSettingType != null">
                #{friendSettingType},
            </if>
            <if test="updateId != null and updateId != ''">
                #{updateId},
            </if>
            <if test="updateName != null and updateName != ''">
                #{updateName},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="updateTime != null">
                #{updateTime},
            </if>
            <if test="deleteFlag != null">
                #{deleteFlag},
            </if>
        </trim>
    </insert>
    <!--通过主键修改数据-->
    <update id="update" parameterType="com.gic.haoban.manage.service.entity.TabHaobanFriendSetting">
        update tab_haoban_friend_setting
        <set>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                wx_enterprise_id = #{wxEnterpriseId},
            </if>
            <if test="friendSettingType != null">
                friend_setting_type = #{friendSettingType},
            </if>
            <if test="updateId != null and updateId != ''">
                update_id = #{updateId},
            </if>
            <if test="updateName != null and updateName != ''">
                update_name = #{updateName},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime},
            </if>
            <if test="deleteFlag != null">
                delete_flag = #{deleteFlag},
            </if>
        </set>
        where friend_setting_id = #{friendSettingId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete
        from tab_haoban_friend_setting
        where friend_setting_id = #{friendSettingId}
    </delete>

    <!--查询单个-->
    <select id="queryById" resultMap="TabHaobanFriendSettingMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_friend_setting
        where friend_setting_id = #{friendSettingId}
    </select>

    <!--通过实体作为筛选条件查询-->
    <select id="queryAll" parameterType="com.gic.haoban.manage.service.entity.TabHaobanFriendSetting"
            resultMap="TabHaobanFriendSettingMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_friend_setting
        <where>
            <if test="friendSettingId != null">
                and friend_setting_id = #{friendSettingId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
            <if test="friendSettingType != null">
                and friend_setting_type = #{friendSettingType}
            </if>
            <if test="updateId != null and updateId != ''">
                and update_id = #{updateId}
            </if>
            <if test="updateName != null and updateName != ''">
                and update_name = #{updateName}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
            <if test="deleteFlag != null">
                and delete_flag = #{deleteFlag}
            </if>
        </where>
    </select>

    <select id="queryCountByPage" resultType="int">
        select count(*)
        from tab_haoban_friend_setting
    </select>

    <select id="queryListByPage" resultMap="TabHaobanFriendSettingMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_friend_setting
        limit #{offset}, #{limit}
    </select>
    <select id="getByWxEnterpriseId" resultMap="TabHaobanFriendSettingMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_friend_setting where  wx_enterprise_id = #{wxEnterpriseId} and delete_flag = 0
    </select>

</mapper>
