<?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.QwGroupMsgItemMapper">

    <resultMap type="QwGroupMsgItem" id="QwGroupMsgItemResult">
        <result property="id"    column="id"    />
        <result property="groupMsgId"    column="group_msg_id"    />
        <result property="msgId"    column="msg_id"    />
        <result property="msgType"    column="msg_type"    />
        <result property="mediaId"    column="media_id"    />
        <result property="mediaPicUrl"    column="media_pic_url"    />
        <result property="title"    column="title"    />
        <result property="picurl"    column="picurl"    />
        <result property="description"    column="description"    />
        <result property="url"    column="url"    />
        <result property="miniprogramPicMediaId"    column="miniprogram_pic_media_id"    />
        <result property="miniprogramPicUrl"    column="miniprogram_pic_url"    />
        <result property="miniprogramAppid"    column="miniprogram_appid"    />
        <result property="miniprogramTitle"    column="miniprogram_title"    />
        <result property="miniprogramPage"    column="miniprogram_page"    />
        <result property="videoMediaId"    column="video_media_id"    />
        <result property="videoUrl"    column="video_url"    />
        <result property="fileMediaId"    column="file_media_id"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="corpId"    column="corp_id"    />
        <result property="companyId"    column="company_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createdAt"    column="created_at"    />
    </resultMap>

    <sql id="selectQwGroupMsgItemVo">
        select id, group_msg_id, msg_id, msg_type, media_id, media_pic_url, title, picurl, description, url, miniprogram_pic_media_id, miniprogram_pic_url, miniprogram_appid, miniprogram_title, miniprogram_page, video_media_id, video_url, file_media_id, file_url, corp_id, company_id, create_time, update_time, created_at from qw_group_msg_item
    </sql>

    <select id="selectQwGroupMsgItemList" parameterType="QwGroupMsgItem" resultMap="QwGroupMsgItemResult">
        <include refid="selectQwGroupMsgItemVo"/>
        <where>
            <if test="groupMsgId != null "> and group_msg_id = #{groupMsgId}</if>
            <if test="msgId != null  and msgId != ''"> and msg_id = #{msgId}</if>
            <if test="msgType != null "> and msg_type = #{msgType}</if>
            <if test="mediaId != null  and mediaId != ''"> and media_id = #{mediaId}</if>
            <if test="mediaPicUrl != null  and mediaPicUrl != ''"> and media_pic_url = #{mediaPicUrl}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="picurl != null  and picurl != ''"> and picurl = #{picurl}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="miniprogramPicMediaId != null  and miniprogramPicMediaId != ''"> and miniprogram_pic_media_id = #{miniprogramPicMediaId}</if>
            <if test="miniprogramPicUrl != null  and miniprogramPicUrl != ''"> and miniprogram_pic_url = #{miniprogramPicUrl}</if>
            <if test="miniprogramAppid != null  and miniprogramAppid != ''"> and miniprogram_appid = #{miniprogramAppid}</if>
            <if test="miniprogramTitle != null  and miniprogramTitle != ''"> and miniprogram_title = #{miniprogramTitle}</if>
            <if test="miniprogramPage != null  and miniprogramPage != ''"> and miniprogram_page = #{miniprogramPage}</if>
            <if test="videoMediaId != null  and videoMediaId != ''"> and video_media_id = #{videoMediaId}</if>
            <if test="videoUrl != null  and videoUrl != ''"> and video_url = #{videoUrl}</if>
            <if test="fileMediaId != null  and fileMediaId != ''"> and file_media_id = #{fileMediaId}</if>
            <if test="fileUrl != null  and fileUrl != ''"> and file_url = #{fileUrl}</if>
            <if test="corpId != null  and corpId != ''"> and corp_id = #{corpId}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="createdAt != null  and createdAt != ''"> and created_at = #{createdAt}</if>
        </where>
    </select>

    <select id="selectQwGroupMsgItemById" parameterType="Long" resultMap="QwGroupMsgItemResult">
        <include refid="selectQwGroupMsgItemVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwGroupMsgItem" parameterType="QwGroupMsgItem" useGeneratedKeys="true" keyProperty="id">
        insert into qw_group_msg_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="groupMsgId != null">group_msg_id,</if>
            <if test="msgId != null">msg_id,</if>
            <if test="msgType != null">msg_type,</if>
            <if test="mediaId != null">media_id,</if>
            <if test="mediaPicUrl != null">media_pic_url,</if>
            <if test="title != null">title,</if>
            <if test="picurl != null">picurl,</if>
            <if test="description != null">description,</if>
            <if test="url != null">url,</if>
            <if test="miniprogramPicMediaId != null">miniprogram_pic_media_id,</if>
            <if test="miniprogramPicUrl != null">miniprogram_pic_url,</if>
            <if test="miniprogramAppid != null">miniprogram_appid,</if>
            <if test="miniprogramTitle != null">miniprogram_title,</if>
            <if test="miniprogramPage != null">miniprogram_page,</if>
            <if test="videoMediaId != null">video_media_id,</if>
            <if test="videoUrl != null">video_url,</if>
            <if test="fileMediaId != null">file_media_id,</if>
            <if test="fileUrl != null">file_url,</if>
            <if test="corpId != null">corp_id,</if>
            <if test="companyId != null">company_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createdAt != null">created_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="groupMsgId != null">#{groupMsgId},</if>
            <if test="msgId != null">#{msgId},</if>
            <if test="msgType != null">#{msgType},</if>
            <if test="mediaId != null">#{mediaId},</if>
            <if test="mediaPicUrl != null">#{mediaPicUrl},</if>
            <if test="title != null">#{title},</if>
            <if test="picurl != null">#{picurl},</if>
            <if test="description != null">#{description},</if>
            <if test="url != null">#{url},</if>
            <if test="miniprogramPicMediaId != null">#{miniprogramPicMediaId},</if>
            <if test="miniprogramPicUrl != null">#{miniprogramPicUrl},</if>
            <if test="miniprogramAppid != null">#{miniprogramAppid},</if>
            <if test="miniprogramTitle != null">#{miniprogramTitle},</if>
            <if test="miniprogramPage != null">#{miniprogramPage},</if>
            <if test="videoMediaId != null">#{videoMediaId},</if>
            <if test="videoUrl != null">#{videoUrl},</if>
            <if test="fileMediaId != null">#{fileMediaId},</if>
            <if test="fileUrl != null">#{fileUrl},</if>
            <if test="corpId != null">#{corpId},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createdAt != null">#{createdAt},</if>
         </trim>
    </insert>

    <update id="updateQwGroupMsgItem" parameterType="QwGroupMsgItem">
        update qw_group_msg_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="groupMsgId != null">group_msg_id = #{groupMsgId},</if>
            <if test="msgId != null">msg_id = #{msgId},</if>
            <if test="msgType != null">msg_type = #{msgType},</if>
            <if test="mediaId != null">media_id = #{mediaId},</if>
            <if test="mediaPicUrl != null">media_pic_url = #{mediaPicUrl},</if>
            <if test="title != null">title = #{title},</if>
            <if test="picurl != null">picurl = #{picurl},</if>
            <if test="description != null">description = #{description},</if>
            <if test="url != null">url = #{url},</if>
            <if test="miniprogramPicMediaId != null">miniprogram_pic_media_id = #{miniprogramPicMediaId},</if>
            <if test="miniprogramPicUrl != null">miniprogram_pic_url = #{miniprogramPicUrl},</if>
            <if test="miniprogramAppid != null">miniprogram_appid = #{miniprogramAppid},</if>
            <if test="miniprogramTitle != null">miniprogram_title = #{miniprogramTitle},</if>
            <if test="miniprogramPage != null">miniprogram_page = #{miniprogramPage},</if>
            <if test="videoMediaId != null">video_media_id = #{videoMediaId},</if>
            <if test="videoUrl != null">video_url = #{videoUrl},</if>
            <if test="fileMediaId != null">file_media_id = #{fileMediaId},</if>
            <if test="fileUrl != null">file_url = #{fileUrl},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwGroupMsgItemById" parameterType="Long">
        delete from qw_group_msg_item where id = #{id}
    </delete>

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

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