Commit 7b601a3e8f6de4acc9d6b9885ef23d6c90a4f349

Authored by xubinbin
1 parent 09bfc69f

使用#替代$,防止SQL注入的风险(主要防止模糊查询sql部分的注入)。

src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java
... ... @@ -16,19 +16,19 @@ import java.util.List;
16 16 public interface DeviceAlarmMapper {
17 17  
18 18 @Insert("INSERT INTO device_alarm (deviceId, channelId, alarmPriority, alarmMethod, alarmTime, alarmDescription, longitude, latitude, alarmType , createTime ) " +
19   - "VALUES ('${deviceId}', '${channelId}', '${alarmPriority}', '${alarmMethod}', '${alarmTime}', '${alarmDescription}', ${longitude}, ${latitude}, '${alarmType}', '${createTime}')")
  19 + "VALUES (#{deviceId}, #{channelId}, #{alarmPriority}, #{alarmMethod}, #{alarmTime}, #{alarmDescription}, #{longitude}, #{latitude}, #{alarmType}, #{createTime})")
20 20 int add(DeviceAlarm alarm);
21 21  
22 22  
23 23 @Select(value = {" <script>" +
24 24 " SELECT * FROM device_alarm " +
25 25 " WHERE 1=1 " +
26   - " <if test=\"deviceId != null\" > AND deviceId = '${deviceId}'</if>" +
27   - " <if test=\"alarmPriority != null\" > AND alarmPriority = '${alarmPriority}' </if>" +
28   - " <if test=\"alarmMethod != null\" > AND alarmMethod = '${alarmMethod}' </if>" +
29   - " <if test=\"alarmType != null\" > AND alarmType = '${alarmType}' </if>" +
30   - " <if test=\"startTime != null\" > AND alarmTime &gt;= '${startTime}' </if>" +
31   - " <if test=\"endTime != null\" > AND alarmTime &lt;= '${endTime}' </if>" +
  26 + " <if test=\"deviceId != null\" > AND deviceId = #{deviceId}</if>" +
  27 + " <if test=\"alarmPriority != null\" > AND alarmPriority = #{alarmPriority} </if>" +
  28 + " <if test=\"alarmMethod != null\" > AND alarmMethod = #{alarmMethod} </if>" +
  29 + " <if test=\"alarmType != null\" > AND alarmType = #{alarmType} </if>" +
  30 + " <if test=\"startTime != null\" > AND alarmTime &gt;= #{startTime} </if>" +
  31 + " <if test=\"endTime != null\" > AND alarmTime &lt;= #{endTime} </if>" +
32 32 " ORDER BY alarmTime ASC " +
33 33 " </script>"})
34 34 List<DeviceAlarm> query(String deviceId, String alarmPriority, String alarmMethod,
... ... @@ -38,10 +38,10 @@ public interface DeviceAlarmMapper {
38 38 @Delete(" <script>" +
39 39 "DELETE FROM device_alarm WHERE 1=1 " +
40 40 " <if test=\"deviceIdList != null and id == null \" > AND deviceId in " +
41   - "<foreach collection='deviceIdList' item='item' open='(' separator=',' close=')' > '${item}'</foreach>" +
  41 + "<foreach collection='deviceIdList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
42 42 "</if>" +
43   - " <if test=\"time != null and id == null \" > AND alarmTime &lt;= '${time}'</if>" +
44   - " <if test=\"id != null\" > AND id = ${id}</if>" +
  43 + " <if test=\"time != null and id == null \" > AND alarmTime &lt;= #{time}</if>" +
  44 + " <if test=\"id != null\" > AND id = #{id}</if>" +
45 45 " </script>"
46 46 )
47 47 int clearAlarmBeforeTime(Integer id, List<String> deviceIdList, String time);
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
... ... @@ -20,46 +20,46 @@ public interface DeviceChannelMapper {
20 20 "address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
21 21 "ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
22 22 "longitudeWgs84, latitudeWgs84, hasAudio, createTime, updateTime, businessGroupId, gpsTime) " +
23   - "VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
24   - "'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
25   - "'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude}, ${longitudeGcj02}, " +
26   - "${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84}, ${hasAudio}, '${createTime}', '${updateTime}', '${businessGroupId}', '${gpsTime}')")
  23 + "VALUES (#{channelId}, #{deviceId}, #{name}, #{manufacture}, #{model}, #{owner}, #{civilCode}, #{block}," +
  24 + "#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{secrecy}, " +
  25 + "#{ipAddress}, #{port}, #{password}, #{PTZType}, #{status}, #{streamId}, #{longitude}, #{latitude}, #{longitudeGcj02}, " +
  26 + "#{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{hasAudio}, #{createTime}, #{updateTime}, #{businessGroupId}, #{gpsTime})")
27 27 int add(DeviceChannel channel);
28 28  
29 29 @Update(value = {" <script>" +
30 30 "UPDATE device_channel " +
31   - "SET updateTime='${updateTime}'" +
32   - "<if test='name != null'>, name='${name}'</if>" +
33   - "<if test='manufacture != null'>, manufacture='${manufacture}'</if>" +
34   - "<if test='model != null'>, model='${model}'</if>" +
35   - "<if test='owner != null'>, owner='${owner}'</if>" +
36   - "<if test='civilCode != null'>, civilCode='${civilCode}'</if>" +
37   - "<if test='block != null'>, block='${block}'</if>" +
38   - "<if test='address != null'>, address='${address}'</if>" +
39   - "<if test='parental != null'>, parental=${parental}</if>" +
40   - "<if test='parentId != null'>, parentId='${parentId}'</if>" +
41   - "<if test='safetyWay != null'>, safetyWay=${safetyWay}</if>" +
42   - "<if test='registerWay != null'>, registerWay=${registerWay}</if>" +
43   - "<if test='certNum != null'>, certNum='${certNum}'</if>" +
44   - "<if test='certifiable != null'>, certifiable=${certifiable}</if>" +
45   - "<if test='errCode != null'>, errCode=${errCode}</if>" +
46   - "<if test='secrecy != null'>, secrecy='${secrecy}'</if>" +
47   - "<if test='ipAddress != null'>, ipAddress='${ipAddress}'</if>" +
48   - "<if test='port != null'>, port=${port}</if>" +
49   - "<if test='password != null'>, password='${password}'</if>" +
50   - "<if test='PTZType != null'>, PTZType=${PTZType}</if>" +
51   - "<if test='status != null'>, status='${status}'</if>" +
52   - "<if test='streamId != null'>, streamId='${streamId}'</if>" +
53   - "<if test='hasAudio != null'>, hasAudio=${hasAudio}</if>" +
54   - "<if test='longitude != null'>, longitude=${longitude}</if>" +
55   - "<if test='latitude != null'>, latitude=${latitude}</if>" +
56   - "<if test='longitudeGcj02 != null'>, longitudeGcj02=${longitudeGcj02}</if>" +
57   - "<if test='latitudeGcj02 != null'>, latitudeGcj02=${latitudeGcj02}</if>" +
58   - "<if test='longitudeWgs84 != null'>, longitudeWgs84=${longitudeWgs84}</if>" +
59   - "<if test='latitudeWgs84 != null'>, latitudeWgs84=${latitudeWgs84}</if>" +
  31 + "SET updateTime=#{updateTime}" +
  32 + "<if test='name != null'>, name=#{name}</if>" +
  33 + "<if test='manufacture != null'>, manufacture=#{manufacture}</if>" +
  34 + "<if test='model != null'>, model=#{model}</if>" +
  35 + "<if test='owner != null'>, owner=#{owner}</if>" +
  36 + "<if test='civilCode != null'>, civilCode=#{civilCode}</if>" +
  37 + "<if test='block != null'>, block=#{block}</if>" +
  38 + "<if test='address != null'>, address=#{address}</if>" +
  39 + "<if test='parental != null'>, parental=#{parental}</if>" +
  40 + "<if test='parentId != null'>, parentId=#{parentId}</if>" +
  41 + "<if test='safetyWay != null'>, safetyWay=#{safetyWay}</if>" +
  42 + "<if test='registerWay != null'>, registerWay=#{registerWay}</if>" +
  43 + "<if test='certNum != null'>, certNum=#{certNum}</if>" +
  44 + "<if test='certifiable != null'>, certifiable=#{certifiable}</if>" +
  45 + "<if test='errCode != null'>, errCode=#{errCode}</if>" +
  46 + "<if test='secrecy != null'>, secrecy=#{secrecy}</if>" +
  47 + "<if test='ipAddress != null'>, ipAddress=#{ipAddress}</if>" +
  48 + "<if test='port != null'>, port=#{port}</if>" +
  49 + "<if test='password != null'>, password=#{password}</if>" +
  50 + "<if test='PTZType != null'>, PTZType=#{PTZType}</if>" +
  51 + "<if test='status != null'>, status=#{status}</if>" +
  52 + "<if test='streamId != null'>, streamId=#{streamId}</if>" +
  53 + "<if test='hasAudio != null'>, hasAudio=#{hasAudio}</if>" +
  54 + "<if test='longitude != null'>, longitude=#{longitude}</if>" +
  55 + "<if test='latitude != null'>, latitude=#{latitude}</if>" +
  56 + "<if test='longitudeGcj02 != null'>, longitudeGcj02=#{longitudeGcj02}</if>" +
  57 + "<if test='latitudeGcj02 != null'>, latitudeGcj02=#{latitudeGcj02}</if>" +
  58 + "<if test='longitudeWgs84 != null'>, longitudeWgs84=#{longitudeWgs84}</if>" +
  59 + "<if test='latitudeWgs84 != null'>, latitudeWgs84=#{latitudeWgs84}</if>" +
60 60 "<if test='businessGroupId != null'>, businessGroupId=#{businessGroupId}</if>" +
61 61 "<if test='gpsTime != null'>, gpsTime=#{gpsTime}</if>" +
62   - "WHERE deviceId='${deviceId}' AND channelId='${channelId}'"+
  62 + "WHERE deviceId=#{deviceId} AND channelId=#{channelId}"+
63 63 " </script>"})
64 64 int update(DeviceChannel channel);
65 65  
... ... @@ -70,7 +70,7 @@ public interface DeviceChannelMapper {
70 70 "device_channel dc " +
71 71 "WHERE " +
72 72 "dc.deviceId = #{deviceId} " +
73   - " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
  73 +" <if test='query != null'> AND (dc.channelId LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%'))</if> " +
74 74 " <if test='parentChannelId != null'> AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) </if> " +
75 75 " <if test='online == true' > AND dc.status=1</if>" +
76 76 " <if test='online == false' > AND dc.status=0</if>" +
... ... @@ -110,7 +110,7 @@ public interface DeviceChannelMapper {
110 110 " LEFT JOIN device de ON dc.deviceId = de.deviceId " +
111 111 " LEFT JOIN platform_gb_channel pgc on pgc.deviceChannelId = dc.id " +
112 112 " WHERE 1=1 " +
113   - " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
  113 + " <if test='query != null'> AND (dc.channelId LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%'))</if> " +
114 114 " <if test='online == true' > AND dc.status=1</if> " +
115 115 " <if test='online == false' > AND dc.status=0</if> " +
116 116 " <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc.subCount > 0</if> " +
... ... @@ -151,14 +151,14 @@ public interface DeviceChannelMapper {
151 151 " longitudeWgs84, latitudeWgs84, hasAudio, createTime, updateTime, businessGroupId, gpsTime) " +
152 152 "values " +
153 153 "<foreach collection='addChannels' index='index' item='item' separator=','> " +
154   - "('${item.channelId}', '${item.deviceId}', '${item.name}', '${item.manufacture}', '${item.model}', " +
155   - "'${item.owner}', '${item.civilCode}', '${item.block}',${item.subCount}," +
156   - "'${item.address}', ${item.parental}, '${item.parentId}', ${item.safetyWay}, ${item.registerWay}, " +
157   - "'${item.certNum}', ${item.certifiable}, ${item.errCode}, '${item.secrecy}', " +
158   - "'${item.ipAddress}', ${item.port}, '${item.password}', ${item.PTZType}, ${item.status}, " +
159   - "'${item.streamId}', ${item.longitude}, ${item.latitude},${item.longitudeGcj02}, " +
160   - "${item.latitudeGcj02},${item.longitudeWgs84}, ${item.latitudeWgs84}, ${item.hasAudio},'${item.createTime}', '${item.updateTime}', " +
161   - "'${item.businessGroupId}', '${item.gpsTime}') " +
  154 + "(#{item.channelId}, #{item.deviceId}, #{item.name}, #{item.manufacture}, #{item.model}, " +
  155 + "#{item.owner}, #{item.civilCode}, #{item.block},#{item.subCount}," +
  156 + "#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, " +
  157 + "#{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.secrecy}, " +
  158 + "#{item.ipAddress}, #{item.port}, #{item.password}, #{item.PTZType}, #{item.status}, " +
  159 + "#{item.streamId}, #{item.longitude}, #{item.latitude},#{item.longitudeGcj02}, " +
  160 + "#{item.latitudeGcj02},#{item.longitudeWgs84}, #{item.latitudeWgs84}, #{item.hasAudio}, now(), now(), " +
  161 + "#{item.businessGroupId}, #{item.gpsTime}) " +
162 162 "</foreach> " +
163 163 "ON DUPLICATE KEY UPDATE " +
164 164 "updateTime=VALUES(updateTime), " +
... ... @@ -203,39 +203,39 @@ public interface DeviceChannelMapper {
203 203 "<foreach collection='updateChannels' item='item' separator=';'>" +
204 204 " UPDATE" +
205 205 " device_channel" +
206   - " SET updateTime='${item.updateTime}'" +
207   - "<if test='item.name != null'>, name='${item.name}'</if>" +
208   - "<if test='item.manufacture != null'>, manufacture='${item.manufacture}'</if>" +
209   - "<if test='item.model != null'>, model='${item.model}'</if>" +
210   - "<if test='item.owner != null'>, owner='${item.owner}'</if>" +
211   - "<if test='item.civilCode != null'>, civilCode='${item.civilCode}'</if>" +
212   - "<if test='item.block != null'>, block='${item.block}'</if>" +
213   - "<if test='item.subCount != null'>, block=${item.subCount}</if>" +
214   - "<if test='item.address != null'>, address='${item.address}'</if>" +
215   - "<if test='item.parental != null'>, parental=${item.parental}</if>" +
216   - "<if test='item.parentId != null'>, parentId='${item.parentId}'</if>" +
217   - "<if test='item.safetyWay != null'>, safetyWay=${item.safetyWay}</if>" +
218   - "<if test='item.registerWay != null'>, registerWay=${item.registerWay}</if>" +
219   - "<if test='item.certNum != null'>, certNum='${item.certNum}'</if>" +
220   - "<if test='item.certifiable != null'>, certifiable=${item.certifiable}</if>" +
221   - "<if test='item.errCode != null'>, errCode=${item.errCode}</if>" +
222   - "<if test='item.secrecy != null'>, secrecy='${item.secrecy}'</if>" +
223   - "<if test='item.ipAddress != null'>, ipAddress='${item.ipAddress}'</if>" +
224   - "<if test='item.port != null'>, port=${item.port}</if>" +
225   - "<if test='item.password != null'>, password='${item.password}'</if>" +
226   - "<if test='item.PTZType != null'>, PTZType=${item.PTZType}</if>" +
227   - "<if test='item.status != null'>, status='${item.status}'</if>" +
228   - "<if test='item.streamId != null'>, streamId='${item.streamId}'</if>" +
229   - "<if test='item.hasAudio != null'>, hasAudio=${item.hasAudio}</if>" +
230   - "<if test='item.longitude != null'>, longitude=${item.longitude}</if>" +
231   - "<if test='item.latitude != null'>, latitude=${item.latitude}</if>" +
232   - "<if test='item.longitudeGcj02 != null'>, longitudeGcj02=${item.longitudeGcj02}</if>" +
233   - "<if test='item.latitudeGcj02 != null'>, latitudeGcj02=${item.latitudeGcj02}</if>" +
234   - "<if test='item.longitudeWgs84 != null'>, longitudeWgs84=${item.longitudeWgs84}</if>" +
235   - "<if test='item.latitudeWgs84 != null'>, latitudeWgs84=${item.latitudeWgs84}</if>" +
  206 + " SET updateTime=#{item.updateTime}" +
  207 + "<if test='item.name != null'>, name=#{item.name}</if>" +
  208 + "<if test='item.manufacture != null'>, manufacture=#{item.manufacture}</if>" +
  209 + "<if test='item.model != null'>, model=#{item.model}</if>" +
  210 + "<if test='item.owner != null'>, owner=#{item.owner}</if>" +
  211 + "<if test='item.civilCode != null'>, civilCode=#{item.civilCode}</if>" +
  212 + "<if test='item.block != null'>, block=#{item.block}</if>" +
  213 + "<if test='item.subCount != null'>, block=#{item.subCount}</if>" +
  214 + "<if test='item.address != null'>, address=#{item.address}</if>" +
  215 + "<if test='item.parental != null'>, parental=#{item.parental}</if>" +
  216 + "<if test='item.parentId != null'>, parentId=#{item.parentId}</if>" +
  217 + "<if test='item.safetyWay != null'>, safetyWay=#{item.safetyWay}</if>" +
  218 + "<if test='item.registerWay != null'>, registerWay=#{item.registerWay}</if>" +
  219 + "<if test='item.certNum != null'>, certNum=#{item.certNum}</if>" +
  220 + "<if test='item.certifiable != null'>, certifiable=#{item.certifiable}</if>" +
  221 + "<if test='item.errCode != null'>, errCode=#{item.errCode}</if>" +
  222 + "<if test='item.secrecy != null'>, secrecy=#{item.secrecy}</if>" +
  223 + "<if test='item.ipAddress != null'>, ipAddress=#{item.ipAddress}</if>" +
  224 + "<if test='item.port != null'>, port=#{item.port}</if>" +
  225 + "<if test='item.password != null'>, password=#{item.password}</if>" +
  226 + "<if test='item.PTZType != null'>, PTZType=#{item.PTZType}</if>" +
  227 + "<if test='item.status != null'>, status=#{item.status}</if>" +
  228 + "<if test='item.streamId != null'>, streamId=#{item.streamId}</if>" +
  229 + "<if test='item.hasAudio != null'>, hasAudio=#{item.hasAudio}</if>" +
  230 + "<if test='item.longitude != null'>, longitude=#{item.longitude}</if>" +
  231 + "<if test='item.latitude != null'>, latitude=#{item.latitude}</if>" +
  232 + "<if test='item.longitudeGcj02 != null'>, longitudeGcj02=#{item.longitudeGcj02}</if>" +
  233 + "<if test='item.latitudeGcj02 != null'>, latitudeGcj02=#{item.latitudeGcj02}</if>" +
  234 + "<if test='item.longitudeWgs84 != null'>, longitudeWgs84=#{item.longitudeWgs84}</if>" +
  235 + "<if test='item.latitudeWgs84 != null'>, latitudeWgs84=#{item.latitudeWgs84}</if>" +
236 236 "<if test='item.businessGroupId != null'>, businessGroupId=#{item.businessGroupId}</if>" +
237 237 "<if test='item.gpsTime != null'>, gpsTime=#{item.gpsTime}</if>" +
238   - "WHERE deviceId='${item.deviceId}' AND channelId='${item.channelId}'"+
  238 + "WHERE deviceId=#{item.deviceId} AND channelId=#{item.channelId}"+
239 239 "</foreach>" +
240 240 "</script>"})
241 241 int batchUpdate(List<DeviceChannel> updateChannels);
... ... @@ -248,7 +248,7 @@ public interface DeviceChannelMapper {
248 248 "device_channel dc1 " +
249 249 "WHERE " +
250 250 "dc1.deviceId = #{deviceId} " +
251   - " <if test='query != null'> AND (dc1.channelId LIKE '%${query}%' OR dc1.name LIKE '%${query}%' OR dc1.name LIKE '%${query}%')</if> " +
  251 + " <if test='query != null'> AND (dc1.channelId LIKE concat('%',#{query},'%') OR dc1.name LIKE concat('%',#{query},'%') OR dc1.name LIKE concat('%',#{query},'%'))</if> " +
252 252 " <if test='parentChannelId != null'> AND dc1.parentId=#{parentChannelId} </if> " +
253 253 " <if test='online == true' > AND dc1.status=1</if>" +
254 254 " <if test='online == false' > AND dc1.status=0</if>" +
... ... @@ -286,13 +286,13 @@ public interface DeviceChannelMapper {
286 286 @Update(value = {" <script>" +
287 287 "UPDATE device_channel " +
288 288 "SET " +
289   - "latitude=${latitude}, " +
290   - "longitude=${longitude}, " +
291   - "longitudeGcj02=${longitudeGcj02}, " +
292   - "latitudeGcj02=${latitudeGcj02}, " +
293   - "longitudeWgs84=${longitudeWgs84}, " +
294   - "latitudeWgs84=${latitudeWgs84}, " +
295   - "gpsTime='${gpsTime}' " +
  289 + "latitude=#{latitude}, " +
  290 + "longitude=#{longitude}, " +
  291 + "longitudeGcj02=#{longitudeGcj02}, " +
  292 + "latitudeGcj02=#{latitudeGcj02}, " +
  293 + "longitudeWgs84=#{longitudeWgs84}, " +
  294 + "latitudeWgs84=#{latitudeWgs84}, " +
  295 + "gpsTime=#{gpsTime} " +
296 296 "WHERE deviceId=#{deviceId} " +
297 297 " <if test='channelId != null' > AND channelId=#{channelId}</if>" +
298 298 " </script>"})
... ... @@ -309,10 +309,10 @@ public interface DeviceChannelMapper {
309 309 "select * " +
310 310 "from device_channel " +
311 311 "where deviceId=#{deviceId}" +
312   - " <if test='parentId != null and length != null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} and length(channelId)=${length} </if>" +
313   - " <if test='parentId == null and length != null' > and parentId = #{parentId} or length(channelId)=${length} </if>" +
  312 + " <if test='parentId != null and length != null' > and parentId = #{parentId} or left(channelId, #{parentId.length()}) = #{parentId} and length(channelId)=#{length} </if>" +
  313 + " <if test='parentId == null and length != null' > and parentId = #{parentId} or length(channelId)=#{length} </if>" +
314 314 " <if test='parentId == null and length == null' > and parentId = #{parentId} </if>" +
315   - " <if test='parentId != null and length == null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} </if>" +
  315 + " <if test='parentId != null and length == null' > and parentId = #{parentId} or left(channelId, #{parentId.length()}) = #{parentId} </if>" +
316 316 " </script>"})
317 317 List<DeviceChannel> getChannelsWithCivilCodeAndLength(String deviceId, String parentId, Integer length);
318 318  
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
... ... @@ -104,21 +104,21 @@ public interface DeviceMapper {
104 104  
105 105 @Update(value = {" <script>" +
106 106 "UPDATE device " +
107   - "SET updateTime='${updateTime}'" +
108   - "<if test=\"name != null\">, name='${name}'</if>" +
109   - "<if test=\"manufacturer != null\">, manufacturer='${manufacturer}'</if>" +
110   - "<if test=\"model != null\">, model='${model}'</if>" +
111   - "<if test=\"firmware != null\">, firmware='${firmware}'</if>" +
112   - "<if test=\"transport != null\">, transport='${transport}'</if>" +
113   - "<if test=\"ip != null\">, ip='${ip}'</if>" +
114   - "<if test=\"localIp != null\">, localIp='${localIp}'</if>" +
115   - "<if test=\"port != null\">, port=${port}</if>" +
116   - "<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" +
117   - "<if test=\"online != null\">, online=${online}</if>" +
118   - "<if test=\"registerTime != null\">, registerTime='${registerTime}'</if>" +
119   - "<if test=\"keepaliveTime != null\">, keepaliveTime='${keepaliveTime}'</if>" +
120   - "<if test=\"expires != null\">, expires=${expires}</if>" +
121   - "WHERE deviceId='${deviceId}'"+
  107 + "SET updateTime=#{updateTime}" +
  108 + "<if test=\"name != null\">, name=#{name}</if>" +
  109 + "<if test=\"manufacturer != null\">, manufacturer=#{manufacturer}</if>" +
  110 + "<if test=\"model != null\">, model=#{model}</if>" +
  111 + "<if test=\"firmware != null\">, firmware=#{firmware}</if>" +
  112 + "<if test=\"transport != null\">, transport=#{transport}</if>" +
  113 + "<if test=\"ip != null\">, ip=#{ip}</if>" +
  114 + "<if test=\"localIp != null\">, localIp=#{localIp}</if>" +
  115 + "<if test=\"port != null\">, port=#{port}</if>" +
  116 + "<if test=\"hostAddress != null\">, hostAddress=#{hostAddress}</if>" +
  117 + "<if test=\"online != null\">, online=#{online}</if>" +
  118 + "<if test=\"registerTime != null\">, registerTime=#{registerTime}</if>" +
  119 + "<if test=\"keepaliveTime != null\">, keepaliveTime=#{keepaliveTime}</if>" +
  120 + "<if test=\"expires != null\">, expires=#{expires}</if>" +
  121 + "WHERE deviceId=#{deviceId}"+
122 122 " </script>"})
123 123 int update(Device device);
124 124  
... ... @@ -217,28 +217,28 @@ public interface DeviceMapper {
217 217 "geoCoordSys," +
218 218 "treeType," +
219 219 "online" +
220   - " FROM device WHERE ip = #{host} AND port=${port}")
  220 + " FROM device WHERE ip = #{host} AND port=#{port}")
221 221 Device getDeviceByHostAndPort(String host, int port);
222 222  
223 223 @Update(value = {" <script>" +
224 224 "UPDATE device " +
225   - "SET updateTime='${updateTime}'" +
226   - "<if test=\"name != null\">, custom_name='${name}'</if>" +
227   - "<if test=\"password != null\">, password='${password}'</if>" +
228   - "<if test=\"streamMode != null\">, streamMode='${streamMode}'</if>" +
229   - "<if test=\"ip != null\">, ip='${ip}'</if>" +
230   - "<if test=\"sdpIp != null\">, sdpIp='${sdpIp}'</if>" +
231   - "<if test=\"port != null\">, port=${port}</if>" +
232   - "<if test=\"charset != null\">, charset='${charset}'</if>" +
233   - "<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=${subscribeCycleForCatalog}</if>" +
234   - "<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}</if>" +
235   - "<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=${mobilePositionSubmissionInterval}</if>" +
236   - "<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=${subscribeCycleForAlarm}</if>" +
237   - "<if test=\"ssrcCheck != null\">, ssrcCheck=${ssrcCheck}</if>" +
  225 + "SET updateTime=#{updateTime}" +
  226 + "<if test=\"name != null\">, custom_name=#{name}</if>" +
  227 + "<if test=\"password != null\">, password=#{password}</if>" +
  228 + "<if test=\"streamMode != null\">, streamMode=#{streamMode}</if>" +
  229 + "<if test=\"ip != null\">, ip=#{ip}</if>" +
  230 + "<if test=\"sdpIp != null\">, sdpIp=#{sdpIp}</if>" +
  231 + "<if test=\"port != null\">, port=#{port}</if>" +
  232 + "<if test=\"charset != null\">, charset=#{charset}</if>" +
  233 + "<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=#{subscribeCycleForCatalog}</if>" +
  234 + "<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=#{subscribeCycleForMobilePosition}</if>" +
  235 + "<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=#{mobilePositionSubmissionInterval}</if>" +
  236 + "<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=#{subscribeCycleForAlarm}</if>" +
  237 + "<if test=\"ssrcCheck != null\">, ssrcCheck=#{ssrcCheck}</if>" +
238 238 "<if test=\"geoCoordSys != null\">, geoCoordSys=#{geoCoordSys}</if>" +
239 239 "<if test=\"treeType != null\">, treeType=#{treeType}</if>" +
240 240 "<if test=\"mediaServerId != null\">, mediaServerId=#{mediaServerId}</if>" +
241   - "WHERE deviceId='${deviceId}'"+
  241 + "WHERE deviceId=#{deviceId}"+
242 242 " </script>"})
243 243 int updateCustom(Device device);
244 244  
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMobilePositionMapper.java
... ... @@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.*;
9 9 public interface DeviceMobilePositionMapper {
10 10  
11 11 @Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, longitudeGcj02, latitudeGcj02, longitudeWgs84, latitudeWgs84, createTime) " +
12   - "VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}', ${longitudeGcj02}, ${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84}, '${createTime}')")
  12 + "VALUES (#{deviceId},#{channelId}, #{deviceName}, #{time}, #{longitude}, #{latitude}, #{altitude}, #{speed}, #{direction}, #{reportSource}, #{longitudeGcj02}, #{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{createTime})")
13 13 int insertNewPosition(MobilePosition mobilePosition);
14 14  
15 15 @Select(value = {" <script>" +
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
... ... @@ -16,9 +16,9 @@ public interface GbStreamMapper {
16 16  
17 17 @Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " +
18 18 "longitude, latitude, streamType, mediaServerId, createTime) VALUES" +
19   - "('${app}', '${stream}', '${gbId}', '${name}', " +
20   - "'${longitude}', '${latitude}', '${streamType}', " +
21   - "'${mediaServerId}', '${createTime}')")
  19 + "(#{app}, #{stream}, #{gbId}, #{name}, " +
  20 + "#{longitude}, #{latitude}, #{streamType}, " +
  21 + "#{mediaServerId}, #{createTime})")
22 22 @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
23 23 int add(GbStream gbStream);
24 24  
... ... @@ -57,7 +57,7 @@ public interface GbStreamMapper {
57 57 "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId} and pgs.catalogId=#{catalogId})</if> " +
58 58 " <if test='catalogId == null'> AND gs.gbStreamId not in" +
59 59 "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) </if> " +
60   - " <if test='query != null'> AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
  60 + " <if test='query != null'> AND (gs.app LIKE concat('%',#{query},'%') OR gs.stream LIKE concat('%',#{query},'%') OR gs.gbId LIKE concat('%',#{query},'%') OR gs.name LIKE concat('%',#{query},'%'))</if> " +
61 61 " <if test='mediaServerId != null' > AND gs.mediaServerId=#{mediaServerId} </if>" +
62 62 " order by gs.gbStreamId asc " +
63 63 "</script>")
... ... @@ -71,7 +71,7 @@ public interface GbStreamMapper {
71 71  
72 72 @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " +
73 73 "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " +
74   - "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'")
  74 + "WHERE gs.gbId = #{gbId} AND pgs.platformId = #{platformId}")
75 75 GbStream queryStreamInPlatform(String platformId, String gbId);
76 76  
77 77 @Select("<script> "+
... ... @@ -122,9 +122,9 @@ public interface GbStreamMapper {
122 122 "longitude, latitude, streamType, mediaServerId, createTime)" +
123 123 "values " +
124 124 "<foreach collection='subList' index='index' item='item' separator=','> " +
125   - "('${item.app}', '${item.stream}', '${item.gbId}', '${item.name}', " +
126   - "'${item.longitude}', '${item.latitude}', '${item.streamType}', " +
127   - "'${item.mediaServerId}', '${item.createTime}') "+
  125 + "(#{item.app}, #{item.stream}, #{item.gbId}, #{item.name}, " +
  126 + "#{item.longitude}, #{item.latitude}, #{item.streamType}, " +
  127 + "#{item.mediaServerId}, #{item.createTime}) "+
128 128 "</foreach> " +
129 129 "</script>")
130 130 @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
... ... @@ -134,7 +134,7 @@ public interface GbStreamMapper {
134 134 "<foreach collection='gpsMsgInfos' item='item' separator=';'>" +
135 135 " UPDATE" +
136 136 " gb_stream" +
137   - " SET longitude=${item.lng}, latitude=${item.lat} " +
  137 + " SET longitude=#{item.lng}, latitude=#{item.lat} " +
138 138 "WHERE gbId=#{item.id}"+
139 139 "</foreach>" +
140 140 "</script>"})
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/LogMapper.java
... ... @@ -18,16 +18,16 @@ import java.util.List;
18 18 public interface LogMapper {
19 19  
20 20 @Insert("insert into log ( name, type, uri, address, result, timing, username, createTime) " +
21   - "values ('${name}', '${type}', '${uri}', '${address}', '${result}', ${timing}, '${username}', '${createTime}')")
  21 + "values (#{name}, #{type}, #{uri}, #{address}, #{result}, #{timing}, #{username}, #{createTime})")
22 22 int add(LogDto logDto);
23 23  
24 24 @Select(value = {"<script>" +
25 25 " SELECT * FROM log " +
26 26 " WHERE 1=1 " +
27   - " <if test=\"query != null\"> AND (name LIKE '%${query}%')</if> " +
28   - " <if test=\"type != null\" > AND type = '${type}'</if>" +
29   - " <if test=\"startTime != null\" > AND createTime &gt;= '${startTime}' </if>" +
30   - " <if test=\"endTime != null\" > AND createTime &lt;= '${endTime}' </if>" +
  27 + " <if test=\"query != null\"> AND (name LIKE concat('%',#{query},'%'))</if> " +
  28 + " <if test=\"type != null\" > AND type = #{type}</if>" +
  29 + " <if test=\"startTime != null\" > AND createTime &gt;= #{startTime} </if>" +
  30 + " <if test=\"endTime != null\" > AND createTime &lt;= #{endTime} </if>" +
31 31 " ORDER BY createTime DESC " +
32 32 " </script>"})
33 33 List<LogDto> query(String query, String type, String startTime, String endTime);
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java
... ... @@ -35,92 +35,92 @@ public interface MediaServerMapper {
35 35 "hookAliveInterval" +
36 36 ") VALUES " +
37 37 "(" +
38   - "'${id}', " +
39   - "'${ip}', " +
40   - "'${hookIp}', " +
41   - "'${sdpIp}', " +
42   - "'${streamIp}', " +
43   - "${httpPort}, " +
44   - "${httpSSlPort}, " +
45   - "${rtmpPort}, " +
46   - "${rtmpSSlPort}, " +
47   - "${rtpProxyPort}, " +
48   - "${rtspPort}, " +
49   - "${rtspSSLPort}, " +
50   - "${autoConfig}, " +
51   - "'${secret}', " +
52   - "${rtpEnable}, " +
53   - "'${rtpPortRange}', " +
54   - "${recordAssistPort}, " +
55   - "${defaultServer}, " +
56   - "'${createTime}', " +
57   - "'${updateTime}', " +
58   - "${hookAliveInterval})")
  38 + "#{id}, " +
  39 + "#{ip}, " +
  40 + "#{hookIp}, " +
  41 + "#{sdpIp}, " +
  42 + "#{streamIp}, " +
  43 + "#{httpPort}, " +
  44 + "#{httpSSlPort}, " +
  45 + "#{rtmpPort}, " +
  46 + "#{rtmpSSlPort}, " +
  47 + "#{rtpProxyPort}, " +
  48 + "#{rtspPort}, " +
  49 + "#{rtspSSLPort}, " +
  50 + "#{autoConfig}, " +
  51 + "#{secret}, " +
  52 + "#{rtpEnable}, " +
  53 + "#{rtpPortRange}, " +
  54 + "#{recordAssistPort}, " +
  55 + "#{defaultServer}, " +
  56 + "#{createTime}, " +
  57 + "#{updateTime}, " +
  58 + "#{hookAliveInterval})")
59 59 int add(MediaServerItem mediaServerItem);
60 60  
61 61 @Update(value = {" <script>" +
62 62 "UPDATE media_server " +
63   - "SET updateTime='${updateTime}'" +
64   - "<if test=\"ip != null\">, ip='${ip}'</if>" +
65   - "<if test=\"hookIp != null\">, hookIp='${hookIp}'</if>" +
66   - "<if test=\"sdpIp != null\">, sdpIp='${sdpIp}'</if>" +
67   - "<if test=\"streamIp != null\">, streamIp='${streamIp}'</if>" +
68   - "<if test=\"httpPort != null\">, httpPort=${httpPort}</if>" +
69   - "<if test=\"httpSSlPort != null\">, httpSSlPort=${httpSSlPort}</if>" +
70   - "<if test=\"rtmpPort != null\">, rtmpPort=${rtmpPort}</if>" +
71   - "<if test=\"rtmpSSlPort != null\">, rtmpSSlPort=${rtmpSSlPort}</if>" +
72   - "<if test=\"rtpProxyPort != null\">, rtpProxyPort=${rtpProxyPort}</if>" +
73   - "<if test=\"rtspPort != null\">, rtspPort=${rtspPort}</if>" +
74   - "<if test=\"rtspSSLPort != null\">, rtspSSLPort=${rtspSSLPort}</if>" +
75   - "<if test=\"autoConfig != null\">, autoConfig=${autoConfig}</if>" +
76   - "<if test=\"rtpEnable != null\">, rtpEnable=${rtpEnable}</if>" +
77   - "<if test=\"rtpPortRange != null\">, rtpPortRange='${rtpPortRange}'</if>" +
78   - "<if test=\"secret != null\">, secret='${secret}'</if>" +
79   - "<if test=\"recordAssistPort != null\">, recordAssistPort=${recordAssistPort}</if>" +
80   - "<if test=\"hookAliveInterval != null\">, hookAliveInterval=${hookAliveInterval}</if>" +
81   - "WHERE id='${id}'"+
  63 + "SET updateTime=#{updateTime}" +
  64 + "<if test=\"ip != null\">, ip=#{ip}</if>" +
  65 + "<if test=\"hookIp != null\">, hookIp=#{hookIp}</if>" +
  66 + "<if test=\"sdpIp != null\">, sdpIp=#{sdpIp}</if>" +
  67 + "<if test=\"streamIp != null\">, streamIp=#{streamIp}</if>" +
  68 + "<if test=\"httpPort != null\">, httpPort=#{httpPort}</if>" +
  69 + "<if test=\"httpSSlPort != null\">, httpSSlPort=#{httpSSlPort}</if>" +
  70 + "<if test=\"rtmpPort != null\">, rtmpPort=#{rtmpPort}</if>" +
  71 + "<if test=\"rtmpSSlPort != null\">, rtmpSSlPort=#{rtmpSSlPort}</if>" +
  72 + "<if test=\"rtpProxyPort != null\">, rtpProxyPort=#{rtpProxyPort}</if>" +
  73 + "<if test=\"rtspPort != null\">, rtspPort=#{rtspPort}</if>" +
  74 + "<if test=\"rtspSSLPort != null\">, rtspSSLPort=#{rtspSSLPort}</if>" +
  75 + "<if test=\"autoConfig != null\">, autoConfig=#{autoConfig}</if>" +
  76 + "<if test=\"rtpEnable != null\">, rtpEnable=#{rtpEnable}</if>" +
  77 + "<if test=\"rtpPortRange != null\">, rtpPortRange=#{rtpPortRange}</if>" +
  78 + "<if test=\"secret != null\">, secret=#{secret}</if>" +
  79 + "<if test=\"recordAssistPort != null\">, recordAssistPort=#{recordAssistPort}</if>" +
  80 + "<if test=\"hookAliveInterval != null\">, hookAliveInterval=#{hookAliveInterval}</if>" +
  81 + "WHERE id=#{id}"+
82 82 " </script>"})
83 83 int update(MediaServerItem mediaServerItem);
84 84  
85 85 @Update(value = {" <script>" +
86 86 "UPDATE media_server " +
87   - "SET updateTime='${updateTime}'" +
88   - "<if test=\"id != null\">, id='${id}'</if>" +
89   - "<if test=\"hookIp != null\">, hookIp='${hookIp}'</if>" +
90   - "<if test=\"sdpIp != null\">, sdpIp='${sdpIp}'</if>" +
91   - "<if test=\"streamIp != null\">, streamIp='${streamIp}'</if>" +
92   - "<if test=\"httpSSlPort != null\">, httpSSlPort=${httpSSlPort}</if>" +
93   - "<if test=\"rtmpPort != null\">, rtmpPort=${rtmpPort}</if>" +
94   - "<if test=\"rtmpSSlPort != null\">, rtmpSSlPort=${rtmpSSlPort}</if>" +
95   - "<if test=\"rtpProxyPort != null\">, rtpProxyPort=${rtpProxyPort}</if>" +
96   - "<if test=\"rtspPort != null\">, rtspPort=${rtspPort}</if>" +
97   - "<if test=\"rtspSSLPort != null\">, rtspSSLPort=${rtspSSLPort}</if>" +
98   - "<if test=\"autoConfig != null\">, autoConfig=${autoConfig}</if>" +
99   - "<if test=\"rtpEnable != null\">, rtpEnable=${rtpEnable}</if>" +
100   - "<if test=\"rtpPortRange != null\">, rtpPortRange='${rtpPortRange}'</if>" +
101   - "<if test=\"secret != null\">, secret='${secret}'</if>" +
102   - "<if test=\"recordAssistPort != null\">, recordAssistPort=${recordAssistPort}</if>" +
103   - "<if test=\"hookAliveInterval != null\">, hookAliveInterval=${hookAliveInterval}</if>" +
104   - "WHERE ip='${ip}' and httpPort=${httpPort}"+
  87 + "SET updateTime=#{updateTime}" +
  88 + "<if test=\"id != null\">, id=#{id}</if>" +
  89 + "<if test=\"hookIp != null\">, hookIp=#{hookIp}</if>" +
  90 + "<if test=\"sdpIp != null\">, sdpIp=#{sdpIp}</if>" +
  91 + "<if test=\"streamIp != null\">, streamIp=#{streamIp}</if>" +
  92 + "<if test=\"httpSSlPort != null\">, httpSSlPort=#{httpSSlPort}</if>" +
  93 + "<if test=\"rtmpPort != null\">, rtmpPort=#{rtmpPort}</if>" +
  94 + "<if test=\"rtmpSSlPort != null\">, rtmpSSlPort=#{rtmpSSlPort}</if>" +
  95 + "<if test=\"rtpProxyPort != null\">, rtpProxyPort=#{rtpProxyPort}</if>" +
  96 + "<if test=\"rtspPort != null\">, rtspPort=#{rtspPort}</if>" +
  97 + "<if test=\"rtspSSLPort != null\">, rtspSSLPort=#{rtspSSLPort}</if>" +
  98 + "<if test=\"autoConfig != null\">, autoConfig=#{autoConfig}</if>" +
  99 + "<if test=\"rtpEnable != null\">, rtpEnable=#{rtpEnable}</if>" +
  100 + "<if test=\"rtpPortRange != null\">, rtpPortRange=#{rtpPortRange}</if>" +
  101 + "<if test=\"secret != null\">, secret=#{secret}</if>" +
  102 + "<if test=\"recordAssistPort != null\">, recordAssistPort=#{recordAssistPort}</if>" +
  103 + "<if test=\"hookAliveInterval != null\">, hookAliveInterval=#{hookAliveInterval}</if>" +
  104 + "WHERE ip=#{ip} and httpPort=#{httpPort}"+
105 105 " </script>"})
106 106 int updateByHostAndPort(MediaServerItem mediaServerItem);
107 107  
108   - @Select("SELECT * FROM media_server WHERE id='${id}'")
  108 + @Select("SELECT * FROM media_server WHERE id=#{id}")
109 109 MediaServerItem queryOne(String id);
110 110  
111 111 @Select("SELECT * FROM media_server")
112 112 List<MediaServerItem> queryAll();
113 113  
114   - @Delete("DELETE FROM media_server WHERE id='${id}'")
  114 + @Delete("DELETE FROM media_server WHERE id=#{id}")
115 115 void delOne(String id);
116 116  
117   - @Select("DELETE FROM media_server WHERE ip='${host}' and httpPort=${port}")
  117 + @Select("DELETE FROM media_server WHERE ip=#{host} and httpPort=#{port}")
118 118 void delOneByIPAndPort(String host, int port);
119 119  
120 120 @Delete("DELETE FROM media_server WHERE defaultServer=1")
121 121 int delDefault();
122 122  
123   - @Select("SELECT * FROM media_server WHERE ip='${host}' and httpPort=${port}")
  123 + @Select("SELECT * FROM media_server WHERE ip=#{host} and httpPort=#{port}")
124 124 MediaServerItem queryOneByHostAndPort(String host, int port);
125 125  
126 126 @Select("SELECT * FROM media_server WHERE defaultServer=1")
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java
... ... @@ -17,9 +17,9 @@ public interface ParentPlatformMapper {
17 17 @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
18 18 " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
19 19 " status, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " +
20   - " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
21   - " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
22   - " ${status}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})")
  20 + " VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIP}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " +
  21 + " #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, " +
  22 + " #{status}, #{startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})")
23 23 int addParentPlatform(ParentPlatform parentPlatform);
24 24  
25 25 @Update("UPDATE parent_platform " +
... ... @@ -41,7 +41,7 @@ public interface ParentPlatformMapper {
41 41 "ptz=#{ptz}, " +
42 42 "rtcp=#{rtcp}, " +
43 43 "status=#{status}, " +
44   - "startOfflinePush=${startOfflinePush}, " +
  44 + "startOfflinePush=#{startOfflinePush}, " +
45 45 "catalogGroup=#{catalogGroup}, " +
46 46 "administrativeDivision=#{administrativeDivision}, " +
47 47 "createTime=#{createTime}, " +
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
... ... @@ -21,22 +21,22 @@ public interface PlatformChannelMapper {
21 21 * 查询列表里已经关联的
22 22 */
23 23 @Select("<script> "+
24   - "SELECT deviceChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" +
25   - "<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> '${item.id}'</foreach>" +
  24 + "SELECT deviceChannelId FROM platform_gb_channel WHERE platformId=#{platformId} AND deviceChannelId in" +
  25 + "<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> #{item.id}</foreach>" +
26 26 "</script>")
27 27 List<Integer> findChannelRelatedPlatform(String platformId, List<ChannelReduce> channelReduces);
28 28  
29 29 @Insert("<script> "+
30 30 "INSERT INTO platform_gb_channel (platformId, deviceChannelId, catalogId) VALUES" +
31 31 "<foreach collection='channelReducesToAdd' item='item' separator=','>" +
32   - " ('${platformId}', '${item.id}' , '${item.catalogId}' )" +
  32 + " (#{platformId}, #{item.id} , #{item.catalogId} )" +
33 33 "</foreach>" +
34 34 "</script>")
35 35 int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd);
36 36  
37 37 @Delete("<script> "+
38   - "DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" +
39   - "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.id}'</foreach>" +
  38 + "DELETE FROM platform_gb_channel WHERE platformId=#{platformId} AND deviceChannelId in" +
  39 + "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
40 40 "</script>")
41 41 int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel);
42 42  
... ... @@ -50,14 +50,14 @@ public interface PlatformChannelMapper {
50 50 int delChannelForDeviceId(String deviceId);
51 51  
52 52 @Delete("<script> "+
53   - "DELETE FROM platform_gb_channel WHERE platformId='${platformId}'" +
  53 + "DELETE FROM platform_gb_channel WHERE platformId=#{platformId}" +
54 54 "</script>")
55 55 int cleanChannelForGB(String platformId);
56 56  
57   - @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE dc.channelId='${channelId}' and pgc.platformId='${platformId}'")
  57 + @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE dc.channelId=#{channelId} and pgc.platformId=#{platformId}")
58 58 List<DeviceChannel> queryChannelInParentPlatform(String platformId, String channelId);
59 59  
60   - @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE pgc.platformId='${platformId}' and pgc.catalogId=#{catalogId}")
  60 + @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}")
61 61 List<DeviceChannel> queryAllChannelInCatalog(String platformId, String catalogId);
62 62  
63 63 @Select(" select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " +
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
... ... @@ -26,7 +26,7 @@ public interface PlatformGbStreamMapper {
26 26 "(gbStreamId, platformId, catalogId) " +
27 27 "values " +
28 28 "<foreach collection='streamPushItems' index='index' item='item' separator=','> " +
29   - "(${item.gbStreamId}, '${item.platformId}', '${item.catalogId}')" +
  29 + "(#{item.gbStreamId}, #{item.platformId}, #{item.catalogId})" +
30 30 "</foreach> " +
31 31 "</script>")
32 32 int batchAdd(List<StreamPushItem> streamPushItems);
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/RecordInfoDao.java
... ... @@ -14,10 +14,10 @@ import java.util.List;
14 14 public interface RecordInfoDao {
15 15  
16 16 @Insert("INSERT INTO recordInfo (app, stream, mediaServerId, createTime, type, deviceId, channelId, name) VALUES" +
17   - "('${app}', '${stream}', '${mediaServerId}', datetime('now','localtime')), '${type}', '${deviceId}', '${channelId}', '${name}'")
  17 + "(#{app}, #{stream}, #{mediaServerId}, datetime('now','localtime')), #{type}, #{deviceId}, #{channelId}, #{name}")
18 18 int add(RecordInfo recordInfo);
19 19  
20   - @Delete("DELETE FROM user WHERE createTime < '${beforeTime}'")
  20 + @Delete("DELETE FROM user WHERE createTime < #{beforeTime}")
21 21 int deleteBefore(String beforeTime);
22 22  
23 23 @Select("select * FROM recordInfo")
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/RoleMapper.java
... ... @@ -12,14 +12,14 @@ import java.util.List;
12 12 public interface RoleMapper {
13 13  
14 14 @Insert("INSERT INTO user_role (name, authority, createTime, updateTime) VALUES" +
15   - "('${name}', '${authority}', '${createTime}', '${updateTime}')")
  15 + "(#{name}, #{authority}, #{createTime}, #{updateTime})")
16 16 int add(Role role);
17 17  
18 18 @Update(value = {" <script>" +
19 19 "UPDATE user_role " +
20   - "SET updateTime='${updateTime}' " +
21   - "<if test=\"name != null\">, name='${name}'</if>" +
22   - "<if test=\"authority != null\">, authority='${authority}'</if>" +
  20 + "SET updateTime=#{updateTime} " +
  21 + "<if test=\"name != null\">, name=#{name}</if>" +
  22 + "<if test=\"authority != null\">, authority=#{authority}</if>" +
23 23 "WHERE id != 1 and id=#{id}" +
24 24 " </script>"})
25 25 int update(Role role);
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java
... ... @@ -13,9 +13,9 @@ public interface StreamProxyMapper {
13 13  
14 14 @Insert("INSERT INTO stream_proxy (type, name, app, stream,mediaServerId, url, src_url, dst_url, " +
15 15 "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_audio, enable_mp4, enable, status, enable_remove_none_reader, enable_disable_none_reader, createTime) VALUES" +
16   - "('${type}','${name}', '${app}', '${stream}', '${mediaServerId}','${url}', '${src_url}', '${dst_url}', " +
17   - "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_audio}, ${enable_mp4}, ${enable}, ${status}, " +
18   - "${enable_remove_none_reader}, ${enable_disable_none_reader}, '${createTime}' )")
  16 + "(#{type}, #{name}, #{app}, #{stream}, #{mediaServerId}, #{url}, #{src_url}, #{dst_url}, " +
  17 + "#{timeout_ms}, #{ffmpeg_cmd_key}, #{rtp_type}, #{enable_audio}, #{enable_mp4}, #{enable}, #{status}, " +
  18 + "#{enable_remove_none_reader}, #{enable_disable_none_reader}, #{createTime} )")
19 19 int add(StreamProxyItem streamProxyDto);
20 20  
21 21 @Update("UPDATE stream_proxy " +
... ... @@ -45,7 +45,7 @@ public interface StreamProxyMapper {
45 45 @Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream order by st.createTime desc")
46 46 List<StreamProxyItem> selectAll();
47 47  
48   - @Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=${enable} order by st.createTime desc")
  48 + @Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=#{enable} order by st.createTime desc")
49 49 List<StreamProxyItem> selectForEnable(boolean enable);
50 50  
51 51 @Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.app=#{app} AND st.stream=#{stream} order by st.createTime desc")
... ... @@ -53,12 +53,12 @@ public interface StreamProxyMapper {
53 53  
54 54 @Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st " +
55 55 "LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream " +
56   - "WHERE st.enable=${enable} and st.mediaServerId = #{id} order by st.createTime desc")
  56 + "WHERE st.enable=#{enable} and st.mediaServerId = #{id} order by st.createTime desc")
57 57 List<StreamProxyItem> selectForEnableInMediaServer(String id, boolean enable);
58 58  
59 59 @Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st " +
60 60 "LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream " +
61   - "WHERE st.mediaServerId = '${id}' order by st.createTime desc")
  61 + "WHERE st.mediaServerId = #{id} order by st.createTime desc")
62 62 List<StreamProxyItem> selectInMediaServer(String id);
63 63  
64 64 @Update("UPDATE stream_proxy " +
... ... @@ -67,7 +67,7 @@ public interface StreamProxyMapper {
67 67 void updateStatusByMediaServerId(String mediaServerId, boolean status);
68 68  
69 69 @Update("UPDATE stream_proxy " +
70   - "SET status=${status} " +
  70 + "SET status=#{status} " +
71 71 "WHERE app=#{app} AND stream=#{stream}")
72 72 int updateStatus(String app, String stream, boolean status);
73 73  
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
... ... @@ -17,23 +17,23 @@ public interface StreamPushMapper {
17 17  
18 18 @Insert("INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
19 19 "pushTime, aliveSecond, mediaServerId, serverId, updateTime, createTime, pushIng, self) VALUES" +
20   - "('${app}', '${stream}', '${totalReaderCount}', '${originType}', '${originTypeStr}', " +
21   - "'${pushTime}', '${aliveSecond}', '${mediaServerId}' , '${serverId}' , '${updateTime}' , '${createTime}', " +
22   - "${pushIng}, ${self} )")
  20 + "(#{app}, #{stream}, #{totalReaderCount}, #{originType}, #{originTypeStr}, " +
  21 + "#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{serverId} , #{updateTime} , #{createTime}, " +
  22 + "#{pushIng}, #{self} )")
23 23 int add(StreamPushItem streamPushItem);
24 24  
25 25  
26 26 @Update(value = {" <script>" +
27 27 "UPDATE stream_push " +
28   - "SET updateTime='${updateTime}'" +
29   - "<if test=\"mediaServerId != null\">, mediaServerId='${mediaServerId}'</if>" +
30   - "<if test=\"totalReaderCount != null\">, totalReaderCount='${totalReaderCount}'</if>" +
31   - "<if test=\"originType != null\">, originType=${originType}</if>" +
32   - "<if test=\"originTypeStr != null\">, originTypeStr='${originTypeStr}'</if>" +
33   - "<if test=\"pushTime != null\">, pushTime='${pushTime}'</if>" +
34   - "<if test=\"aliveSecond != null\">, aliveSecond='${aliveSecond}'</if>" +
35   - "<if test=\"pushIng != null\">, pushIng=${pushIng}</if>" +
36   - "<if test=\"self != null\">, self=${self}</if>" +
  28 + "SET updateTime=#{updateTime}" +
  29 + "<if test=\"mediaServerId != null\">, mediaServerId=#{mediaServerId}</if>" +
  30 + "<if test=\"totalReaderCount != null\">, totalReaderCount=#{totalReaderCount}</if>" +
  31 + "<if test=\"originType != null\">, originType=#{originType}</if>" +
  32 + "<if test=\"originTypeStr != null\">, originTypeStr=#{originTypeStr}</if>" +
  33 + "<if test=\"pushTime != null\">, pushTime=#{pushTime}</if>" +
  34 + "<if test=\"aliveSecond != null\">, aliveSecond=#{aliveSecond}</if>" +
  35 + "<if test=\"pushIng != null\">, pushIng=#{pushIng}</if>" +
  36 + "<if test=\"self != null\">, self=#{self}</if>" +
37 37 "WHERE app=#{app} AND stream=#{stream}"+
38 38 " </script>"})
39 39 int update(StreamPushItem streamPushItem);
... ... @@ -76,7 +76,7 @@ public interface StreamPushMapper {
76 76 "on st.app = gs.app AND st.stream = gs.stream " +
77 77 "WHERE " +
78 78 "1=1 " +
79   - " <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
  79 + " <if test='query != null'> AND (st.app LIKE concat('%',#{query},'%') OR st.stream LIKE concat('%',#{query},'%') OR gs.gbId LIKE concat('%',#{query},'%') OR gs.name LIKE concat('%',#{query},'%'))</if> " +
80 80 " <if test='pushing == true' > AND (gs.gbId is null OR st.pushIng=1)</if>" +
81 81 " <if test='pushing == false' > AND (st.pushIng is null OR st.pushIng=0) </if>" +
82 82 " <if test='mediaServerId != null' > AND st.mediaServerId=#{mediaServerId} </if>" +
... ... @@ -94,9 +94,9 @@ public interface StreamPushMapper {
94 94 "Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
95 95 "createTime, aliveSecond, mediaServerId, status, pushIng) " +
96 96 "VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
97   - "( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " +
98   - "'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}', ${item.status} ," +
99   - " ${item.pushIng} )" +
  97 + "( #{item.app}, #{item.stream}, #{item.totalReaderCount}, #{item.originType}, " +
  98 + "#{item.originTypeStr},#{item.createTime}, #{item.aliveSecond}, #{item.mediaServerId}, #{item.status} ," +
  99 + " #{item.pushIng} )" +
100 100 " </foreach>" +
101 101 "</script>")
102 102 @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
... ... @@ -115,12 +115,12 @@ public interface StreamPushMapper {
115 115 List<StreamPushItem> selectAllByMediaServerIdWithOutGbID(String mediaServerId);
116 116  
117 117 @Update("UPDATE stream_push " +
118   - "SET status=${status} " +
  118 + "SET status=#{status} " +
119 119 "WHERE app=#{app} AND stream=#{stream}")
120 120 int updateStatus(String app, String stream, boolean status);
121 121  
122 122 @Update("UPDATE stream_push " +
123   - "SET pushIng=${pushIng} " +
  123 + "SET pushIng=#{pushIng} " +
124 124 "WHERE app=#{app} AND stream=#{stream}")
125 125 int updatePushStatus(String app, String stream, boolean pushIng);
126 126  
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java
... ... @@ -11,16 +11,16 @@ import java.util.List;
11 11 public interface UserMapper {
12 12  
13 13 @Insert("INSERT INTO user (username, password, roleId, pushKey, createTime, updateTime) VALUES" +
14   - "('${username}', '${password}', '${role.id}', '${pushKey}', '${createTime}', '${updateTime}')")
  14 + "(#{username}, #{password}, #{role.id}, #{pushKey}, #{createTime}, #{updateTime})")
15 15 int add(User user);
16 16  
17 17 @Update(value = {" <script>" +
18 18 "UPDATE user " +
19   - "SET updateTime='${updateTime}' " +
20   - "<if test=\"pushKey != null\">, pushKey='${pushKey}'</if>" +
21   - "<if test=\"role != null\">, roleId='${role.id}'</if>" +
22   - "<if test=\"password != null\">, password='${password}'</if>" +
23   - "<if test=\"username != null\">, username='${username}'</if>" +
  19 + "SET updateTime=#{updateTime} " +
  20 + "<if test=\"pushKey != null\">, pushKey=#{pushKey}</if>" +
  21 + "<if test=\"role != null\">, roleId=#{role.id}</if>" +
  22 + "<if test=\"password != null\">, password=#{password}</if>" +
  23 + "<if test=\"username != null\">, username=#{username}</if>" +
24 24 "WHERE id=#{id}" +
25 25 " </script>"})
26 26 int update(User user);
... ... @@ -50,10 +50,10 @@ public interface UserMapper {
50 50 @ResultMap(value="roleMap")
51 51 List<User> selectAll();
52 52  
53   - @Select("select * from (select user.*, concat('${callId}_', pushKey) as str1 from user) as u where md5(u.str1) = '${sign}'")
  53 + @Select("select * from (select user.*, concat(#{callId}_', pushKey) as str1 from user) as u where md5(u.str1) = #{sign}")
54 54 List<User> checkPushAuthorityByCallIdAndSign(String callId, String sign);
55 55  
56   - @Select("select * from user where md5(pushKey) = '${sign}'")
  56 + @Select("select * from user where md5(pushKey) = #{sign}")
57 57 List<User> checkPushAuthorityByCallId(String sign);
58 58  
59 59 @Select("select u.id, u.username,u.pushKey,u.roleId, r.id as roleID, r.name as roleName, r.authority as roleAuthority , r.createTime as roleCreateTime , r.updateTime as roleUpdateTime FROM user u join user_role r on u.roleId=r.id")
... ...