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 295 */
296 296 @ApiOperation("收藏录像(被收藏的录像不会被清理任务清理)")
297 297 @ApiImplicitParams({
  298 + @ApiImplicitParam(name="type", value = "类型", required = true, dataTypeClass = String.class),
298 299 @ApiImplicitParam(name="app", value = "应用名", required = true, dataTypeClass = String.class),
299 300 @ApiImplicitParam(name="stream", value = "流ID", required = true, dataTypeClass = String.class),
300 301 })
301 302 @GetMapping(value = "/file/collection/add")
302 303 @ResponseBody
303 304 public WVPResult<String> collection(
  305 + @RequestParam(required = true) String type,
304 306 @RequestParam(required = true) String app,
305 307 @RequestParam(required = true) String stream){
306 308  
307   - boolean collectionResult = videoFileService.collection(app, stream);
  309 + boolean collectionResult = videoFileService.collection(app, stream, type);
308 310 WVPResult<String> result = new WVPResult<>();
309 311 result.setCode(0);
310 312 result.setMsg(collectionResult ?"success":"error");
... ... @@ -316,16 +318,18 @@ public class RecordController {
316 318 */
317 319 @ApiOperation("移除收藏录像")
318 320 @ApiImplicitParams({
  321 + @ApiImplicitParam(name="type", value = "类型", required = true, dataTypeClass = String.class),
319 322 @ApiImplicitParam(name="app", value = "应用名", required = true, dataTypeClass = String.class),
320 323 @ApiImplicitParam(name="stream", value = "流ID", required = true, dataTypeClass = String.class),
321 324 })
322 325 @GetMapping(value = "/file/collection/remove")
323 326 @ResponseBody
324 327 public WVPResult<String> removeCollection(
  328 + @RequestParam(required = true) String type,
325 329 @RequestParam(required = true) String app,
326 330 @RequestParam(required = true) String stream){
327 331  
328   - boolean collectionResult = videoFileService.removeCollection(app, stream);
  332 + boolean collectionResult = videoFileService.removeCollection(app, stream, type);
329 333 WVPResult<String> result = new WVPResult<>();
330 334 result.setCode(0);
331 335 result.setMsg(collectionResult ?"success":"error");
... ... @@ -337,16 +341,18 @@ public class RecordController {
337 341 */
338 342 @ApiOperation("收藏录像列表")
339 343 @ApiImplicitParams({
  344 + @ApiImplicitParam(name="type", value = "类型", required = true, dataTypeClass = String.class),
340 345 @ApiImplicitParam(name="app", value = "应用名", required = false, dataTypeClass = String.class),
341 346 @ApiImplicitParam(name="stream", value = "流ID", required = false, dataTypeClass = String.class),
342 347 })
343 348 @GetMapping(value = "/file/collection/list")
344 349 @ResponseBody
345 350 public WVPResult<List<SignInfo>> collectionList(
  351 + @RequestParam(required = false) String type,
346 352 @RequestParam(required = false) String app,
347 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 356 WVPResult<List<SignInfo>> result = new WVPResult<>();
351 357 result.setCode(0);
352 358 result.setMsg(signInfos != null ?"success":"error");
... ...
src/main/java/top/panll/assist/service/FileManagerTimer.java
... ... @@ -59,8 +59,11 @@ public class FileManagerTimer {
59 59 if (streamList != null && streamList.size() > 0) {
60 60 for (File streamFile : streamList) {
61 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 67 continue;
65 68 }
66 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 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 537 File streamFile = new File(userSettings.getRecord() + File.separator + app + File.separator + stream);
538 538 boolean result = false;
539 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 541 try {
542 542 result = signFile.createNewFile();
543 543 } catch (IOException e) {
... ... @@ -547,8 +547,8 @@ public class VideoFileService {
547 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 552 boolean result = false;
553 553 if (signFile.exists() && signFile.isFile()) {
554 554 result = signFile.delete();
... ... @@ -556,7 +556,7 @@ public class VideoFileService {
556 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 560 List<File> appList = this.getAppList(true);
561 561 List<SignInfo> result = new ArrayList<>();
562 562 if (appList.size() > 0) {
... ... @@ -574,7 +574,7 @@ public class VideoFileService {
574 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 578 if (signFile.exists()) {
579 579 SignInfo signInfo = new SignInfo();
580 580 signInfo.setApp(appFile.getName());
... ...