IotDeviceMapper.xml 7.9 KB
<?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.IotDeviceMapper">
    
    <resultMap type="IotDevice" id="IotDeviceResult">
        <result property="active_time"    column="active_time"    />
        <result property="client_id"    column="client_id"    />
        <result property="completion_auth"    column="completion_auth"    />
        <result property="create_by"    column="create_by"    />
        <result property="create_time"    column="create_time"    />
        <result property="del_flag"    column="del_flag"    />
        <result property="firmware_version"    column="firmware_version"    />
        <result property="img_url"    column="img_url"    />
        <result property="is_shadow"    column="is_shadow"    />
        <result property="latitude"    column="latitude"    />
        <result property="location_way"    column="location_way"    />
        <result property="longitude"    column="longitude"    />
        <result property="name"    column="name"    />
        <result property="network_address"    column="network_address"    />
        <result property="network_ip"    column="network_ip"    />
        <result property="remark"    column="remark"    />
        <result property="rssi"    column="rssi"    />
        <result property="status"    column="status"    />
        <result property="summary"    column="summary"    />
        <result property="things_model_value"    column="things_model_value"    />
        <result property="update_by"    column="update_by"    />
        <result property="update_time"    column="update_time"    />
        <result property="user_id"    column="user_id"    />
        <result property="payload_type"    column="payload_type"    />

    </resultMap>

    <sql id="selectIotDeviceVo">
        select active_time, client_id, completion_auth, create_by, create_time, del_flag, firmware_version, img_url, is_shadow, latitude, location_way, longitude, `name`, network_address, network_ip, remark, rssi, status, summary, things_model_value, update_by, update_time, user_id,payload_type from iot_device
    </sql>

    <select id="selectIotDeviceList" parameterType="IotDevice" resultMap="IotDeviceResult">
        <include refid="selectIotDeviceVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectIotDeviceByClient_id" parameterType="String" resultMap="IotDeviceResult">
        <include refid="selectIotDeviceVo"/>
        where client_id = #{client_id}
    </select>
        
    <insert id="insertIotDevice" parameterType="IotDevice">
        insert into iot_device
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="active_time != null">active_time,</if>
            <if test="client_id != null and client_id != ''">client_id,</if>
            <if test="completion_auth != null">completion_auth,</if>
            <if test="create_by != null">create_by,</if>
            <if test="del_flag != null">del_flag,</if>
            <if test="firmware_version != null">firmware_version,</if>
            <if test="img_url != null">img_url,</if>
            <if test="is_shadow != null">is_shadow,</if>
            <if test="latitude != null">latitude,</if>
            <if test="location_way != null">location_way,</if>
            <if test="longitude != null">longitude,</if>
            <if test="name != null">name,</if>
            <if test="network_address != null">network_address,</if>
            <if test="network_ip != null">network_ip,</if>
            <if test="remark != null">remark,</if>
            <if test="rssi != null">rssi,</if>
            <if test="status != null">status,</if>
            <if test="summary != null">summary,</if>
            <if test="things_model_value != null">things_model_value,</if>
            <if test="update_by != null">update_by,</if>
            <if test="update_time != null">update_time,</if>
            <if test="user_id != null">user_id,</if>
            <if test="payload_type != null">payload_type,</if>
            create_time,
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="active_time != null">#{active_time},</if>
            <if test="client_id != null and client_id != ''">#{client_id},</if>
            <if test="completion_auth != null">#{completion_auth},</if>
            <if test="create_by != null">#{create_by},</if>
            <if test="del_flag != null">#{del_flag},</if>
            <if test="firmware_version != null">#{firmware_version},</if>
            <if test="img_url != null">#{img_url},</if>
            <if test="is_shadow != null">#{is_shadow},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="location_way != null">#{location_way},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="name != null">#{name},</if>
            <if test="network_address != null">#{network_address},</if>
            <if test="network_ip != null">#{network_ip},</if>
            <if test="remark != null">#{remark},</if>
            <if test="rssi != null">#{rssi},</if>
            <if test="status != null">#{status},</if>
            <if test="summary != null">#{summary},</if>
            <if test="things_model_value != null">#{things_model_value},</if>
            <if test="update_by != null">#{update_by},</if>
            <if test="update_time != null">#{update_time},</if>
            <if test="user_id != null">#{user_id},</if>
            <if test="payload_type != null">#{payload_type},</if>
            UNIX_TIMESTAMP(NOW()),
         </trim>
    </insert>

    <update id="updateIotDevice" parameterType="IotDevice">
        update iot_device
        <trim prefix="SET" suffixOverrides=",">
            <if test="active_time != null">active_time = #{active_time},</if>
            <if test="completion_auth != null">completion_auth = #{completion_auth},</if>
            <if test="create_by != null">create_by = #{create_by},</if>
            <if test="create_time != null">create_time = #{create_time},</if>
            <if test="del_flag != null">del_flag = #{del_flag},</if>
            <if test="firmware_version != null">firmware_version = #{firmware_version},</if>
            <if test="img_url != null">img_url = #{img_url},</if>
            <if test="is_shadow != null">is_shadow = #{is_shadow},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="location_way != null">location_way = #{location_way},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="name != null">name = #{name},</if>
            <if test="network_address != null">network_address = #{network_address},</if>
            <if test="network_ip != null">network_ip = #{network_ip},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="rssi != null">rssi = #{rssi},</if>
            <if test="status != null">status = #{status},</if>
            <if test="summary != null">summary = #{summary},</if>
            <if test="things_model_value != null">things_model_value = #{things_model_value},</if>
            <if test="update_by != null">update_by = #{update_by},</if>
            <if test="update_time != null">update_time = #{update_time},</if>
            <if test="user_id != null">user_id = #{user_id},</if>
            <if test="payload_type != null">user_id = #{payload_type},</if>
        </trim>
        where client_id = #{client_id}
    </update>

    <delete id="deleteIotDeviceByClient_id" parameterType="String">
        delete from iot_device where client_id = #{client_id}
    </delete>

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