优化收藏功能
parent
cccfdace5b
commit
79f3ca9791
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public interface CloudRecordServiceMapper {
|
|||
"update wvp_cloud_record set collect = #{collect} where file_path in " +
|
||||
" <foreach collection='cloudRecordItemList' item='item' open='(' separator=',' close=')' > #{item.filePath}</foreach>" +
|
||||
" </script>")
|
||||
void updateCollectList(@Param("collect") boolean collect, List<CloudRecordItem> cloudRecordItemList);
|
||||
int updateCollectList(@Param("collect") boolean collect, List<CloudRecordItem> cloudRecordItemList);
|
||||
|
||||
@Delete(" <script>" +
|
||||
"delete from wvp_cloud_record where media_server_id=#{mediaServerId} file_path in " +
|
||||
|
@ -91,26 +91,16 @@ public interface CloudRecordServiceMapper {
|
|||
@Select(" <script>" +
|
||||
"select file_path" +
|
||||
" from wvp_cloud_record " +
|
||||
" where collect = false and reserve = false " +
|
||||
" where collect = false " +
|
||||
" <if test= 'endTimeStamp != null '> and start_time <= #{endTimeStamp}</if>" +
|
||||
" <if test= 'callId != null '> and call_id = #{callId}</if>" +
|
||||
" <if test= 'mediaServerId != null ' > and media_server_id = #{mediaServerId} </if>" +
|
||||
" </script>")
|
||||
List<String> queryRecordFilePathListForDelete(@Param("endTimeStamp")Long endTimeStamp, String mediaServerId);
|
||||
|
||||
@Update(" <script>" +
|
||||
"update wvp_cloud_record set reserve = #{reserve} where file_path in " +
|
||||
" <foreach collection='cloudRecordItems' item='item' open='(' separator=',' close=')' > #{item.filePath}</foreach>" +
|
||||
" </script>")
|
||||
void updateReserveList(@Param("reserve") boolean reserve,List<CloudRecordItem> cloudRecordItems);
|
||||
|
||||
@Update(" <script>" +
|
||||
"update wvp_cloud_record set collect = #{collect} where id = #{recordId} " +
|
||||
" </script>")
|
||||
void changeCollectById(@Param("collect") boolean collect, @Param("recordId") Integer recordId);
|
||||
int changeCollectById(@Param("collect") boolean collect, @Param("recordId") Integer recordId);
|
||||
|
||||
@Update(" <script>" +
|
||||
"update wvp_cloud_record set reserve = #{reserve} where id = #{recordId} " +
|
||||
" </script>")
|
||||
void changeReserveById(@Param("reserve") boolean reserve, Integer recordId);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue