quartz数据库持久化

This commit is contained in:
jianzhichu
2026-01-26 18:29:19 +08:00
parent f13d73e023
commit 85986cdaa3
16 changed files with 514 additions and 131 deletions
+2 -2
View File
@@ -22,9 +22,9 @@ namespace dy.net.service
}
public List<DouyinCookie> GetOpendCookies()
public async Task<List<DouyinCookie>> GetOpendCookies()
{
return _cookieRepository.GetAllCookies();
return await _cookieRepository.GetAllCookies();
}
public Task<List<DouyinCookie>> GetAllAsync()
{
+11 -11
View File
@@ -35,7 +35,7 @@ namespace dy.net.service
string refererValue,
string cookie)
{
string fullUrl = "{requestUrl}";
string fullUrl = $"{requestUrl}";
if (requestParameters != null && requestParameters.Count > 0)
{
fullUrl = QueryHelpers.AddQueryString(
@@ -109,7 +109,7 @@ namespace dy.net.service
var data = await respose.Content.ReadAsStringAsync();
var model = JsonConvert.DeserializeObject<DouyinVideoInfoResponse>(data);
if (model == null)
Serilog.Log.Error($"SyncCollectVideos fail: {data}");
Serilog.Log.Error($"SyncCollectVideos fail, data= {data}");
return model;
}
else
@@ -161,7 +161,7 @@ namespace dy.net.service
var data = await respose.Content.ReadAsStringAsync();
var model = JsonConvert.DeserializeObject<DouyinCollectListResponse>(data);
if (model == null)
Serilog.Log.Error($"SyncCollectFolderList fail: {data}");
Serilog.Log.Error($"SyncCollectFolderList fail, data= {data}");
return model;
}
else
@@ -282,7 +282,7 @@ namespace dy.net.service
var data = await respose.Content.ReadAsStringAsync();
var model = JsonConvert.DeserializeObject<DouyinMixListResponse>(data);
if (model == null)
Serilog.Log.Error($"SyncMixList fail: {data}");
Serilog.Log.Error($"SyncMixList fail, data= {data}");
return model;
}
else
@@ -402,7 +402,7 @@ namespace dy.net.service
var data = await respose.Content.ReadAsStringAsync();
var model = JsonConvert.DeserializeObject<DouyinSeriesListResponse>(data);
if (model == null)
Serilog.Log.Error($"SyncShortList fail: {data}");
Serilog.Log.Error($"SyncShortList fail, data= {data}");
return model;
}
else
@@ -543,7 +543,7 @@ namespace dy.net.service
var data = await respose.Content.ReadAsStringAsync();
var model = JsonConvert.DeserializeObject<DouyinVideoInfoResponse>(data);
if (model == null)
Serilog.Log.Error($"SyncFavoriteVideos fail: {data}");
Serilog.Log.Error($"SyncFavoriteVideos fail, data= {data}");
return model;
}
else
@@ -601,7 +601,7 @@ namespace dy.net.service
var requestUrl = "/aweme/v1/web/aweme/post";
var refererValue = "https://www.douyin.com/user/";
var requestParameters = DouyinRequestParamManager.DouyinUpderPostParams;//修复关注的不下载图文视频
var requestParameters = DouyinRequestParamManager.DouyinUpderPostParams;
{
// 添加动态参数
requestParameters["max_cursor"] = cursor;
@@ -615,12 +615,12 @@ namespace dy.net.service
var data = await respose.Content.ReadAsStringAsync();
var model = JsonConvert.DeserializeObject<DouyinVideoInfoResponse>(data);
if (model == null)
Serilog.Log.Error($"SyncUpderPostVideos fail: {data}");
Serilog.Log.Error($"SyncUpderPostVideos fail, data= {data}");
return model;
}
else
{
Serilog.Log.Error($"SyncUpderPostVideos fail: {respose.StatusCode}");
Serilog.Log.Error($"SyncUpderPostVideos StatusCode fail: {respose.StatusCode}");
return null;
}
}
@@ -740,12 +740,12 @@ namespace dy.net.service
if (!string.IsNullOrWhiteSpace(douyinCookie.SecUserId))
{
var res = await SyncMyFollows("1", "1", douyinCookie.SecUserId, douyinCookie.Cookies, null);
return res != null && res.status_code == 0 && res.Followings != null && res.Followings.Any();
return res != null && res.StatusCode == 0;
}
else
{
var res = await SyncCollectVideos("0", "1", douyinCookie.Cookies);
return res != null && res.AwemeList != null && res.AwemeList.Any();
return res != null && res.StatusCode == 0;
}
}
+7 -7
View File
@@ -77,11 +77,11 @@ namespace dy.net.service
"抖音收藏夹短剧同步任务")
},
{
"follow_user_once",
"sync_follow_user_once",
new JobConfig(
typeof(DouyinFollowsAndCollnectsSyncJob),
"dy.job.key.follow_user_once",
"dy.trigger.key.follow_user_once",
"dy.job.key.sync_follow_user_once",
"dy.trigger.key.sync_follow_user_once",
"抖音关注同步任务(单次执行)")
}
};
@@ -115,7 +115,7 @@ namespace dy.net.service
// 执行任务启动逻辑
foreach (var jobKey in JobConfigs.Keys)
{
if (jobKey == "follow_user_once")
if (jobKey == "sync_follow_user_once")
continue;
if (jobKey == "follow_user") expression = "60";
var startSuccess = await StartJobAsync(jobKey, expression);
@@ -147,13 +147,13 @@ namespace dy.net.service
/// </summary>
public async Task<bool> StartFollowJobOnceAsync()
{
return await StartOneTimeJobAsync("follow_user_once");
return await StartOneTimeJobAsync("sync_follow_user_once");
}
/// <summary>
/// 移除所有已存在的任务(避免重复调度)
/// </summary>
private async Task RemoveAllExistingJobs(IScheduler scheduler)
private static async Task RemoveAllExistingJobs(IScheduler scheduler)
{
var jobKeys = JobConfigs.Values.Select(config => new JobKey(config.JobKey, DefaultJobGroup)).ToList();
foreach (var jobKey in jobKeys)
@@ -246,7 +246,7 @@ namespace dy.net.service
.Build();
await scheduler.ScheduleJob(jobDetail, trigger);
Log.Information("【任务服务】启动单次任务成功 - 任务描述: {JobDescription}", jobConfig.Description);
Log.Debug("【任务服务】启动单次任务成功 - 任务描述: {JobDescription}", jobConfig.Description);
return true;
}