<?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.DataMsgMapper">
    
    <resultMap type="DataMsg" id="DataMsgResult">
        <result property="id"    column="id"    />
        <result property="sitename"    column="sitename"    />
        <result property="url"    column="url"    />
        <result property="command"    column="command"    />
        <result property="jsonpath"    column="jsonpath"    />
        <result property="ostype"    column="ostype"    />
    </resultMap>

    <sql id="selectDataMsgVo">
        select id, sitename, url, command, jsonpath, ostype from data_msg
    </sql>

    <select id="selectDataMsgList" parameterType="DataMsg" resultMap="DataMsgResult">
        <include refid="selectDataMsgVo"/>
        <where>  
            <if test="sitename != null  and sitename != ''"> and sitename like concat('%', #{sitename}, '%')</if>
            <if test="url != null  and url != ''"> and url like concat('%', #{url}, '%')</if>
        </where>
    </select>
    
    <select id="selectDataMsgById" parameterType="Long" resultMap="DataMsgResult">
        <include refid="selectDataMsgVo"/>
        where id = #{id}
    </select>

    <insert id="insertDataMsg" parameterType="DataMsg" useGeneratedKeys="true" keyProperty="id">
        insert into data_msg
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sitename != null and sitename != ''">sitename,</if>
            <if test="url != null and url != ''">url,</if>
            <if test="command != null and command != ''">command,</if>
            <if test="jsonpath != null and jsonpath != ''">jsonpath,</if>
            <if test="ostype != null and ostype != ''">ostype,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sitename != null and sitename != ''">#{sitename},</if>
            <if test="url != null and url != ''">#{url},</if>
            <if test="command != null and command != ''">#{command},</if>
            <if test="jsonpath != null and jsonpath != ''">#{jsonpath},</if>
            <if test="ostype != null and ostype != ''">#{ostype},</if>
         </trim>
    </insert>

    <update id="updateDataMsg" parameterType="DataMsg">
        update data_msg
        <trim prefix="SET" suffixOverrides=",">
            <if test="sitename != null and sitename != ''">sitename = #{sitename},</if>
            <if test="url != null and url != ''">url = #{url},</if>
            <if test="command != null and command != ''">command = #{command},</if>
            <if test="jsonpath != null and jsonpath != ''">jsonpath = #{jsonpath},</if>
            <if test="ostype != null and ostype != ''">ostype = #{ostype},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDataMsgById" parameterType="Long">
        delete from data_msg where id = #{id}
    </delete>

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

</mapper>