Blame view

service-user/src/main/resources/mapper/property/LocationTrackMapper.xml 1.82 KB
88e030b7   王彪总   init project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  <?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="LocationTrackV1ServiceDaoImpl">
  
      <insert id="saveLocationTrack" parameterType="com.java110.po.property.LocationTrackPo">
          INSERT INTO location_track(user_id, longitude, latitude, report_time, bind_relation, loc_status, create_time)
          VALUES(#{userId}, #{longitude}, #{latitude}, #{reportTime}, #{bindRelation}, #{locStatus}, NOW())
      </insert>
  
      <select id="queryLocationTracks" parameterType="map" resultType="map">
          SELECT lt.*, pu.name AS user_name, pu.work_type
          FROM location_track lt
          LEFT JOIN property_user pu ON lt.user_id = pu.user_id
          WHERE 1=1
          <if test="userId != null and userId != ''">AND lt.user_id = #{userId}</if>
          <if test="startTime != null and startTime != ''">AND lt.report_time &gt;= #{startTime}</if>
          <if test="endTime != null and endTime != ''">AND lt.report_time &lt;= #{endTime}</if>
          ORDER BY lt.report_time ASC
          <if test="page != null and page != '' and row != null and row != ''">
              LIMIT #{page}, #{row}
          </if>
      </select>
  
      <select id="queryLocationTracksCount" parameterType="map" resultType="map">
          SELECT COUNT(1) count FROM location_track lt WHERE 1=1
          <if test="userId != null and userId != ''">AND lt.user_id = #{userId}</if>
          <if test="startTime != null and startTime != ''">AND lt.report_time &gt;= #{startTime}</if>
          <if test="endTime != null and endTime != ''">AND lt.report_time &lt;= #{endTime}</if>
      </select>
  
      <select id="queryLastLocationByUserId" parameterType="string" resultType="map">
          SELECT * FROM location_track WHERE user_id = #{userId} ORDER BY report_time DESC LIMIT 1
      </select>
  
  </mapper>