收藏夹
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查询
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>分页结果</returns>
|
||||||
|
[HttpPost("paged")]
|
||||||
|
public async Task<IActionResult> 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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 重新同步-单次
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("sync")]
|
||||||
|
public async Task<IActionResult> SyncFollowList()
|
||||||
|
{
|
||||||
|
//后台异步
|
||||||
|
_douyinQuartzJobService.StartFollowJobOnceAsync();
|
||||||
|
await Task.Delay(1000);
|
||||||
|
return ApiResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改关注同步状态
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("BatchSave")]
|
||||||
|
public async Task<IActionResult> BatchSave(List<DouyinCollectCateSwitchDto> dto)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(dto.Any(x=> !DouyinFileNameHelper.IsValidWithoutSpecialChars(x.Folder)))
|
||||||
|
{
|
||||||
|
return ApiResult.Fail("有部分文件名不符合要求,请检查");
|
||||||
|
}
|
||||||
|
|
||||||
|
var result= await _douyinCollectCateService.BatchSwitchSync(dto);
|
||||||
|
return ApiResult.SuccOrFail(result, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,5 +12,7 @@
|
|||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
public bool Sync { get; set; }
|
public bool Sync { get; set; }
|
||||||
|
|
||||||
|
public string Folder { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,5 +59,6 @@ namespace dy.net.model.dto
|
|||||||
{
|
{
|
||||||
|
|
||||||
public string cookieId { get; set; }
|
public string cookieId { get; set; }
|
||||||
|
public int cateType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using ClockSnowFlake;
|
using ClockSnowFlake;
|
||||||
using dy.net.model.dto;
|
using dy.net.model.dto;
|
||||||
using dy.net.model.entity;
|
using dy.net.model.entity;
|
||||||
|
using dy.net.utils;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ namespace dy.net.repository
|
|||||||
public async Task<(List<DouyinCollectCate> list, int totalCount)> GetPagedAsync(DouyinCollectCateRequestDto dto)
|
public async Task<(List<DouyinCollectCate> list, int totalCount)> GetPagedAsync(DouyinCollectCateRequestDto dto)
|
||||||
{
|
{
|
||||||
var where = this.Db.Queryable<DouyinCollectCate>()
|
var where = this.Db.Queryable<DouyinCollectCate>()
|
||||||
|
.Where(x=>x.CateType==dto.cateType)
|
||||||
.WhereIF(!string.IsNullOrWhiteSpace(dto.cookieId), x => x.CookieId == dto.cookieId);
|
.WhereIF(!string.IsNullOrWhiteSpace(dto.cookieId), x => x.CookieId == dto.cookieId);
|
||||||
|
|
||||||
var totalCount = await where.CountAsync();
|
var totalCount = await where.CountAsync();
|
||||||
@@ -52,6 +54,8 @@ namespace dy.net.repository
|
|||||||
if (dtoDict.TryGetValue(item.Id, out var dtocate))
|
if (dtoDict.TryGetValue(item.Id, out var dtocate))
|
||||||
{
|
{
|
||||||
item.Sync = dtocate.Sync;
|
item.Sync = dtocate.Sync;
|
||||||
|
item.SaveFolder = string.IsNullOrWhiteSpace(dtocate.Folder) ? DouyinFileNameHelper.SanitizeLinuxFileName(item.Name, item.Id, true) : dtocate.Folder;
|
||||||
|
item.UpdateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ namespace dy.net.service
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<bool> AddAsync(DouyinCollectCate cate)
|
||||||
|
{
|
||||||
|
return await douyinCollectCateRepository.InsertAsync(cate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -38,10 +41,11 @@ namespace dy.net.service
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cates"></param>
|
/// <param name="cates"></param>
|
||||||
/// <param name="ckId"></param>
|
/// <param name="ckId"></param>
|
||||||
|
/// <param name="cateType"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<(int add, int update,int delete, bool succ)> Sync(List<DouyinCollectCate> cates, string ckId)
|
public async Task<(int add, int update,int delete, bool succ)> Sync(List<DouyinCollectCate> cates, string ckId,int cateType)
|
||||||
{
|
{
|
||||||
return await douyinCollectCateRepository.Sync(cates, ckId);
|
return await douyinCollectCateRepository.Sync(cates, ckId, cateType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user