将账号、认证、管理员、分析、自动化、卡券、聊天、商品、关键词、设置和订单能力迁移到 application 与 adapter,删除 Server 内对应的旧仓储和业务服务实现,并收紧架构检查。 完善批量发布与订单刷新生命周期、凭证写回、账号任务补偿、订单 reconciliation、通知和敏感数据边界;补充正常、失败、取消、并发、越权及多方言回归测试,并修正 MySQL 延迟任务表的 InnoDB 配置。 修复空卡密响应为 null 时前端加载失败的问题,重建嵌入式前端资产;重写重构总计划,清除历史流水并明确阶段 1 至 10 各对应一次完整迭代和一个 PR。 验证:make check;make test-server-race;npm test/typecheck/comments:check/build;Docker SQLite/MySQL 8.4/PostgreSQL 17 TestMultiDB_*。
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
accountapp "xianyu-go/internal/application/account"
|
|
)
|
|
|
|
const (
|
|
// loginMethodPassword 保留 Server 内部调用方使用的账号密码登录方式别名。
|
|
loginMethodPassword = accountapp.LoginMethodPassword
|
|
// loginMethodQRScan 保留 Server 内部调用方使用的扫码登录方式别名。
|
|
loginMethodQRScan = accountapp.LoginMethodQRScan
|
|
)
|
|
|
|
// markSuccessfulLogin 将 Server 登录成功事件交给账号应用服务审计,不在 HTTP 层组装数据库模型。
|
|
func (s *Server) markSuccessfulLogin(ctx context.Context, cookieID string, userID int64, method, message string) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
// auditService 保存应用层登录审计服务;它拥有归一化、启用和日志写入编排。
|
|
auditService := s.loginAuditApplication()
|
|
if auditService == nil {
|
|
return
|
|
}
|
|
// auditErr 保存审计服务返回的基础设施错误;登录主流程保持旧的成功后续行为并仅记录告警。
|
|
auditErr := auditService.RecordSuccessfulLogin(ctx, accountapp.SuccessfulLoginInput{
|
|
AccountID: cookieID,
|
|
UserID: userID,
|
|
Method: method,
|
|
Message: message,
|
|
})
|
|
if auditErr != nil && s.Logger != nil {
|
|
s.Logger.Warn("记录账号登录审计失败", "cookie_id", cookieID, "method", method, "err", auditErr)
|
|
}
|
|
}
|