重置cookie工具
This commit is contained in:
@@ -151,6 +151,38 @@ namespace dy.net.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配合工具自动设置cookie
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("FastResetCookie")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<IActionResult> FastResetCookie([FromBody] DouyinCookieResetDto dto)
|
||||||
|
{
|
||||||
|
var cookieValid = await httpClientService.CheckCookie(new DouyinCookie { Cookies = dto.cookie });
|
||||||
|
if (!cookieValid)
|
||||||
|
return ApiResult.Fail("Cookie无效或已过期,请按照文档提示重新获取有效Cookie,不要使用插件获取cookie");
|
||||||
|
var result = await dyCookieService.FastResetCookie(dto.id, dto.cookie);
|
||||||
|
|
||||||
|
return result ? ApiResult.Success() : ApiResult.Fail("cookie设置失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配合工具自动设置cookie,获取当前设置的所有Cookie
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpGet("Cookies")]
|
||||||
|
public async Task<IActionResult> GetAllCookies()
|
||||||
|
{
|
||||||
|
var cookies = await dyCookieService.GetAllAsync();
|
||||||
|
if (cookies != null)
|
||||||
|
return ApiResult.Success(cookies.Select(x => new { id= x.Id,name= x.UserName, status=x.StatusMsg }));
|
||||||
|
return ApiResult.Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 非docker初始化
|
/// 非docker初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -17,6 +17,6 @@
|
|||||||
<SelfContained>false</SelfContained>
|
<SelfContained>false</SelfContained>
|
||||||
<!--<DockerArch>x86</DockerArch>-->
|
<!--<DockerArch>x86</DockerArch>-->
|
||||||
<!--<DockerArch>arm</DockerArch> -->
|
<!--<DockerArch>arm</DockerArch> -->
|
||||||
<!--<DockerCoreVersion>2.1.8</DockerCoreVersion>-->
|
<!--<DockerCoreVersion>2.2.0</DockerCoreVersion>-->
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -95,8 +95,9 @@ Cookie 及 `sec_user_id` 是同步功能的核心,需严格按步骤获取,
|
|||||||
|
|
||||||
| 镜像标签 | 架构 |
|
| 镜像标签 | 架构 |
|
||||||
| ----------------- | -------------- |
|
| ----------------- | -------------- |
|
||||||
| `beta_2.1.8` | x86_64 (amd64) |
|
| `beta_2.2.0` | x86_64 (amd64) |
|
||||||
| `arm_2.1.8` | ARM64 |
|
| `arm_2.2.0` | ARM64 |
|
||||||
|
| `latest` | x86_64 (amd64) |
|
||||||
|
|
||||||
|
|
||||||
### 构建命令示例
|
### 构建命令示例
|
||||||
@@ -113,7 +114,7 @@ Cookie 及 `sec_user_id` 是同步功能的核心,需严格按步骤获取,
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
dysync:
|
dysync:
|
||||||
image: ccr.ccs.tencentyun.com/jianzhichu/dysync:beta_2.1.8
|
image: ccr.ccs.tencentyun.com/jianzhichu/dysync:beta_2.2.0
|
||||||
container_name: dysync2026 # 容器名称
|
container_name: dysync2026 # 容器名称
|
||||||
restart: unless-stopped # 始终重启容器,除非容器被手动停止或Docker服务停止
|
restart: unless-stopped # 始终重启容器,除非容器被手动停止或Docker服务停止
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Binary file not shown.
+1
-1
@@ -131,7 +131,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<!-- 核心配置:仅用核心版本号2.1.8,自动拼接前缀 -->
|
<!-- 核心配置:仅用核心版本号2.2.0,自动拼接前缀 -->
|
||||||
<!--<Target Name="DockerBuildAndPushAfterPublish" AfterTargets="Publish">
|
<!--<Target Name="DockerBuildAndPushAfterPublish" AfterTargets="Publish">
|
||||||
<Exec Command="docker build -t jianzhichu/dysync.net:beta_$(DockerCoreVersion) . && docker tag jianzhichu/dysync.net:beta_$(DockerCoreVersion) ccr.ccs.tencentyun.com/jianzhichu/dysync:beta_$(DockerCoreVersion) && docker push ccr.ccs.tencentyun.com/jianzhichu/dysync:beta_$(DockerCoreVersion)"
|
<Exec Command="docker build -t jianzhichu/dysync.net:beta_$(DockerCoreVersion) . && docker tag jianzhichu/dysync.net:beta_$(DockerCoreVersion) ccr.ccs.tencentyun.com/jianzhichu/dysync:beta_$(DockerCoreVersion) && docker push ccr.ccs.tencentyun.com/jianzhichu/dysync:beta_$(DockerCoreVersion)"
|
||||||
Condition="'$(DockerArch)' == 'x86'" />
|
Condition="'$(DockerArch)' == 'x86'" />
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace dy.net.model.dto
|
||||||
|
{
|
||||||
|
public class DouyinCookieResetDto
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
|
||||||
|
public string cookie { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,24 @@ namespace dy.net.repository
|
|||||||
public DouyinCookieRepository(ISqlSugarClient db) : base(db)
|
public DouyinCookieRepository(ISqlSugarClient db) : base(db)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
public async Task<bool> FastResetCookie(string id, string cookie)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(id))
|
||||||
|
{
|
||||||
|
var result = await Db.Updateable<DouyinCookie>()
|
||||||
|
.SetColumns(it => it.Cookies == cookie)
|
||||||
|
.Where(it => it.Id == id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
return result > 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = await Db.Updateable<DouyinCookie>()
|
||||||
|
.SetColumns(it => it.Cookies == cookie)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
return result > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
public async Task<List<DouyinCookie>> GetAllCookiesAsync(Expression<Func<DouyinCookie, bool>> whereExpression = null)
|
public async Task<List<DouyinCookie>> GetAllCookiesAsync(Expression<Func<DouyinCookie, bool>> whereExpression = null)
|
||||||
{
|
{
|
||||||
// 1. 初始化查询:先加固定条件 Status == 1
|
// 1. 初始化查询:先加固定条件 Status == 1
|
||||||
|
|||||||
@@ -42,6 +42,19 @@ namespace dy.net.service
|
|||||||
{
|
{
|
||||||
return await _cookieRepository.InsertAsync(dyUserCookies);
|
return await _cookieRepository.InsertAsync(dyUserCookies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> FastResetCookie(string id,string cookie)
|
||||||
|
{
|
||||||
|
var d= await _cookieRepository.FastResetCookie(id, cookie);
|
||||||
|
if (d)
|
||||||
|
{
|
||||||
|
var cookies =await _cookieRepository.GetByIdAsync(id);
|
||||||
|
cookies.StatusCode = 0;
|
||||||
|
cookies.StatusMsg = "正常";
|
||||||
|
await _cookieRepository.UpdateAsync(cookies);
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
}
|
||||||
public async Task<bool> Switch(DouyinCookieSwitchDto dto)
|
public async Task<bool> Switch(DouyinCookieSwitchDto dto)
|
||||||
{
|
{
|
||||||
return await _cookieRepository.SwitchAsync(dto);
|
return await _cookieRepository.SwitchAsync(dto);
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ namespace dy.net.service
|
|||||||
if (model == null)
|
if (model == null)
|
||||||
Log.Error($"SyncCollectVideos fail, data is null");
|
Log.Error($"SyncCollectVideos fail, data is null");
|
||||||
return model;
|
return model;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user