This commit is contained in:
parent
1e52b99988
commit
70c1654a96
|
|
@ -31,6 +31,38 @@
|
||||||
"autoApprove": [
|
"autoApprove": [
|
||||||
"execute_sql"
|
"execute_sql"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"prod-api-sqlserver": {
|
||||||
|
"command": "node",
|
||||||
|
"args": [
|
||||||
|
"D:\\outsource\\live-forum\\mcp\\mssql-mcp-server\\index.js"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"MSSQL_SERVER": "192.168.195.18",
|
||||||
|
"MSSQL_PORT": "1433",
|
||||||
|
"MSSQL_USER": "sa",
|
||||||
|
"MSSQL_PASSWORD": "skzj@1.com",
|
||||||
|
"MSSQL_DATABASE": "liveForumdb"
|
||||||
|
},
|
||||||
|
"autoApprove": [
|
||||||
|
"execute_sql"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"prod-admin-sqlserver": {
|
||||||
|
"command": "node",
|
||||||
|
"args": [
|
||||||
|
"D:\\outsource\\live-forum\\mcp\\mssql-mcp-server\\index.js"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"MSSQL_SERVER": "192.168.195.18",
|
||||||
|
"MSSQL_PORT": "1433",
|
||||||
|
"MSSQL_USER": "sa",
|
||||||
|
"MSSQL_PASSWORD": "skzj@1.com",
|
||||||
|
"MSSQL_DATABASE": "admindb"
|
||||||
|
},
|
||||||
|
"autoApprove": [
|
||||||
|
"execute_sql"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
|
|
||||||
|
using ZR.Common.Cache;
|
||||||
using ZR.LiveForum.Model.Liveforum.Dto;
|
using ZR.LiveForum.Model.Liveforum.Dto;
|
||||||
using ZR.LiveForum.Model.Liveforum;
|
using ZR.LiveForum.Model.Liveforum;
|
||||||
using ZR.Repository;
|
using ZR.Repository;
|
||||||
|
|
@ -72,7 +73,19 @@ namespace ZR.Service.Liveforum
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int UpdateT_Streamers(T_Streamers model)
|
public int UpdateT_Streamers(T_Streamers model)
|
||||||
{
|
{
|
||||||
return Update(model, true);
|
var result = Update(model, true);
|
||||||
|
|
||||||
|
// 清除该主播的Redis花数缓存
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RedisServer.Cache.Del($"flower_count:Streamer:{model.Id}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
NLog.LogManager.GetCurrentClassLogger().Warn(ex, "清除Redis花数缓存失败, StreamerId: {0}", model.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -122,9 +135,26 @@ namespace ZR.Service.Liveforum
|
||||||
streamer.UpdatedAt = DateTime.Now;
|
streamer.UpdatedAt = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Context.Updateable(streamers)
|
var result = Context.Updateable(streamers)
|
||||||
.UpdateColumns(it => new { it.FlowerCount, it.UpdatedAt })
|
.UpdateColumns(it => new { it.FlowerCount, it.UpdatedAt })
|
||||||
.ExecuteCommand();
|
.ExecuteCommand();
|
||||||
|
|
||||||
|
// 清除Redis中对应主播的花数缓存,确保WebAPI读取最新数据
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var streamer in streamers)
|
||||||
|
{
|
||||||
|
var cacheKey = $"flower_count:Streamer:{streamer.Id}";
|
||||||
|
RedisServer.Cache.Del(cacheKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Redis清除失败不影响主流程,缓存会在24小时后自动过期
|
||||||
|
NLog.LogManager.GetCurrentClassLogger().Warn(ex, "清除Redis花数缓存失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
using FreeSql;
|
using FreeSql;
|
||||||
|
|
||||||
|
using LiveForum.Code.Redis.Contract;
|
||||||
using LiveForum.IService.Others;
|
using LiveForum.IService.Others;
|
||||||
using LiveForum.Model;
|
using LiveForum.Model;
|
||||||
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
@ -19,22 +21,27 @@ namespace LiveForum.Service.ScheduledJobs
|
||||||
{
|
{
|
||||||
private readonly IBaseRepository<T_Streamers> _streamersRepository;
|
private readonly IBaseRepository<T_Streamers> _streamersRepository;
|
||||||
private readonly IBaseRepository<T_FlowerRecords> _flowerRecordsRepository;
|
private readonly IBaseRepository<T_FlowerRecords> _flowerRecordsRepository;
|
||||||
|
private readonly IRedisService _redisService;
|
||||||
private readonly ILogger<StreamerFlowerResetJob> _logger;
|
private readonly ILogger<StreamerFlowerResetJob> _logger;
|
||||||
private const int BatchSize = 500; // 每批处理500条记录
|
private const int BatchSize = 500; // 每批处理500条记录
|
||||||
|
private const string FLOWER_COUNT_KEY_PREFIX = "flower_count:";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造函数
|
/// 构造函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamersRepository">主播仓储</param>
|
/// <param name="streamersRepository">主播仓储</param>
|
||||||
/// <param name="flowerRecordsRepository">送花记录仓储</param>
|
/// <param name="flowerRecordsRepository">送花记录仓储</param>
|
||||||
|
/// <param name="redisService">Redis服务</param>
|
||||||
/// <param name="logger">日志记录器</param>
|
/// <param name="logger">日志记录器</param>
|
||||||
public StreamerFlowerResetJob(
|
public StreamerFlowerResetJob(
|
||||||
IBaseRepository<T_Streamers> streamersRepository,
|
IBaseRepository<T_Streamers> streamersRepository,
|
||||||
IBaseRepository<T_FlowerRecords> flowerRecordsRepository,
|
IBaseRepository<T_FlowerRecords> flowerRecordsRepository,
|
||||||
|
IRedisService redisService,
|
||||||
ILogger<StreamerFlowerResetJob> logger)
|
ILogger<StreamerFlowerResetJob> logger)
|
||||||
{
|
{
|
||||||
_streamersRepository = streamersRepository;
|
_streamersRepository = streamersRepository;
|
||||||
_flowerRecordsRepository = flowerRecordsRepository;
|
_flowerRecordsRepository = flowerRecordsRepository;
|
||||||
|
_redisService = redisService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,6 +67,18 @@ namespace LiveForum.Service.ScheduledJobs
|
||||||
.ExecuteAffrowsAsync();
|
.ExecuteAffrowsAsync();
|
||||||
_logger.LogInformation("[定时任务] 已清零 {ResetCount} 个主播的送花数量", resetCount);
|
_logger.LogInformation("[定时任务] 已清零 {ResetCount} 个主播的送花数量", resetCount);
|
||||||
|
|
||||||
|
// 2.5 清除Redis中所有主播的花数缓存
|
||||||
|
_logger.LogInformation("[定时任务] 开始清除Redis花数缓存...");
|
||||||
|
var allStreamers = await _streamersRepository.Select.ToListAsync();
|
||||||
|
var clearedCount = 0;
|
||||||
|
foreach (var streamer in allStreamers)
|
||||||
|
{
|
||||||
|
var cacheKey = $"{FLOWER_COUNT_KEY_PREFIX}Streamer:{streamer.Id}";
|
||||||
|
await _redisService.RemoveAsync(cacheKey);
|
||||||
|
clearedCount++;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("[定时任务] 已清除 {ClearedCount} 个主播的Redis花数缓存", clearedCount);
|
||||||
|
|
||||||
// 3. 从T_FlowerRecords表统计当月数据
|
// 3. 从T_FlowerRecords表统计当月数据
|
||||||
_logger.LogInformation("[定时任务] 开始统计当月送花记录...");
|
_logger.LogInformation("[定时任务] 开始统计当月送花记录...");
|
||||||
// 先查询所有符合条件的记录
|
// 先查询所有符合条件的记录
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ var Config = Config || {}
|
||||||
// Config.API_BASE_URL = 'http://localhost:8080'
|
// Config.API_BASE_URL = 'http://localhost:8080'
|
||||||
// Config.API_BASE_URL = 'https://liveforum.api.zpc-xy.com'
|
// Config.API_BASE_URL = 'https://liveforum.api.zpc-xy.com'
|
||||||
// Config.API_BASE_URL = 'http://192.168.195.15:2408' // 备用地址
|
// Config.API_BASE_URL = 'http://192.168.195.15:2408' // 备用地址
|
||||||
Config.API_BASE_URL = 'https://api.skzhijia.com' // 现网地址
|
// Config.API_BASE_URL = 'https://api.skzhijia.com' // 现网地址
|
||||||
|
|
||||||
// Config.API_BASE_URL = 'https://api.xkx.shhmkjgs.cn' // 备用地址
|
Config.API_BASE_URL = 'https://api.xkx.shhmkjgs.cn' // 备用地址
|
||||||
|
|
||||||
// Config.API_BASE_URL = 'http://175.27.168.122:82' // 备用地址
|
// Config.API_BASE_URL = 'http://175.27.168.122:82' // 备用地址
|
||||||
|
|
||||||
|
|
@ -45,8 +45,8 @@ Config.UPLOAD_CONFIG = {
|
||||||
videoMaxSize: 100 * 1024 * 1024, // 100MB
|
videoMaxSize: 100 * 1024 * 1024, // 100MB
|
||||||
|
|
||||||
// COS域名(如果使用COS上传)
|
// COS域名(如果使用COS上传)
|
||||||
// cosDomain: 'https://miaoyu-1308826010.cos.ap-shanghai.myqcloud.com'
|
cosDomain: 'https://miaoyu-1308826010.cos.ap-shanghai.myqcloud.com'
|
||||||
cosDomain: 'https://skzjmp-1377391978.cos.ap-nanjing.myqcloud.com'
|
// cosDomain: 'https://skzjmp-1377391978.cos.ap-nanjing.myqcloud.com'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 不同场景的上传配置预设
|
// 不同场景的上传配置预设
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user