Commit 79f3ca9791bffe1ee7850432b8b432e8c5d7bf7e
1 parent
cccfdace
优化收藏功能
Showing
8 changed files
with
20 additions
and
55 deletions
sql/初始化-mysql-2.6.9.sql
| ... | ... | @@ -280,7 +280,6 @@ create table wvp_cloud_record ( |
| 280 | 280 | folder character varying(255), |
| 281 | 281 | file_path character varying(255), |
| 282 | 282 | collect bool default false, |
| 283 | - reserve bool default false, | |
| 284 | 283 | file_size bigint, |
| 285 | 284 | time_len bigint, |
| 286 | 285 | constraint uk_stream_push_app_stream_path unique (app, stream, file_path) | ... | ... |
sql/初始化-postgresql-kingbase-2.6.9.sql
| ... | ... | @@ -280,7 +280,6 @@ create table wvp_cloud_record ( |
| 280 | 280 | folder character varying(255), |
| 281 | 281 | file_path character varying(255), |
| 282 | 282 | collect bool default false, |
| 283 | - reserve bool default false, | |
| 284 | 283 | file_size int8, |
| 285 | 284 | time_len int8, |
| 286 | 285 | constraint uk_stream_push_app_stream_path unique (app, stream, file_path) | ... | ... |
sql/更新-mysql-2.6.9.sql
| ... | ... | @@ -19,7 +19,6 @@ create table wvp_cloud_record ( |
| 19 | 19 | folder character varying(255), |
| 20 | 20 | file_path character varying(255), |
| 21 | 21 | collect bool default false, |
| 22 | - reserve bool default false, | |
| 23 | 22 | file_size bigint, |
| 24 | 23 | time_len bigint, |
| 25 | 24 | constraint uk_stream_push_app_stream_path unique (app, stream, file_path) | ... | ... |
sql/更新-postgresql-kingbase-2.6.9.sql
| ... | ... | @@ -19,7 +19,6 @@ create table wvp_cloud_record ( |
| 19 | 19 | folder character varying(255), |
| 20 | 20 | file_path character varying(255), |
| 21 | 21 | collect bool default false, |
| 22 | - reserve bool default false, | |
| 23 | 22 | file_size int8, |
| 24 | 23 | time_len int8, |
| 25 | 24 | constraint uk_stream_push_app_stream_path unique (app, stream, file_path) | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java
| ... | ... | @@ -43,11 +43,11 @@ public interface ICloudRecordService { |
| 43 | 43 | /** |
| 44 | 44 | * 收藏视频,收藏的视频过期不会删除 |
| 45 | 45 | */ |
| 46 | - void changeCollect(String type, boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId, String collectType); | |
| 46 | + int changeCollect(boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId); | |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * 添加指定录像收藏 |
| 50 | 50 | */ |
| 51 | - void changeCollectById(Integer recordId, String collectType, boolean result); | |
| 51 | + int changeCollectById(Integer recordId, boolean result); | |
| 52 | 52 | |
| 53 | 53 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java
| ... | ... | @@ -166,7 +166,7 @@ public class CloudRecordServiceImpl implements ICloudRecordService { |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | @Override |
| 169 | - public void changeCollect(String type, boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId, String collectType) { | |
| 169 | + public int changeCollect(boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId) { | |
| 170 | 170 | // 开始时间和结束时间在数据库中都是以秒为单位的 |
| 171 | 171 | Long startTimeStamp = null; |
| 172 | 172 | Long endTimeStamp = null; |
| ... | ... | @@ -203,34 +203,24 @@ public class CloudRecordServiceImpl implements ICloudRecordService { |
| 203 | 203 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到待收藏的视频"); |
| 204 | 204 | } |
| 205 | 205 | int limitCount = 50; |
| 206 | + int resultCount = 0; | |
| 206 | 207 | if (all.size() > limitCount) { |
| 207 | 208 | for (int i = 0; i < all.size(); i += limitCount) { |
| 208 | 209 | int toIndex = i + limitCount; |
| 209 | 210 | if (i + limitCount > all.size()) { |
| 210 | 211 | toIndex = all.size(); |
| 211 | 212 | } |
| 212 | - if ("collect".equals(collectType)) { | |
| 213 | - cloudRecordServiceMapper.updateCollectList(result, all.subList(i, toIndex)); | |
| 214 | - }else if ("reserve".equals(collectType)) { | |
| 215 | - cloudRecordServiceMapper.updateReserveList(result, all.subList(i, toIndex)); | |
| 216 | - } | |
| 213 | + resultCount += cloudRecordServiceMapper.updateCollectList(result, all.subList(i, toIndex)); | |
| 217 | 214 | |
| 218 | 215 | } |
| 219 | 216 | }else { |
| 220 | - if ("collect".equals(collectType)) { | |
| 221 | - cloudRecordServiceMapper.updateCollectList(result, all); | |
| 222 | - }else if ("reserve".equals(collectType)) { | |
| 223 | - cloudRecordServiceMapper.updateReserveList(result, all); | |
| 224 | - } | |
| 217 | + resultCount = cloudRecordServiceMapper.updateCollectList(result, all); | |
| 225 | 218 | } |
| 219 | + return resultCount; | |
| 226 | 220 | } |
| 227 | 221 | |
| 228 | 222 | @Override |
| 229 | - public void changeCollectById(Integer recordId, String collectType, boolean result) { | |
| 230 | - if ("collect".equals(collectType)) { | |
| 231 | - cloudRecordServiceMapper.changeCollectById(result, recordId); | |
| 232 | - }else if ("reserve".equals(collectType)) { | |
| 233 | - cloudRecordServiceMapper.changeReserveById(result, recordId); | |
| 234 | - } | |
| 223 | + public int changeCollectById(Integer recordId, boolean result) { | |
| 224 | + return cloudRecordServiceMapper.changeCollectById(result, recordId); | |
| 235 | 225 | } |
| 236 | 226 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/CloudRecordServiceMapper.java
| ... | ... | @@ -79,7 +79,7 @@ public interface CloudRecordServiceMapper { |
| 79 | 79 | "update wvp_cloud_record set collect = #{collect} where file_path in " + |
| 80 | 80 | " <foreach collection='cloudRecordItemList' item='item' open='(' separator=',' close=')' > #{item.filePath}</foreach>" + |
| 81 | 81 | " </script>") |
| 82 | - void updateCollectList(@Param("collect") boolean collect, List<CloudRecordItem> cloudRecordItemList); | |
| 82 | + int updateCollectList(@Param("collect") boolean collect, List<CloudRecordItem> cloudRecordItemList); | |
| 83 | 83 | |
| 84 | 84 | @Delete(" <script>" + |
| 85 | 85 | "delete from wvp_cloud_record where media_server_id=#{mediaServerId} file_path in " + |
| ... | ... | @@ -91,7 +91,7 @@ public interface CloudRecordServiceMapper { |
| 91 | 91 | @Select(" <script>" + |
| 92 | 92 | "select file_path" + |
| 93 | 93 | " from wvp_cloud_record " + |
| 94 | - " where collect = false and reserve = false " + | |
| 94 | + " where collect = false " + | |
| 95 | 95 | " <if test= 'endTimeStamp != null '> and start_time <= #{endTimeStamp}</if>" + |
| 96 | 96 | " <if test= 'callId != null '> and call_id = #{callId}</if>" + |
| 97 | 97 | " <if test= 'mediaServerId != null ' > and media_server_id = #{mediaServerId} </if>" + |
| ... | ... | @@ -99,18 +99,8 @@ public interface CloudRecordServiceMapper { |
| 99 | 99 | List<String> queryRecordFilePathListForDelete(@Param("endTimeStamp")Long endTimeStamp, String mediaServerId); |
| 100 | 100 | |
| 101 | 101 | @Update(" <script>" + |
| 102 | - "update wvp_cloud_record set reserve = #{reserve} where file_path in " + | |
| 103 | - " <foreach collection='cloudRecordItems' item='item' open='(' separator=',' close=')' > #{item.filePath}</foreach>" + | |
| 104 | - " </script>") | |
| 105 | - void updateReserveList(@Param("reserve") boolean reserve,List<CloudRecordItem> cloudRecordItems); | |
| 106 | - | |
| 107 | - @Update(" <script>" + | |
| 108 | 102 | "update wvp_cloud_record set collect = #{collect} where id = #{recordId} " + |
| 109 | 103 | " </script>") |
| 110 | - void changeCollectById(@Param("collect") boolean collect, @Param("recordId") Integer recordId); | |
| 104 | + int changeCollectById(@Param("collect") boolean collect, @Param("recordId") Integer recordId); | |
| 111 | 105 | |
| 112 | - @Update(" <script>" + | |
| 113 | - "update wvp_cloud_record set reserve = #{reserve} where id = #{recordId} " + | |
| 114 | - " </script>") | |
| 115 | - void changeReserveById(@Param("reserve") boolean reserve, Integer recordId); | |
| 116 | 106 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java
| ... | ... | @@ -188,24 +188,20 @@ public class CloudRecordController { |
| 188 | 188 | @Parameter(name = "startTime", description = "鉴权ID", required = false) |
| 189 | 189 | @Parameter(name = "endTime", description = "鉴权ID", required = false) |
| 190 | 190 | @Parameter(name = "callId", description = "鉴权ID", required = false) |
| 191 | - @Parameter(name = "collectType", description = "收藏类型, collect/reserve", required = false) | |
| 192 | - public void addCollect( | |
| 191 | + @Parameter(name = "recordId", description = "录像记录的ID,用于精准收藏一个视频文件", required = false) | |
| 192 | + public int addCollect( | |
| 193 | 193 | @RequestParam(required = false) String app, |
| 194 | 194 | @RequestParam(required = false) String stream, |
| 195 | 195 | @RequestParam(required = false) String mediaServerId, |
| 196 | 196 | @RequestParam(required = false) String startTime, |
| 197 | 197 | @RequestParam(required = false) String endTime, |
| 198 | 198 | @RequestParam(required = false) String callId, |
| 199 | - @RequestParam(required = false) String collectType, | |
| 200 | 199 | @RequestParam(required = false) Integer recordId |
| 201 | 200 | ){ |
| 202 | - if (!"collect".equals(collectType) && !"reserve".equals(collectType)) { | |
| 203 | - collectType = "collect"; | |
| 204 | - } | |
| 205 | 201 | if (recordId != null) { |
| 206 | - cloudRecordService.changeCollectById(recordId, collectType, true); | |
| 202 | + return cloudRecordService.changeCollectById(recordId, true); | |
| 207 | 203 | }else { |
| 208 | - cloudRecordService.changeCollect(collectType, true, app, stream, mediaServerId, startTime, endTime, callId, collectType); | |
| 204 | + return cloudRecordService.changeCollect(true, app, stream, mediaServerId, startTime, endTime, callId); | |
| 209 | 205 | } |
| 210 | 206 | } |
| 211 | 207 | |
| ... | ... | @@ -218,27 +214,20 @@ public class CloudRecordController { |
| 218 | 214 | @Parameter(name = "startTime", description = "鉴权ID", required = false) |
| 219 | 215 | @Parameter(name = "endTime", description = "鉴权ID", required = false) |
| 220 | 216 | @Parameter(name = "callId", description = "鉴权ID", required = false) |
| 221 | - @Parameter(name = "collectType", description = "收藏类型, collect/reserve", required = false) | |
| 222 | - public void deleteCollect( | |
| 217 | + @Parameter(name = "recordId", description = "录像记录的ID,用于精准精准移除一个视频文件的收藏", required = false) | |
| 218 | + public int deleteCollect( | |
| 223 | 219 | @RequestParam(required = false) String app, |
| 224 | 220 | @RequestParam(required = false) String stream, |
| 225 | 221 | @RequestParam(required = false) String mediaServerId, |
| 226 | 222 | @RequestParam(required = false) String startTime, |
| 227 | 223 | @RequestParam(required = false) String endTime, |
| 228 | 224 | @RequestParam(required = false) String callId, |
| 229 | - @RequestParam(required = false) String collectType, | |
| 230 | 225 | @RequestParam(required = false) Integer recordId |
| 231 | 226 | ){ |
| 232 | - if (!"collect".equals(collectType) && !"reserve".equals(collectType)) { | |
| 233 | - collectType = "collect"; | |
| 234 | - } | |
| 235 | 227 | if (recordId != null) { |
| 236 | - cloudRecordService.changeCollectById(recordId, collectType, false); | |
| 228 | + return cloudRecordService.changeCollectById(recordId, false); | |
| 237 | 229 | }else { |
| 238 | - cloudRecordService.changeCollect(collectType, false, app, stream, mediaServerId, startTime, endTime, callId, collectType); | |
| 230 | + return cloudRecordService.changeCollect(false, app, stream, mediaServerId, startTime, endTime, callId); | |
| 239 | 231 | } |
| 240 | 232 | } |
| 241 | - | |
| 242 | - | |
| 243 | - | |
| 244 | 233 | } | ... | ... |