<?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.fs.qw.mapper.QwGroupchatStatisticMapper">
    
    <resultMap type="QwGroupchatStatistic" id="QwGroupchatStatisticResult">
        <result property="id"    column="id"    />
        <result property="owner"    column="owner"    />
        <result property="dayTime"    column="day_time"    />
        <result property="newChatCnt"    column="new_chat_cnt"    />
        <result property="chatTotal"    column="chat_total"    />
        <result property="chatHasMsg"    column="chat_has_msg"    />
        <result property="newMemberCnt"    column="new_member_cnt"    />
        <result property="memberTotal"    column="member_total"    />
        <result property="memberHasMsg"    column="member_has_msg"    />
        <result property="msgTotal"    column="msg_total"    />
        <result property="migrateTraineeChatCnt"    column="migrate_trainee_chat_cnt"    />
        <result property="companyId"    column="companyId"    />
        <result property="corpId"    column="corpId"    />
    </resultMap>

    <sql id="selectQwGroupchatStatisticVo">
        select id, owner, day_time, new_chat_cnt, chat_total, chat_has_msg, new_member_cnt, member_total, member_has_msg, msg_total, migrate_trainee_chat_cnt, companyId, corp_id from qw_groupchat_statistic
    </sql>

    <select id="selectQwGroupchatStatisticList" parameterType="QwGroupchatStatistic" resultMap="QwGroupchatStatisticResult">
        <include refid="selectQwGroupchatStatisticVo"/>
        <where>  
            <if test="owner != null  and owner != ''"> and owner = #{owner}</if>
            <if test="dayTime != null "> and day_time = #{dayTime}</if>
            <if test="newChatCnt != null "> and new_chat_cnt = #{newChatCnt}</if>
            <if test="chatTotal != null "> and chat_total = #{chatTotal}</if>
            <if test="chatHasMsg != null "> and chat_has_msg = #{chatHasMsg}</if>
            <if test="newMemberCnt != null "> and new_member_cnt = #{newMemberCnt}</if>
            <if test="memberTotal != null "> and member_total = #{memberTotal}</if>
            <if test="memberHasMsg != null "> and member_has_msg = #{memberHasMsg}</if>
            <if test="msgTotal != null "> and msg_total = #{msgTotal}</if>
            <if test="migrateTraineeChatCnt != null "> and migrate_trainee_chat_cnt = #{migrateTraineeChatCnt}</if>
            <if test="companyId != null "> and companyId = #{companyId}</if>
            <if test="corpId != null "> and corp_id = #{companyId}</if>
        </where>
    </select>
    
    <select id="selectQwGroupchatStatisticById" parameterType="Long" resultMap="QwGroupchatStatisticResult">
        <include refid="selectQwGroupchatStatisticVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertQwGroupchatStatistic" parameterType="QwGroupchatStatistic">
        insert into qw_groupchat_statistic
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="owner != null">owner,</if>
            <if test="dayTime != null">day_time,</if>
            <if test="newChatCnt != null">new_chat_cnt,</if>
            <if test="chatTotal != null">chat_total,</if>
            <if test="chatHasMsg != null">chat_has_msg,</if>
            <if test="newMemberCnt != null">new_member_cnt,</if>
            <if test="memberTotal != null">member_total,</if>
            <if test="memberHasMsg != null">member_has_msg,</if>
            <if test="msgTotal != null">msg_total,</if>
            <if test="migrateTraineeChatCnt != null">migrate_trainee_chat_cnt,</if>
            <if test="companyId != null">companyId,</if>
            <if test="corpId != null">corp_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="owner != null">#{owner},</if>
            <if test="dayTime != null">#{dayTime},</if>
            <if test="newChatCnt != null">#{newChatCnt},</if>
            <if test="chatTotal != null">#{chatTotal},</if>
            <if test="chatHasMsg != null">#{chatHasMsg},</if>
            <if test="newMemberCnt != null">#{newMemberCnt},</if>
            <if test="memberTotal != null">#{memberTotal},</if>
            <if test="memberHasMsg != null">#{memberHasMsg},</if>
            <if test="msgTotal != null">#{msgTotal},</if>
            <if test="migrateTraineeChatCnt != null">#{migrateTraineeChatCnt},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="corpId != null">#{corpId},</if>
         </trim>
    </insert>

    <insert id="updateOrInsertQwGroupchatStatistic" parameterType="QwGroupchatStatistic">
        insert into qw_groupchat_statistic
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="owner != null">owner,</if>
            <if test="dayTime != null">day_time,</if>
            <if test="newChatCnt != null">new_chat_cnt,</if>
            <if test="chatTotal != null">chat_total,</if>
            <if test="chatHasMsg != null">chat_has_msg,</if>
            <if test="newMemberCnt != null">new_member_cnt,</if>
            <if test="memberTotal != null">member_total,</if>
            <if test="memberHasMsg != null">member_has_msg,</if>
            <if test="msgTotal != null">msg_total,</if>
            <if test="migrateTraineeChatCnt != null">migrate_trainee_chat_cnt,</if>
            <if test="companyId != null">companyId,</if>
            <if test="corpId != null">corp_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="owner != null">#{owner},</if>
            <if test="dayTime != null">#{dayTime},</if>
            <if test="newChatCnt != null">#{newChatCnt},</if>
            <if test="chatTotal != null">#{chatTotal},</if>
            <if test="chatHasMsg != null">#{chatHasMsg},</if>
            <if test="newMemberCnt != null">#{newMemberCnt},</if>
            <if test="memberTotal != null">#{memberTotal},</if>
            <if test="memberHasMsg != null">#{memberHasMsg},</if>
            <if test="msgTotal != null">#{msgTotal},</if>
            <if test="migrateTraineeChatCnt != null">#{migrateTraineeChatCnt},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="corpId != null">#{corpId},</if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="owner != null">owner = #{owner},</if>
            <if test="dayTime != null">day_time = #{dayTime},</if>
            <if test="newChatCnt != null">new_chat_cnt = #{newChatCnt},</if>
            <if test="chatTotal != null">chat_total = #{chatTotal},</if>
            <if test="chatHasMsg != null">chat_has_msg = #{chatHasMsg},</if>
            <if test="newMemberCnt != null">new_member_cnt = #{newMemberCnt},</if>
            <if test="memberTotal != null">member_total = #{memberTotal},</if>
            <if test="memberHasMsg != null">member_has_msg = #{memberHasMsg},</if>
            <if test="msgTotal != null">msg_total = #{msgTotal},</if>
            <if test="migrateTraineeChatCnt != null">migrate_trainee_chat_cnt = #{migrateTraineeChatCnt},</if>
            <if test="companyId != null">companyId = #{companyId},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
        </trim>
    </insert>

    <update id="updateQwGroupchatStatistic" parameterType="QwGroupchatStatistic">
        update qw_groupchat_statistic
        <trim prefix="SET" suffixOverrides=",">
            <if test="owner != null">owner = #{owner},</if>
            <if test="dayTime != null">day_time = #{dayTime},</if>
            <if test="newChatCnt != null">new_chat_cnt = #{newChatCnt},</if>
            <if test="chatTotal != null">chat_total = #{chatTotal},</if>
            <if test="chatHasMsg != null">chat_has_msg = #{chatHasMsg},</if>
            <if test="newMemberCnt != null">new_member_cnt = #{newMemberCnt},</if>
            <if test="memberTotal != null">member_total = #{memberTotal},</if>
            <if test="memberHasMsg != null">member_has_msg = #{memberHasMsg},</if>
            <if test="msgTotal != null">msg_total = #{msgTotal},</if>
            <if test="migrateTraineeChatCnt != null">migrate_trainee_chat_cnt = #{migrateTraineeChatCnt},</if>
            <if test="companyId != null">companyId = #{companyId},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwGroupchatStatisticById" parameterType="Long">
        delete from qw_groupchat_statistic where id = #{id}
    </delete>

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