From 79f3ca9791bffe1ee7850432b8b432e8c5d7bf7e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 25 Oct 2023 14:45:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=B6=E8=97=8F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/初始化-mysql-2.6.9.sql | 1 - sql/初始化-postgresql-kingbase-2.6.9.sql | 1 - sql/更新-mysql-2.6.9.sql | 1 - sql/更新-postgresql-kingbase-2.6.9.sql | 1 - .../iot/vmp/service/ICloudRecordService.java | 4 +-- .../service/impl/CloudRecordServiceImpl.java | 24 +++++------------ .../dao/CloudRecordServiceMapper.java | 16 +++-------- .../cloudRecord/CloudRecordController.java | 27 ++++++------------- 8 files changed, 20 insertions(+), 55 deletions(-) diff --git a/sql/初始化-mysql-2.6.9.sql b/sql/初始化-mysql-2.6.9.sql index 78f9e9aa..bd8a4f57 100644 --- a/sql/初始化-mysql-2.6.9.sql +++ b/sql/初始化-mysql-2.6.9.sql @@ -280,7 +280,6 @@ create table wvp_cloud_record ( folder character varying(255), file_path character varying(255), collect bool default false, - reserve bool default false, file_size bigint, time_len bigint, constraint uk_stream_push_app_stream_path unique (app, stream, file_path) diff --git a/sql/初始化-postgresql-kingbase-2.6.9.sql b/sql/初始化-postgresql-kingbase-2.6.9.sql index 97a36941..701fd763 100644 --- a/sql/初始化-postgresql-kingbase-2.6.9.sql +++ b/sql/初始化-postgresql-kingbase-2.6.9.sql @@ -280,7 +280,6 @@ create table wvp_cloud_record ( folder character varying(255), file_path character varying(255), collect bool default false, - reserve bool default false, file_size int8, time_len int8, constraint uk_stream_push_app_stream_path unique (app, stream, file_path) diff --git a/sql/更新-mysql-2.6.9.sql b/sql/更新-mysql-2.6.9.sql index 15b9e27d..f670ff30 100644 --- a/sql/更新-mysql-2.6.9.sql +++ b/sql/更新-mysql-2.6.9.sql @@ -19,7 +19,6 @@ create table wvp_cloud_record ( folder character varying(255), file_path character varying(255), collect bool default false, - reserve bool default false, file_size bigint, time_len bigint, constraint uk_stream_push_app_stream_path unique (app, stream, file_path) diff --git a/sql/更新-postgresql-kingbase-2.6.9.sql b/sql/更新-postgresql-kingbase-2.6.9.sql index 9681052d..8681c44c 100644 --- a/sql/更新-postgresql-kingbase-2.6.9.sql +++ b/sql/更新-postgresql-kingbase-2.6.9.sql @@ -19,7 +19,6 @@ create table wvp_cloud_record ( folder character varying(255), file_path character varying(255), collect bool default false, - reserve bool default false, file_size int8, time_len int8, constraint uk_stream_push_app_stream_path unique (app, stream, file_path) diff --git a/src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java b/src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java index 1c1dba35..8da31e69 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java @@ -43,11 +43,11 @@ public interface ICloudRecordService { /** * 收藏视频,收藏的视频过期不会删除 */ - void changeCollect(String type, boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId, String collectType); + int changeCollect(boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId); /** * 添加指定录像收藏 */ - void changeCollectById(Integer recordId, String collectType, boolean result); + int changeCollectById(Integer recordId, boolean result); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java index 1a8adb18..2954cd82 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java @@ -166,7 +166,7 @@ public class CloudRecordServiceImpl implements ICloudRecordService { } @Override - public void changeCollect(String type, boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId, String collectType) { + public int changeCollect(boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId) { // 开始时间和结束时间在数据库中都是以秒为单位的 Long startTimeStamp = null; Long endTimeStamp = null; @@ -203,34 +203,24 @@ public class CloudRecordServiceImpl implements ICloudRecordService { throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到待收藏的视频"); } int limitCount = 50; + int resultCount = 0; if (all.size() > limitCount) { for (int i = 0; i < all.size(); i += limitCount) { int toIndex = i + limitCount; if (i + limitCount > all.size()) { toIndex = all.size(); } - if ("collect".equals(collectType)) { - cloudRecordServiceMapper.updateCollectList(result, all.subList(i, toIndex)); - }else if ("reserve".equals(collectType)) { - cloudRecordServiceMapper.updateReserveList(result, all.subList(i, toIndex)); - } + resultCount += cloudRecordServiceMapper.updateCollectList(result, all.subList(i, toIndex)); } }else { - if ("collect".equals(collectType)) { - cloudRecordServiceMapper.updateCollectList(result, all); - }else if ("reserve".equals(collectType)) { - cloudRecordServiceMapper.updateReserveList(result, all); - } + resultCount = cloudRecordServiceMapper.updateCollectList(result, all); } + return resultCount; } @Override - public void changeCollectById(Integer recordId, String collectType, boolean result) { - if ("collect".equals(collectType)) { - cloudRecordServiceMapper.changeCollectById(result, recordId); - }else if ("reserve".equals(collectType)) { - cloudRecordServiceMapper.changeReserveById(result, recordId); - } + public int changeCollectById(Integer recordId, boolean result) { + return cloudRecordServiceMapper.changeCollectById(result, recordId); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/CloudRecordServiceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/CloudRecordServiceMapper.java index f8ceaf45..5fdf2f5c 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/CloudRecordServiceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/CloudRecordServiceMapper.java @@ -79,7 +79,7 @@ public interface CloudRecordServiceMapper { "update wvp_cloud_record set collect = #{collect} where file_path in " + " #{item.filePath}" + " ") - void updateCollectList(@Param("collect") boolean collect, List cloudRecordItemList); + int updateCollectList(@Param("collect") boolean collect, List cloudRecordItemList); @Delete(" ") List queryRecordFilePathListForDelete(@Param("endTimeStamp")Long endTimeStamp, String mediaServerId); - @Update(" ") - void updateReserveList(@Param("reserve") boolean reserve,List cloudRecordItems); - @Update(" ") - void changeCollectById(@Param("collect") boolean collect, @Param("recordId") Integer recordId); + int changeCollectById(@Param("collect") boolean collect, @Param("recordId") Integer recordId); - @Update(" ") - void changeReserveById(@Param("reserve") boolean reserve, Integer recordId); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java index 48ff15ac..1287bc35 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java @@ -188,24 +188,20 @@ public class CloudRecordController { @Parameter(name = "startTime", description = "鉴权ID", required = false) @Parameter(name = "endTime", description = "鉴权ID", required = false) @Parameter(name = "callId", description = "鉴权ID", required = false) - @Parameter(name = "collectType", description = "收藏类型, collect/reserve", required = false) - public void addCollect( + @Parameter(name = "recordId", description = "录像记录的ID,用于精准收藏一个视频文件", required = false) + public int addCollect( @RequestParam(required = false) String app, @RequestParam(required = false) String stream, @RequestParam(required = false) String mediaServerId, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String callId, - @RequestParam(required = false) String collectType, @RequestParam(required = false) Integer recordId ){ - if (!"collect".equals(collectType) && !"reserve".equals(collectType)) { - collectType = "collect"; - } if (recordId != null) { - cloudRecordService.changeCollectById(recordId, collectType, true); + return cloudRecordService.changeCollectById(recordId, true); }else { - cloudRecordService.changeCollect(collectType, true, app, stream, mediaServerId, startTime, endTime, callId, collectType); + return cloudRecordService.changeCollect(true, app, stream, mediaServerId, startTime, endTime, callId); } } @@ -218,27 +214,20 @@ public class CloudRecordController { @Parameter(name = "startTime", description = "鉴权ID", required = false) @Parameter(name = "endTime", description = "鉴权ID", required = false) @Parameter(name = "callId", description = "鉴权ID", required = false) - @Parameter(name = "collectType", description = "收藏类型, collect/reserve", required = false) - public void deleteCollect( + @Parameter(name = "recordId", description = "录像记录的ID,用于精准精准移除一个视频文件的收藏", required = false) + public int deleteCollect( @RequestParam(required = false) String app, @RequestParam(required = false) String stream, @RequestParam(required = false) String mediaServerId, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String callId, - @RequestParam(required = false) String collectType, @RequestParam(required = false) Integer recordId ){ - if (!"collect".equals(collectType) && !"reserve".equals(collectType)) { - collectType = "collect"; - } if (recordId != null) { - cloudRecordService.changeCollectById(recordId, collectType, false); + return cloudRecordService.changeCollectById(recordId, false); }else { - cloudRecordService.changeCollect(collectType, false, app, stream, mediaServerId, startTime, endTime, callId, collectType); + return cloudRecordService.changeCollect(false, app, stream, mediaServerId, startTime, endTime, callId); } } - - - }