<?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.system.mapper.CpsGlbMsgMapper">

    <resultMap type="com.ruoyi.system.domain.CpsGlbMsg" id="CpsGlbMsgResult">
        <result property="id"    column="id"    />
        <result property="uri"    column="uri"    />
        <result property="msg"    column="msg"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectCpsGlbMsgVo">
        select id, uri, msg, update_time, create_time, create_by, update_by from cps_glb_msg
    </sql>

    <select id="selectCpsGlbMsgList" parameterType="com.ruoyi.system.domain.CpsGlbMsg" resultMap="CpsGlbMsgResult">
        <include refid="selectCpsGlbMsgVo"/>
        <where>
            <if test="msg != null  and msg != ''"> and msg like concat('%', #{msg}, '%')</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectCpsGlbMsgById" parameterType="Long" resultMap="CpsGlbMsgResult">
        <include refid="selectCpsGlbMsgVo"/>
        where id = #{id}
    </select>

    <insert id="insertCpsGlbMsg" parameterType="com.ruoyi.system.domain.CpsGlbMsg" useGeneratedKeys="true" keyProperty="id">
        insert into cps_glb_msg
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uri != null">uri,</if>
            <if test="msg != null and msg != ''">msg,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="uri != null">#{uri},</if>
            <if test="msg != null and msg != ''">#{msg},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateCpsGlbMsg" parameterType="com.ruoyi.system.domain.CpsGlbMsg">
        update cps_glb_msg
        <trim prefix="SET" suffixOverrides=",">
            <if test="uri != null">uri = #{uri},</if>
            <if test="msg != null and msg != ''">msg = #{msg},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCpsGlbMsgById" parameterType="Long">
        delete from cps_glb_msg where id = #{id}
    </delete>

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