diff --git a/.kiro/settings/mcp.json b/.kiro/settings/mcp.json
index a2472bb..4a237e3 100644
--- a/.kiro/settings/mcp.json
+++ b/.kiro/settings/mcp.json
@@ -31,6 +31,38 @@
"autoApprove": [
"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"
+ ]
}
}
}
\ No newline at end of file
diff --git a/server/admin/ZrAdminNetCore/ZR.Service/Liveforum/T_StreamersService.cs b/server/admin/ZrAdminNetCore/ZR.Service/Liveforum/T_StreamersService.cs
index 02264ae..bc7ecd9 100644
--- a/server/admin/ZrAdminNetCore/ZR.Service/Liveforum/T_StreamersService.cs
+++ b/server/admin/ZrAdminNetCore/ZR.Service/Liveforum/T_StreamersService.cs
@@ -1,6 +1,7 @@
using Infrastructure.Attribute;
using Infrastructure.Extensions;
+using ZR.Common.Cache;
using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.LiveForum.Model.Liveforum;
using ZR.Repository;
@@ -72,7 +73,19 @@ namespace ZR.Service.Liveforum
///
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;
}
///
@@ -122,9 +135,26 @@ namespace ZR.Service.Liveforum
streamer.UpdatedAt = DateTime.Now;
}
- return Context.Updateable(streamers)
+ var result = Context.Updateable(streamers)
.UpdateColumns(it => new { it.FlowerCount, it.UpdatedAt })
.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;
}
///
diff --git a/server/webapi/LiveForum/LiveForum.Service/ScheduledJobs/StreamerFlowerResetJob.cs b/server/webapi/LiveForum/LiveForum.Service/ScheduledJobs/StreamerFlowerResetJob.cs
index 3d359e9..1782b1a 100644
--- a/server/webapi/LiveForum/LiveForum.Service/ScheduledJobs/StreamerFlowerResetJob.cs
+++ b/server/webapi/LiveForum/LiveForum.Service/ScheduledJobs/StreamerFlowerResetJob.cs
@@ -1,11 +1,13 @@
using FreeSql;
+using LiveForum.Code.Redis.Contract;
using LiveForum.IService.Others;
using LiveForum.Model;
using Microsoft.Extensions.Logging;
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -19,22 +21,27 @@ namespace LiveForum.Service.ScheduledJobs
{
private readonly IBaseRepository _streamersRepository;
private readonly IBaseRepository _flowerRecordsRepository;
+ private readonly IRedisService _redisService;
private readonly ILogger _logger;
private const int BatchSize = 500; // 每批处理500条记录
+ private const string FLOWER_COUNT_KEY_PREFIX = "flower_count:";
///
/// 构造函数
///
/// 主播仓储
/// 送花记录仓储
+ /// Redis服务
/// 日志记录器
public StreamerFlowerResetJob(
IBaseRepository streamersRepository,
IBaseRepository flowerRecordsRepository,
+ IRedisService redisService,
ILogger logger)
{
_streamersRepository = streamersRepository;
_flowerRecordsRepository = flowerRecordsRepository;
+ _redisService = redisService;
_logger = logger;
}
@@ -60,6 +67,18 @@ namespace LiveForum.Service.ScheduledJobs
.ExecuteAffrowsAsync();
_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表统计当月数据
_logger.LogInformation("[定时任务] 开始统计当月送花记录...");
// 先查询所有符合条件的记录
diff --git a/前端/live-forum/modules/Config.js b/前端/live-forum/modules/Config.js
index 2b86794..62aee0a 100644
--- a/前端/live-forum/modules/Config.js
+++ b/前端/live-forum/modules/Config.js
@@ -13,9 +13,9 @@ var Config = Config || {}
// Config.API_BASE_URL = 'http://localhost:8080'
// Config.API_BASE_URL = 'https://liveforum.api.zpc-xy.com'
// 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' // 备用地址
@@ -45,8 +45,8 @@ Config.UPLOAD_CONFIG = {
videoMaxSize: 100 * 1024 * 1024, // 100MB
// COS域名(如果使用COS上传)
- // cosDomain: 'https://miaoyu-1308826010.cos.ap-shanghai.myqcloud.com'
- cosDomain: 'https://skzjmp-1377391978.cos.ap-nanjing.myqcloud.com'
+ cosDomain: 'https://miaoyu-1308826010.cos.ap-shanghai.myqcloud.com'
+ // cosDomain: 'https://skzjmp-1377391978.cos.ap-nanjing.myqcloud.com'
}
// 不同场景的上传配置预设