<?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.chat.GroupChatActivityMapper">
    <resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatActivity" id="TabHaobanGroupChatActivityMap">
        <result property="chatActivityId" column="chat_activity_id" jdbcType="INTEGER"/>
        <result property="activityName" column="activity_name" jdbcType="VARCHAR"/>
        <result property="startDate" column="start_date" jdbcType="TIMESTAMP"/>
        <result property="endDate" column="end_date" jdbcType="TIMESTAMP"/>
        <result property="limitDate" column="limit_date" jdbcType="TIMESTAMP"/>
        <result property="activityImg" column="activity_img" jdbcType="VARCHAR"/>
        <result property="activityInviteImg" column="activity_invite_img" jdbcType="VARCHAR"/>
        <result property="activityDesc" column="activity_desc" jdbcType="VARCHAR"/>
        <result property="activityShareTitle" column="activity_share_title" jdbcType="VARCHAR"/>
        <result property="activityShareImg" column="activity_share_img" jdbcType="VARCHAR"/>
        <result property="activityPosterImg" column="activity_poster_img" jdbcType="VARCHAR"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="inviteRewardType" column="invite_reward_type" jdbcType="INTEGER"/>
        <result property="joinType" column="join_type" jdbcType="INTEGER"/>
        <result property="joinRule" column="join_rule" jdbcType="VARCHAR"/>
        <result property="joinChatHmId" column="join_chat_hm_id" jdbcType="INTEGER"/>
        <result property="inviteType" column="invite_type" jdbcType="INTEGER"/>
        <result property="inviteMemberType" column="invite_member_type" jdbcType="INTEGER"/>
        <result property="labelFlag" column="label_flag" jdbcType="INTEGER"/>
        <result property="labelJson" column="label_json" jdbcType="VARCHAR"/>
        <result property="exceptionNotice" column="exception_notice" jdbcType="INTEGER"/>
        <result property="exceptionNoticeNum" column="exception_notice_num" jdbcType="INTEGER"/>
        <result property="enterpriseId" column="enterprise_id" jdbcType="VARCHAR"/>
        <result property="wxEnterpriseId" column="wx_enterprise_id" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="creatorId" column="creator_id" jdbcType="VARCHAR"/>
        <result property="creatorName" column="creator_name" jdbcType="VARCHAR"/>
        <result property="deleteFlag" column="delete_flag" jdbcType="INTEGER"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="TabHaobanGroupChatActivityMap">
        select chat_activity_id, activity_name, start_date, end_date, limit_date, activity_img, activity_invite_img, activity_desc, activity_share_title, activity_share_img, activity_poster_img, status, invite_reward_type, join_type, join_rule, join_chat_hm_id, invite_type, invite_member_type, label_flag, label_json, exception_notice, exception_notice_num, enterprise_id, wx_enterprise_id, create_time, update_time, creator_id, creator_name, delete_flag
        from tab_haoban_group_chat_activity
        where chat_activity_id = #{chatActivityId}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TabHaobanGroupChatActivityMap">
        select
        chat_activity_id, activity_name, start_date, end_date, limit_date, activity_img, activity_invite_img, activity_desc, activity_share_title, activity_share_img, activity_poster_img, status, invite_reward_type, join_type, join_rule, join_chat_hm_id, invite_type, invite_member_type, label_flag, label_json, exception_notice, exception_notice_num, enterprise_id, wx_enterprise_id, create_time, update_time, creator_id, creator_name, delete_flag
        from tab_haoban_group_chat_activity
        <where>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="activityName != null and activityName != ''">
                and activity_name = #{activityName}
            </if>
            <if test="startDate != null">
                and start_date = #{startDate}
            </if>
            <if test="endDate != null">
                and end_date = #{endDate}
            </if>
            <if test="limitDate != null">
                and limit_date = #{limitDate}
            </if>
            <if test="activityImg != null and activityImg != ''">
                and activity_img = #{activityImg}
            </if>
            <if test="activityInviteImg != null and activityInviteImg != ''">
                and activity_invite_img = #{activityInviteImg}
            </if>
            <if test="activityDesc != null and activityDesc != ''">
                and activity_desc = #{activityDesc}
            </if>
            <if test="activityShareTitle != null and activityShareTitle != ''">
                and activity_share_title = #{activityShareTitle}
            </if>
            <if test="activityShareImg != null and activityShareImg != ''">
                and activity_share_img = #{activityShareImg}
            </if>
            <if test="activityPosterImg != null and activityPosterImg != ''">
                and activity_poster_img = #{activityPosterImg}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="inviteRewardType != null">
                and invite_reward_type = #{inviteRewardType}
            </if>
            <if test="joinType != null">
                and join_type = #{joinType}
            </if>
            <if test="joinRule != null and joinRule != ''">
                and join_rule = #{joinRule}
            </if>
            <if test="joinChatHmId != null">
                and join_chat_hm_id = #{joinChatHmId}
            </if>
            <if test="inviteType != null">
                and invite_type = #{inviteType}
            </if>
            <if test="inviteMemberType != null">
                and invite_member_type = #{inviteMemberType}
            </if>
            <if test="labelFlag != null">
                and label_flag = #{labelFlag}
            </if>
            <if test="labelJson != null and labelJson != ''">
                and label_json = #{labelJson}
            </if>
            <if test="exceptionNotice != null">
                and exception_notice = #{exceptionNotice}
            </if>
            <if test="exceptionNoticeNum != null">
                and exception_notice_num = #{exceptionNoticeNum}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
            <if test="creatorId != null and creatorId != ''">
                and creator_id = #{creatorId}
            </if>
            <if test="creatorName != null and creatorName != ''">
                and creator_name = #{creatorName}
            </if>
            <if test="deleteFlag != null">
                and delete_flag = #{deleteFlag}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from tab_haoban_group_chat_activity
        <where>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="activityName != null and activityName != ''">
                and activity_name = #{activityName}
            </if>
            <if test="startDate != null">
                and start_date = #{startDate}
            </if>
            <if test="endDate != null">
                and end_date = #{endDate}
            </if>
            <if test="limitDate != null">
                and limit_date = #{limitDate}
            </if>
            <if test="activityImg != null and activityImg != ''">
                and activity_img = #{activityImg}
            </if>
            <if test="activityInviteImg != null and activityInviteImg != ''">
                and activity_invite_img = #{activityInviteImg}
            </if>
            <if test="activityDesc != null and activityDesc != ''">
                and activity_desc = #{activityDesc}
            </if>
            <if test="activityShareTitle != null and activityShareTitle != ''">
                and activity_share_title = #{activityShareTitle}
            </if>
            <if test="activityShareImg != null and activityShareImg != ''">
                and activity_share_img = #{activityShareImg}
            </if>
            <if test="activityPosterImg != null and activityPosterImg != ''">
                and activity_poster_img = #{activityPosterImg}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="inviteRewardType != null">
                and invite_reward_type = #{inviteRewardType}
            </if>
            <if test="joinType != null">
                and join_type = #{joinType}
            </if>
            <if test="joinRule != null and joinRule != ''">
                and join_rule = #{joinRule}
            </if>
            <if test="joinChatHmId != null">
                and join_chat_hm_id = #{joinChatHmId}
            </if>
            <if test="inviteType != null">
                and invite_type = #{inviteType}
            </if>
            <if test="inviteMemberType != null">
                and invite_member_type = #{inviteMemberType}
            </if>
            <if test="labelFlag != null">
                and label_flag = #{labelFlag}
            </if>
            <if test="labelJson != null and labelJson != ''">
                and label_json = #{labelJson}
            </if>
            <if test="exceptionNotice != null">
                and exception_notice = #{exceptionNotice}
            </if>
            <if test="exceptionNoticeNum != null">
                and exception_notice_num = #{exceptionNoticeNum}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
            <if test="creatorId != null and creatorId != ''">
                and creator_id = #{creatorId}
            </if>
            <if test="creatorName != null and creatorName != ''">
                and creator_name = #{creatorName}
            </if>
            <if test="deleteFlag != null">
                and delete_flag = #{deleteFlag}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="chatActivityId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity(
            activity_name,
            start_date,
            end_date,
            limit_date,
            activity_img,
            activity_invite_img,
            activity_desc,
            activity_share_title,
            activity_share_img,
            activity_poster_img,
            status,
            invite_reward_type,
            join_type,
            join_rule,
            join_chat_hm_id,
            invite_type,
            invite_member_type,
            label_flag,
            label_json,
            exception_notice,
            exception_notice_num,
            enterprise_id,
            wx_enterprise_id,
            create_time,
            update_time,
            creator_id,
            creator_name,
            delete_flag)
        values (
                   #{activityName},
                   #{startDate},
                   #{endDate},
                   #{limitDate},
                   #{activityImg},
                   #{activityInviteImg},
                   #{activityDesc},
                   #{activityShareTitle},
                   #{activityShareImg},
                   #{activityPosterImg},
                   #{status},
                   #{inviteRewardType},
                   #{joinType},
                   #{joinRule},
                   #{joinChatHmId},
                   #{inviteType},
                   #{inviteMemberType},
                   #{labelFlag},
                   #{labelJson},
                   #{exceptionNotice},
                   #{exceptionNoticeNum},
                   #{enterpriseId},
                   #{wxEnterpriseId},
                   #{createTime},
                   #{updateTime},
                   #{creatorId},
                   #{creatorName},
                   #{deleteFlag})
    </insert>

    <insert id="insertBatch" keyProperty="chatActivityId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity(
        activity_name,
        start_date,
        end_date,
        limit_date,
        activity_img,
        activity_invite_img,
        activity_desc,
        activity_share_title,
        activity_share_img,
        activity_poster_img,
        status,
        invite_reward_type,
        join_type,
        join_rule,
        join_chat_hm_id,
        invite_type,
        invite_member_type,
        label_flag,
        label_json,
        exception_notice,
        exception_notice_num,
        enterprise_id,
        wx_enterprise_id,
        create_time,
        update_time,
        creator_id,
        creator_name,
        delete_flag)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.activityName},
            #{entity.startDate},
            #{entity.endDate},
            #{entity.limitDate},
            #{entity.activityImg},
            #{entity.activityInviteImg},
            #{entity.activityDesc},
            #{entity.activityShareTitle},
            #{entity.activityShareImg},
            #{entity.activityPosterImg},
            #{entity.status},
            #{entity.inviteRewardType},
            #{entity.joinType},
            #{entity.joinRule},
            #{entity.joinChatHmId},
            #{entity.inviteType},
            #{entity.inviteMemberType},
            #{entity.labelFlag},
            #{entity.labelJson},
            #{entity.exceptionNotice},
            #{entity.exceptionNoticeNum},
            #{entity.enterpriseId},
            #{entity.wxEnterpriseId},
            #{entity.createTime},
            #{entity.updateTime},
            #{entity.creatorId},
            #{entity.creatorName},
            #{entity.deleteFlag})
        </foreach>
    </insert>

    <insert id="insertOrUpdateBatch" keyProperty="chatActivityId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity(
        activity_name,
        start_date,
        end_date,
        limit_date,
        activity_img,
        activity_invite_img,
        activity_desc,
        activity_share_title,
        activity_share_img,
        activity_poster_img,
        status,
        invite_reward_type,
        join_type,
        join_rule,
        join_chat_hm_id,
        invite_type,
        invite_member_type,
        label_flag,
        label_json,
        exception_notice,
        exception_notice_num,
        enterprise_id,
        wx_enterprise_id,
        create_time,
        update_time,
        creator_id,
        creator_name,
        delete_flag)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.activityName},
            #{entity.startDate},
            #{entity.endDate},
            #{entity.limitDate},
            #{entity.activityImg},
            #{entity.activityInviteImg},
            #{entity.activityDesc},
            #{entity.activityShareTitle},
            #{entity.activityShareImg},
            #{entity.activityPosterImg},
            #{entity.status},
            #{entity.inviteRewardType},
            #{entity.joinType},
            #{entity.joinRule},
            #{entity.joinChatHmId},
            #{entity.inviteType},
            #{entity.inviteMemberType},
            #{entity.labelFlag},
            #{entity.labelJson},
            #{entity.exceptionNotice},
            #{entity.exceptionNoticeNum},
            #{entity.enterpriseId},
            #{entity.wxEnterpriseId},
            #{entity.createTime},
            #{entity.updateTime},
            #{entity.creatorId},
            #{entity.creatorName},
            #{entity.deleteFlag})
        </foreach>
        on duplicate key update
        activity_name = values(activity_name),
        start_date = values(start_date),
        end_date = values(end_date),
        limit_date = values(limit_date),
        activity_img = values(activity_img),
        activity_invite_img = values(activity_invite_img),
        activity_desc = values(activity_desc),
        activity_share_title = values(activity_share_title),
        activity_share_img = values(activity_share_img),
        activity_poster_img = values(activity_poster_img),
        status = values(status),
        invite_reward_type = values(invite_reward_type),
        join_type = values(join_type),
        join_rule = values(join_rule),
        join_chat_hm_id = values(join_chat_hm_id),
        invite_type = values(invite_type),
        invite_member_type = values(invite_member_type),
        label_flag = values(label_flag),
        label_json = values(label_json),
        exception_notice = values(exception_notice),
        exception_notice_num = values(exception_notice_num),
        enterprise_id = values(enterprise_id),
        wx_enterprise_id = values(wx_enterprise_id),
        create_time = values(create_time),
        update_time = values(update_time),
        creator_id = values(creator_id),
        creator_name = values(creator_name),
        delete_flag = values(delete_flag)
    </insert>


    <!--通过主键修改数据-->
    <update id="update">
        update tab_haoban_group_chat_activity
        <set>
            <if test="activityName != null and activityName != ''">
                activity_name = #{activityName},
            </if>
            <if test="startDate != null">
                start_date = #{startDate},
            </if>
            <if test="endDate != null">
                end_date = #{endDate},
            </if>
            <if test="limitDate != null">
                limit_date = #{limitDate},
            </if>
            <if test="activityImg != null and activityImg != ''">
                activity_img = #{activityImg},
            </if>
            <if test="activityInviteImg != null and activityInviteImg != ''">
                activity_invite_img = #{activityInviteImg},
            </if>
            <if test="activityDesc != null and activityDesc != ''">
                activity_desc = #{activityDesc},
            </if>
            <if test="activityShareTitle != null and activityShareTitle != ''">
                activity_share_title = #{activityShareTitle},
            </if>
            <if test="activityShareImg != null and activityShareImg != ''">
                activity_share_img = #{activityShareImg},
            </if>
            <if test="activityPosterImg != null and activityPosterImg != ''">
                activity_poster_img = #{activityPosterImg},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
            <if test="inviteRewardType != null">
                invite_reward_type = #{inviteRewardType},
            </if>
            <if test="joinType != null">
                join_type = #{joinType},
            </if>
            <if test="joinRule != null and joinRule != ''">
                join_rule = #{joinRule},
            </if>
            <if test="joinChatHmId != null">
                join_chat_hm_id = #{joinChatHmId},
            </if>
            <if test="inviteType != null">
                invite_type = #{inviteType},
            </if>
            <if test="inviteMemberType != null">
                invite_member_type = #{inviteMemberType},
            </if>
            <if test="labelFlag != null">
                label_flag = #{labelFlag},
            </if>
            <if test="labelJson != null and labelJson != ''">
                label_json = #{labelJson},
            </if>
            <if test="exceptionNotice != null">
                exception_notice = #{exceptionNotice},
            </if>
            <if test="exceptionNoticeNum != null">
                exception_notice_num = #{exceptionNoticeNum},
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                enterprise_id = #{enterpriseId},
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                wx_enterprise_id = #{wxEnterpriseId},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime},
            </if>
            <if test="creatorId != null and creatorId != ''">
                creator_id = #{creatorId},
            </if>
            <if test="creatorName != null and creatorName != ''">
                creator_name = #{creatorName},
            </if>
            <if test="deleteFlag != null">
                delete_flag = #{deleteFlag},
            </if>
        </set>
        where chat_activity_id = #{chatActivityId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete
        from tab_haoban_group_chat_activity
        where chat_activity_id = #{chatActivityId}
    </delete>
</mapper>

