<?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.ss.onlineLog.mapper.OnlineLogMapper">

    <resultMap type="OnlineLog" id="EtOnlineLogResult">
        <result property="id"    column="id"    />
        <result property="mac"    column="mac"    />
        <result property="sn"    column="sn"    />
        <result property="onlineStatus"    column="online_status"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectEtOnlineLogVo">
        select id, mac, sn, online_status, longitude, latitude, create_time from ss_online_log
    </sql>

    <select id="selectEtOnlineLogList" parameterType="OnlineLog" resultMap="EtOnlineLogResult">
        <include refid="selectEtOnlineLogVo"/>
        <where>
            <if test="mac != null  and mac != ''"> and mac like concat('%', #{mac}, '%')</if>
            <if test="sn != null  and sn != ''"> and sn like concat('%', #{sn}, '%')</if>
            <if test="onlineStatus != null  and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
        </where>
    </select>

    <select id="selectEtOnlineLogById" parameterType="Long" resultMap="EtOnlineLogResult">
        <include refid="selectEtOnlineLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertEtOnlineLog" parameterType="OnlineLog" useGeneratedKeys="true" keyProperty="id">
        insert into ss_online_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mac != null">mac,</if>
            <if test="sn != null">sn,</if>
            <if test="onlineStatus != null">online_status,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mac != null">#{mac},</if>
            <if test="sn != null">#{sn},</if>
            <if test="onlineStatus != null">#{onlineStatus},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateEtOnlineLog" parameterType="OnlineLog">
        update ss_online_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="mac != null">mac = #{mac},</if>
            <if test="sn != null">sn = #{sn},</if>
            <if test="onlineStatus != null">online_status = #{onlineStatus},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEtOnlineLogById" parameterType="Long">
        delete from ss_online_log where id = #{id}
    </delete>

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