diff --git a/Controllers/CollectController.cs b/Controllers/CollectController.cs
new file mode 100644
index 0000000..6b3dc42
--- /dev/null
+++ b/Controllers/CollectController.cs
@@ -0,0 +1,82 @@
+using dy.net.model.dto;
+using dy.net.model.entity;
+using dy.net.service;
+using dy.net.utils;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+
+namespace dy.net.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ [Authorize]
+ public class CollectController : ControllerBase
+ {
+ private readonly DouyinCollectCateService _douyinCollectCateService;
+ private readonly DouyinQuartzJobService _douyinQuartzJobService;
+
+ public CollectController(DouyinCollectCateService douyinCollectCateService, DouyinQuartzJobService douyinQuartzJobService)
+ {
+ this._douyinCollectCateService = douyinCollectCateService;
+ _douyinQuartzJobService = douyinQuartzJobService;
+ }
+
+
+
+ ///
+ /// 分页查询
+ ///
+ /// 分页结果
+ [HttpPost("paged")]
+ public async Task GetPagedAsync(
+ DouyinCollectCateRequestDto dto)
+ {
+ if (string.IsNullOrWhiteSpace(dto.cookieId))
+ {
+ return ApiResult.Success(new { });
+ }
+ var (list, totalCount) = await _douyinCollectCateService.GetPagedAsync(dto);
+
+ return ApiResult.Success(new
+ {
+ data = list,
+ total = totalCount,
+ pageIndex = dto.PageIndex,
+ pageSize = dto.PageSize
+ });
+ }
+ ///
+ /// 重新同步-单次
+ ///
+ ///
+ [HttpGet("sync")]
+ public async Task SyncFollowList()
+ {
+ //后台异步
+ _douyinQuartzJobService.StartFollowJobOnceAsync();
+ await Task.Delay(1000);
+ return ApiResult.Success();
+ }
+
+
+ ///
+ /// 修改关注同步状态
+ ///
+ ///
+ ///
+ [HttpPost("BatchSave")]
+ public async Task BatchSave(List dto)
+ {
+
+ if(dto.Any(x=> !DouyinFileNameHelper.IsValidWithoutSpecialChars(x.Folder)))
+ {
+ return ApiResult.Fail("有部分文件名不符合要求,请检查");
+ }
+
+ var result= await _douyinCollectCateService.BatchSwitchSync(dto);
+ return ApiResult.SuccOrFail(result, result);
+ }
+
+ }
+}
diff --git a/model/dto/DouyinCookieStopDto.cs b/model/dto/DouyinCookieStopDto.cs
index cff3766..ed5aed6 100644
--- a/model/dto/DouyinCookieStopDto.cs
+++ b/model/dto/DouyinCookieStopDto.cs
@@ -12,5 +12,7 @@
public string Id { get; set; }
public bool Sync { get; set; }
+
+ public string Folder { get; set; }
}
}
diff --git a/model/dto/DouyinVideoPageRequestDto.cs b/model/dto/DouyinVideoPageRequestDto.cs
index fd0462d..758d559 100644
--- a/model/dto/DouyinVideoPageRequestDto.cs
+++ b/model/dto/DouyinVideoPageRequestDto.cs
@@ -59,5 +59,6 @@ namespace dy.net.model.dto
{
public string cookieId { get; set; }
+ public int cateType { get; set; }
}
}
diff --git a/repository/DouyinCollectCateRepository.cs b/repository/DouyinCollectCateRepository.cs
index fc2ec10..83f621c 100644
--- a/repository/DouyinCollectCateRepository.cs
+++ b/repository/DouyinCollectCateRepository.cs
@@ -1,6 +1,7 @@
using ClockSnowFlake;
using dy.net.model.dto;
using dy.net.model.entity;
+using dy.net.utils;
using SqlSugar;
using System.Linq.Expressions;
@@ -22,6 +23,7 @@ namespace dy.net.repository
public async Task<(List list, int totalCount)> GetPagedAsync(DouyinCollectCateRequestDto dto)
{
var where = this.Db.Queryable()
+ .Where(x=>x.CateType==dto.cateType)
.WhereIF(!string.IsNullOrWhiteSpace(dto.cookieId), x => x.CookieId == dto.cookieId);
var totalCount = await where.CountAsync();
@@ -52,6 +54,8 @@ namespace dy.net.repository
if (dtoDict.TryGetValue(item.Id, out var dtocate))
{
item.Sync = dtocate.Sync;
+ item.SaveFolder = string.IsNullOrWhiteSpace(dtocate.Folder) ? DouyinFileNameHelper.SanitizeLinuxFileName(item.Name, item.Id, true) : dtocate.Folder;
+ item.UpdateTime = DateTime.Now;
}
});
diff --git a/service/DouyinCollectCateService.cs b/service/DouyinCollectCateService.cs
index fee2ed5..8a63863 100644
--- a/service/DouyinCollectCateService.cs
+++ b/service/DouyinCollectCateService.cs
@@ -20,7 +20,10 @@ namespace dy.net.service
-
+ public async Task AddAsync(DouyinCollectCate cate)
+ {
+ return await douyinCollectCateRepository.InsertAsync(cate);
+ }
///
@@ -38,10 +41,11 @@ namespace dy.net.service
///
///
///
+ ///
///
- public async Task<(int add, int update,int delete, bool succ)> Sync(List cates, string ckId)
+ public async Task<(int add, int update,int delete, bool succ)> Sync(List cates, string ckId,int cateType)
{
- return await douyinCollectCateRepository.Sync(cates, ckId);
+ return await douyinCollectCateRepository.Sync(cates, ckId, cateType);
}