Commit ddad8cf6f922f4679b2c9ace4762359355ba4965

Authored by 648540858
1 parent 8a50a02d

收藏添加类型

src/main/java/top/panll/assist/controller/RecordController.java
@@ -295,16 +295,18 @@ public class RecordController { @@ -295,16 +295,18 @@ public class RecordController {
295 */ 295 */
296 @ApiOperation("收藏录像(被收藏的录像不会被清理任务清理)") 296 @ApiOperation("收藏录像(被收藏的录像不会被清理任务清理)")
297 @ApiImplicitParams({ 297 @ApiImplicitParams({
  298 + @ApiImplicitParam(name="type", value = "类型", required = true, dataTypeClass = String.class),
298 @ApiImplicitParam(name="app", value = "应用名", required = true, dataTypeClass = String.class), 299 @ApiImplicitParam(name="app", value = "应用名", required = true, dataTypeClass = String.class),
299 @ApiImplicitParam(name="stream", value = "流ID", required = true, dataTypeClass = String.class), 300 @ApiImplicitParam(name="stream", value = "流ID", required = true, dataTypeClass = String.class),
300 }) 301 })
301 @GetMapping(value = "/file/collection/add") 302 @GetMapping(value = "/file/collection/add")
302 @ResponseBody 303 @ResponseBody
303 public WVPResult<String> collection( 304 public WVPResult<String> collection(
  305 + @RequestParam(required = true) String type,
304 @RequestParam(required = true) String app, 306 @RequestParam(required = true) String app,
305 @RequestParam(required = true) String stream){ 307 @RequestParam(required = true) String stream){
306 308
307 - boolean collectionResult = videoFileService.collection(app, stream); 309 + boolean collectionResult = videoFileService.collection(app, stream, type);
308 WVPResult<String> result = new WVPResult<>(); 310 WVPResult<String> result = new WVPResult<>();
309 result.setCode(0); 311 result.setCode(0);
310 result.setMsg(collectionResult ?"success":"error"); 312 result.setMsg(collectionResult ?"success":"error");
@@ -316,16 +318,18 @@ public class RecordController { @@ -316,16 +318,18 @@ public class RecordController {
316 */ 318 */
317 @ApiOperation("移除收藏录像") 319 @ApiOperation("移除收藏录像")
318 @ApiImplicitParams({ 320 @ApiImplicitParams({
  321 + @ApiImplicitParam(name="type", value = "类型", required = true, dataTypeClass = String.class),
319 @ApiImplicitParam(name="app", value = "应用名", required = true, dataTypeClass = String.class), 322 @ApiImplicitParam(name="app", value = "应用名", required = true, dataTypeClass = String.class),
320 @ApiImplicitParam(name="stream", value = "流ID", required = true, dataTypeClass = String.class), 323 @ApiImplicitParam(name="stream", value = "流ID", required = true, dataTypeClass = String.class),
321 }) 324 })
322 @GetMapping(value = "/file/collection/remove") 325 @GetMapping(value = "/file/collection/remove")
323 @ResponseBody 326 @ResponseBody
324 public WVPResult<String> removeCollection( 327 public WVPResult<String> removeCollection(
  328 + @RequestParam(required = true) String type,
325 @RequestParam(required = true) String app, 329 @RequestParam(required = true) String app,
326 @RequestParam(required = true) String stream){ 330 @RequestParam(required = true) String stream){
327 331
328 - boolean collectionResult = videoFileService.removeCollection(app, stream); 332 + boolean collectionResult = videoFileService.removeCollection(app, stream, type);
329 WVPResult<String> result = new WVPResult<>(); 333 WVPResult<String> result = new WVPResult<>();
330 result.setCode(0); 334 result.setCode(0);
331 result.setMsg(collectionResult ?"success":"error"); 335 result.setMsg(collectionResult ?"success":"error");
@@ -337,16 +341,18 @@ public class RecordController { @@ -337,16 +341,18 @@ public class RecordController {
337 */ 341 */
338 @ApiOperation("收藏录像列表") 342 @ApiOperation("收藏录像列表")
339 @ApiImplicitParams({ 343 @ApiImplicitParams({
  344 + @ApiImplicitParam(name="type", value = "类型", required = true, dataTypeClass = String.class),
340 @ApiImplicitParam(name="app", value = "应用名", required = false, dataTypeClass = String.class), 345 @ApiImplicitParam(name="app", value = "应用名", required = false, dataTypeClass = String.class),
341 @ApiImplicitParam(name="stream", value = "流ID", required = false, dataTypeClass = String.class), 346 @ApiImplicitParam(name="stream", value = "流ID", required = false, dataTypeClass = String.class),
342 }) 347 })
343 @GetMapping(value = "/file/collection/list") 348 @GetMapping(value = "/file/collection/list")
344 @ResponseBody 349 @ResponseBody
345 public WVPResult<List<SignInfo>> collectionList( 350 public WVPResult<List<SignInfo>> collectionList(
  351 + @RequestParam(required = false) String type,
346 @RequestParam(required = false) String app, 352 @RequestParam(required = false) String app,
347 @RequestParam(required = false) String stream){ 353 @RequestParam(required = false) String stream){
348 354
349 - List<SignInfo> signInfos = videoFileService.getCollectionList(app, stream); 355 + List<SignInfo> signInfos = videoFileService.getCollectionList(app, stream, type);
350 WVPResult<List<SignInfo>> result = new WVPResult<>(); 356 WVPResult<List<SignInfo>> result = new WVPResult<>();
351 result.setCode(0); 357 result.setCode(0);
352 result.setMsg(signInfos != null ?"success":"error"); 358 result.setMsg(signInfos != null ?"success":"error");
src/main/java/top/panll/assist/service/FileManagerTimer.java
@@ -59,8 +59,11 @@ public class FileManagerTimer { @@ -59,8 +59,11 @@ public class FileManagerTimer {
59 if (streamList != null && streamList.size() > 0) { 59 if (streamList != null && streamList.size() > 0) {
60 for (File streamFile : streamList) { 60 for (File streamFile : streamList) {
61 // 带有sig标记文件的为收藏文件,不被自动清理任务移除 61 // 带有sig标记文件的为收藏文件,不被自动清理任务移除
62 - File signFile = new File(streamFile.getAbsolutePath() + File.separator + "sign");  
63 - if (signFile.exists()) { 62 + File[] signFiles = streamFile.listFiles((File dir, String name) -> {
  63 + File currentFile = new File(dir.getAbsolutePath() + File.separator + name);
  64 + return currentFile.isFile() && name.endsWith(".sign");
  65 + });
  66 + if (signFiles != null && signFiles.length > 0) {
64 continue; 67 continue;
65 } 68 }
66 List<File> dateList = videoFileService.getDateList(streamFile, null, null, false); 69 List<File> dateList = videoFileService.getDateList(streamFile, null, null, false);
src/main/java/top/panll/assist/service/VideoFileService.java
@@ -533,11 +533,11 @@ public class VideoFileService { @@ -533,11 +533,11 @@ public class VideoFileService {
533 return false; 533 return false;
534 } 534 }
535 535
536 - public boolean collection(String app, String stream) { 536 + public boolean collection(String app, String stream, String type) {
537 File streamFile = new File(userSettings.getRecord() + File.separator + app + File.separator + stream); 537 File streamFile = new File(userSettings.getRecord() + File.separator + app + File.separator + stream);
538 boolean result = false; 538 boolean result = false;
539 if (streamFile.exists() && streamFile.isDirectory() && streamFile.canWrite()) { 539 if (streamFile.exists() && streamFile.isDirectory() && streamFile.canWrite()) {
540 - File signFile = new File(streamFile.getAbsolutePath() + File.separator + "sign"); 540 + File signFile = new File(streamFile.getAbsolutePath() + File.separator + type + ".sign");
541 try { 541 try {
542 result = signFile.createNewFile(); 542 result = signFile.createNewFile();
543 } catch (IOException e) { 543 } catch (IOException e) {
@@ -547,8 +547,8 @@ public class VideoFileService { @@ -547,8 +547,8 @@ public class VideoFileService {
547 return result; 547 return result;
548 } 548 }
549 549
550 - public boolean removeCollection(String app, String stream) {  
551 - File signFile = new File(userSettings.getRecord() + File.separator + app + File.separator + stream + File.separator + "sign"); 550 + public boolean removeCollection(String app, String stream, String type) {
  551 + File signFile = new File(userSettings.getRecord() + File.separator + app + File.separator + stream + File.separator + type + ".sign");
552 boolean result = false; 552 boolean result = false;
553 if (signFile.exists() && signFile.isFile()) { 553 if (signFile.exists() && signFile.isFile()) {
554 result = signFile.delete(); 554 result = signFile.delete();
@@ -556,7 +556,7 @@ public class VideoFileService { @@ -556,7 +556,7 @@ public class VideoFileService {
556 return result; 556 return result;
557 } 557 }
558 558
559 - public List<SignInfo> getCollectionList(String app, String stream) { 559 + public List<SignInfo> getCollectionList(String app, String stream, String type) {
560 List<File> appList = this.getAppList(true); 560 List<File> appList = this.getAppList(true);
561 List<SignInfo> result = new ArrayList<>(); 561 List<SignInfo> result = new ArrayList<>();
562 if (appList.size() > 0) { 562 if (appList.size() > 0) {
@@ -574,7 +574,7 @@ public class VideoFileService { @@ -574,7 +574,7 @@ public class VideoFileService {
574 continue; 574 continue;
575 } 575 }
576 } 576 }
577 - File signFile = new File(streamFile.getAbsolutePath() + File.separator + "sign"); 577 + File signFile = new File(streamFile.getAbsolutePath() + File.separator + type + ".sign");
578 if (signFile.exists()) { 578 if (signFile.exists()) {
579 SignInfo signInfo = new SignInfo(); 579 SignInfo signInfo = new SignInfo();
580 signInfo.setApp(appFile.getName()); 580 signInfo.setApp(appFile.getName());