<?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.ruoyi.frequency.userappmessage.mapper.UserAppMessageMapper">
    
    <resultMap type="com.ruoyi.frequency.userappmessage.entity.UserAppMessage" id="UserAppMessageResult">
        <result property="id"    column="id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="userId"    column="user_id"    />
        <result property="userType"    column="user_type"    />
        <result property="messageId"    column="message_id"    />
        <result property="isShow"    column="is_show"    />
        <result property="isRead"    column="is_read"    />
    </resultMap>

    <sql id="selectUserAppMessageVo">
        select id, create_by, create_time, update_by, update_time, del_flag, user_id, user_type, message_id, is_show, is_read from t_user_app_message
    </sql>

    <select id="selectUserAppMessageList" parameterType="com.ruoyi.frequency.userappmessage.entity.UserAppMessage" resultMap="UserAppMessageResult">
        <include refid="selectUserAppMessageVo"/>
        <where>  
            <if test="createBy != null "> and create_by = #{createBy}</if>
            <if test="updateBy != null "> and update_by = #{updateBy}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="userType != null "> and user_type = #{userType}</if>
            <if test="messageId != null "> and message_id = #{messageId}</if>
            <if test="isShow != null "> and is_show = #{isShow}</if>
            <if test="isRead != null "> and is_read = #{isRead}</if>
        </where>
    </select>
    
    <select id="selectUserAppMessageById" parameterType="Long" resultMap="UserAppMessageResult">
        <include refid="selectUserAppMessageVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertUserAppMessage" parameterType="com.ruoyi.frequency.userappmessage.entity.UserAppMessage">
        insert into t_user_app_message
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="userId != null">user_id,</if>
            <if test="userType != null">user_type,</if>
            <if test="messageId != null">message_id,</if>
            <if test="isShow != null">is_show,</if>
            <if test="isRead != null">is_read,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userType != null">#{userType},</if>
            <if test="messageId != null">#{messageId},</if>
            <if test="isShow != null">#{isShow},</if>
            <if test="isRead != null">#{isRead},</if>
         </trim>
    </insert>

    <update id="updateByAppMessage" parameterType="com.ruoyi.frequency.userappmessage.entity.UserAppMessage">
        update t_user_app_message
        <trim prefix="SET" suffixOverrides=",">
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userType != null">user_type = #{userType},</if>
            <if test="messageId != null">message_id = #{messageId},</if>
            <if test="isShow != null">is_show = #{isShow},</if>
            <if test="isRead != null">is_read = #{isRead},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUserAppMessageById" parameterType="Long">
        delete from t_user_app_message where id = #{id}
    </delete>

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