| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?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.fs.watch.mapper.WatchSosCallLogsMapper">
- <resultMap type="com.fs.watch.domain.WatchSosCallLogs" id="BaseResultMap">
- <result property="id" column="id" jdbcType="OTHER" typeHandler="com.fs.watch.handler.UUIDTypeHandler"/>
- <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
- <result property="alarmTime" column="alarm_time" jdbcType="VARCHAR"/>
- <result property="lat" column="lat" jdbcType="VARCHAR"/>
- <result property="lon" column="lon" jdbcType="VARCHAR"/>
- <result property="callLogs" column="call_logs" jdbcType="VARCHAR"/>
- </resultMap>
- <!-- 查询列列表 -->
- <sql id="Base_Column_List">
- id, device_id, alarm_time, lat, lon, call_logs
- </sql>
- <!-- 根据创建时间查询 -->
- <select id="queryByAlarmTime" parameterType="String" resultType="Integer">
- SELECT COUNT(*)
- FROM watch_sos_call_logs
- WHERE alarm_time = #{alarmTime}
- </select>
- <select id="getByDeviceIdAndTime" resultMap="BaseResultMap">
- select * from watch_sos_call_logs where device_id like #{deviceId}
- and alarm_time = #{alarmTime}
- </select>
- <select id="getByDeviceIdAndTimeOne" resultMap="BaseResultMap">
- SELECT *
- FROM watch_sos_call_logs
- WHERE device_id LIKE #{deviceId}
- ORDER BY abs(toUnixTimestamp(alarm_time) - #{alarmTime})
- LIMIT 1
- </select>
- <!-- 插入数据 -->
- <update id="insert" parameterType="com.fs.watch.domain.WatchSosCallLogs">
- INSERT INTO watch_sos_call_logs
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- id,
- </if>
- <if test="data.deviceId != null">
- device_id,
- </if>
- <if test="data.alarmTime != null">
- alarm_time,
- </if>
- <if test="data.lat != null">
- lat,
- </if>
- <if test="data.lon != null">
- lon,
- </if>
- <if test="data.callLogs != null">
- call_logs,
- </if>
- </trim>
- <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
- <if test="data.id != null">
- #{data.id},
- </if>
- <if test="data.deviceId != null">
- #{data.deviceId},
- </if>
- <if test="data.alarmTime != null">
- #{data.alarmTime},
- </if>
- <if test="data.lat != null">
- #{data.lat},
- </if>
- <if test="data.lon != null">
- #{data.lon},
- </if>
- <if test="data.callLogs != null">
- #{data.callLogs},
- </if>
- </trim>
- </update>
- <update id="batchInsertData" parameterType="java.util.List">
- INSERT INTO watch_sos_call_logs (device_id, alarm_time, lat, lon, call_logs)
- VALUES
- <foreach collection="list" item="item" index="index" separator=",">
- (
- #{item.deviceId},
- #{item.alarmTime},
- #{item.lat},
- #{item.lon},
- #{item.callLogs}
- )
- </foreach>
- </update>
- </mapper>
|