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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  | package com.genersoft.iot.vmp.storager.dao; 
 |    
 |  import com.genersoft.iot.vmp.gb28181.bean.Device; 
 |  import org.apache.ibatis.annotations.*; 
 |  import org.springframework.stereotype.Repository; 
 |    
 |  import java.util.List; 
 |    
 |  /** 
 |   * 用于存储设备信息 
 |   */ 
 |  @Mapper 
 |  @Repository 
 |  public interface DeviceMapper { 
 |    
 |      @Select("SELECT * FROM device WHERE deviceId = #{deviceId}") 
 |      Device getDeviceByDeviceId(String deviceId); 
 |    
 |      @Insert("INSERT INTO device (" + 
 |                  "deviceId, " + 
 |                  "name, " + 
 |                  "manufacturer, " + 
 |                  "model, " + 
 |                  "firmware, " + 
 |                  "transport," + 
 |                  "streamMode," + 
 |                  "ip," + 
 |                  "port," + 
 |                  "hostAddress," + 
 |                  "online" + 
 |              ") VALUES (" + 
 |                  "#{deviceId}," + 
 |                  "#{name}," + 
 |                  "#{manufacturer}," + 
 |                  "#{model}," + 
 |                  "#{firmware}," + 
 |                  "#{transport}," + 
 |                  "#{streamMode}," + 
 |                  "#{ip}," + 
 |                  "#{port}," + 
 |                  "#{hostAddress}," + 
 |                  "#{online}" + 
 |              ")") 
 |      int add(Device device); 
 |    
 |      @Update(value = {" <script>" + 
 |                  "UPDATE device " + 
 |                  "SET deviceId='${deviceId}'" + 
 |                  "<if test=\"name != null\">, name='${name}'</if>" + 
 |                  "<if test=\"manufacturer != null\">, manufacturer='${manufacturer}'</if>" + 
 |                  "<if test=\"model != null\">, model='${model}'</if>" + 
 |                  "<if test=\"firmware != null\">, firmware='${firmware}'</if>" + 
 |                  "<if test=\"transport != null\">, transport='${transport}'</if>" + 
 |                  "<if test=\"streamMode != null\">, streamMode='${streamMode}'</if>" + 
 |                  "<if test=\"ip != null\">, ip='${ip}'</if>" + 
 |                  "<if test=\"port != null\">, port=${port}</if>" + 
 |                  "<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" + 
 |                  "<if test=\"online != null\">, online=${online}</if>" + 
 |                  "WHERE deviceId='${deviceId}'"+ 
 |              " </script>"}) 
 |      int update(Device device); 
 |    
 |      @Select("SELECT *, (SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount  FROM device de") 
 |      List<Device> getDevices(); 
 |    
 |      @Delete("DELETE FROM device WHERE deviceId=#{deviceId}") 
 |      int del(String deviceId); 
 |  } 
 |  
  |