refactor(swap): FindTrade seam上提基类消除三子类重复

SwapDealService/SwapEodPositionService/SwapFlowEventService 三处 FindTrade(int)
签名和实现完全一致(DbContext.trade.Find),上提到 SwapTradeBaseService 基类。

核对确认可安全上提的只有 FindTrade(三者逐字一致):
- FindTradeExtend 不可上提: SwapEodPositionService 用 FirstOrDefault,
  SwapFlowEventService 用 First(找不到抛异常),语义不同。
- FindPositions 不可上提: SwapEodPositionService 含 IsInitial 持仓,
  SwapFlowEventService 排除 IsInitial + AsNoTracking,语义不同。

测试 stub override FindTrade 跨基类层级正常工作,C# virtual 多态不受影响。
SwapModule 171测试全绿,无回归。
This commit is contained in:
hjhan
2026-07-03 09:52:57 +08:00
parent b501e21904
commit 32bcf9beb9
4 changed files with 15 additions and 12 deletions
@@ -33,8 +33,7 @@ namespace YLErp.Modules.SwapModule
#region Seams refactor-swap-event-testable override DB/
protected virtual trade FindTrade(int swapTradeId)
=> DbContext.trade.Find(swapTradeId);
// FindTrade 已上提到基类 SwapTradeBaseService(三子类实现一致,消除重复)
protected virtual trade_extend FindTradeExtend(int swapTradeId)
=> DbContext.trade_extend.First(x => x.TradeId == swapTradeId);