<?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.project.common.mapper.MessageMapper">
    
    <resultMap type="com.ruoyi.project.common.domain.Message" id="MessageResult">
        <result property="id"    column="id"    />
        <result property="messageType"    column="message_type"    />
        <result property="messageContent"    column="message_content"    />
        <result property="messageContentUS"    column="message_contentUS"    />
        <result property="messageContentRU"    column="message_contentRU"    />
        <result property="messageContentES"    column="message_contentES"    />
        <result property="pushTime"    column="push_time"    />
        <result property="pushStatus"    column="push_status"    />
        <result property="delFlag"    column="del_flag"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectMessageVo">
        select id, message_type, message_content, message_contentUS, message_contentRU, message_contentES, push_time, push_status, del_flag, create_by, create_time, update_by, update_time, remark from message
    </sql>

    <select id="selectMessageList" parameterType="com.ruoyi.project.common.domain.Message" resultMap="MessageResult">
        <include refid="selectMessageVo"/>
        <where>  
            <if test="messageType != null  and messageType != ''"> and message_type = #{messageType}</if>
            <if test="messageContent != null  and messageContent != ''"> and message_content like CONCAT('%', #{messageContent},'%')</if>
            <if test="messageContentUS != null  and messageContentUS != ''"> and message_contentUS like CONCAT('%', #{messageContentUS},'%')</if>
            <if test="messageContentRU != null  and messageContentRU != ''"> and message_contentRU like CONCAT('%', #{messageContentRU},'%')</if>
            <if test="messageContentES != null  and messageContentES != ''"> and message_contentES like CONCAT('%', #{messageContentES},'%')</if>
            <if test="pushTime != null "> and push_time = #{pushTime}</if>
            <if test="pushStatus != null  and pushStatus != ''"> and push_status = #{pushStatus}</if>
        </where>
    </select>
    
    <select id="selectMessageById" parameterType="Long" resultMap="MessageResult">
        <include refid="selectMessageVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMessage" parameterType="com.ruoyi.project.common.domain.Message" useGeneratedKeys="true" keyProperty="id">
        insert into message
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="messageType != null and messageType != ''">message_type,</if>
            <if test="messageContent != null">message_content,</if>
            <if test="messageContentUS != null">message_contentUS,</if>
            <if test="messageContentRU != null">message_contentRU,</if>
            <if test="messageContentES != null">message_contentES,</if>
            <if test="pushTime != null">push_time,</if>
            <if test="pushStatus != null">push_status,</if>
            <if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="messageType != null and messageType != ''">#{messageType},</if>
            <if test="messageContent != null">#{messageContent},</if>
            <if test="messageContentUS != null">#{messageContentUS},</if>
            <if test="messageContentRU != null">#{messageContentRU},</if>
            <if test="messageContentES != null">#{messageContentES},</if>
            <if test="pushTime != null">#{pushTime},</if>
            <if test="pushStatus != null">#{pushStatus},</if>
            <if test="delFlag != null">#{delFlag},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateMessage" parameterType="com.ruoyi.project.common.domain.Message">
        update message
        <trim prefix="SET" suffixOverrides=",">
            <if test="messageType != null and messageType != ''">message_type = #{messageType},</if>
            <if test="messageContent != null">message_content = #{messageContent},</if>
            <if test="messageContentUS != null">message_contentUS = #{messageContentUS},</if>
            <if test="messageContentRU != null">message_contentRU = #{messageContentRU},</if>
            <if test="messageContentES != null">message_contentES = #{messageContentES},</if>
            <if test="pushTime != null">push_time = #{pushTime},</if>
            <if test="pushStatus != null">push_status = #{pushStatus},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <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="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMessageById" parameterType="Long">
        delete from message where id = #{id}
    </delete>

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