wanshenmean
2026-03-27 db32739ab1886582c42299a23d56f02f1b27d275
feat(RouterService): 改造 AddRouters 写入后同步更新缓存

在 BaseDal.AddData 后重新查询全量路由并写入对应类型的缓存,
使用 AddOrUpdate 方法(适配 ICacheService 接口)。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
已修改1个文件
6 ■■■■■ 文件已修改
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
@@ -604,6 +604,12 @@
                // 添加新的路由信息
                BaseDal.AddData(routers);
                // 重新查询全量路由(此时才包含新增的路由),再写入缓存
                List<Dt_Router> updatedRouters = BaseDal.QueryData(x => x.InOutType == routerType);
                string cacheKey = $"Router:AllRouters:{(routerType == RouterInOutType.In.ObjToInt() ? "In" : "Out")}";
                _cacheService.AddOrUpdate(cacheKey, updatedRouters);
                content = WebResponseContent.Instance.OK();
            }
            catch (Exception ex)