<?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.cmvr.device.mapper.DeRobotConfigMapper">
    
    <resultMap type="DeRobotConfig" id="DeRobotConfigResult">
        <result property="id"    column="id"    />
        <result property="configId"    column="config_id"    />
        <result property="configType"    column="config_type"    />
        <result property="pid"    column="pid"    />
        <result property="nodeName"    column="node_name"    />
        <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="selectDeRobotConfigVo">
        select id, config_id, config_type, pid, node_name, create_by, create_time, update_by, update_time, remark from de_robot_config
    </sql>

    <select id="selectDeRobotConfigList" parameterType="DeRobotConfig" resultMap="DeRobotConfigResult">
        <include refid="selectDeRobotConfigVo"/>
        <where>  
            <if test="configId != null  and configId != ''"> and config_id = #{configId}</if>
            <if test="configType != null  and configType != ''"> and config_type = #{configType}</if>
            <if test="pid != null  and pid != ''"> and pid = #{pid}</if>
            <if test="nodeName != null  and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
        </where>
    </select>
    
    <select id="selectDeRobotConfigById" parameterType="String" resultMap="DeRobotConfigResult">
        <include refid="selectDeRobotConfigVo"/>
        where id = #{id}
    </select>

    <insert id="insertDeRobotConfig" parameterType="DeRobotConfig">
        insert into de_robot_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="configId != null">config_id,</if>
            <if test="configType != null">config_type,</if>
            <if test="pid != null">pid,</if>
            <if test="nodeName != null">node_name,</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="id != null">#{id},</if>
            <if test="configId != null">#{configId},</if>
            <if test="configType != null">#{configType},</if>
            <if test="pid != null">#{pid},</if>
            <if test="nodeName != null">#{nodeName},</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="updateDeRobotConfig" parameterType="DeRobotConfig">
        update de_robot_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="configId != null">config_id = #{configId},</if>
            <if test="configType != null">config_type = #{configType},</if>
            <if test="pid != null">pid = #{pid},</if>
            <if test="nodeName != null">node_name = #{nodeName},</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="deleteDeRobotConfigById" parameterType="String">
        delete from de_robot_config where id = #{id}
    </delete>

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