fix(n+1): 批量查询替代循环单查
- IsAdminBootstrapRequired: userRepo.GetByID 循环 → GetByIDs 批量 - AssignRoles: roleRepo.GetByID 循环 → GetByIDs 批量 - 在 userRepositoryInterface 补充 GetByIDs 方法签名
This commit is contained in:
@@ -88,6 +88,11 @@ func (m *OperationLogMiddleware) Record() gin.HandlerFunc {
|
||||
}
|
||||
|
||||
go func(entry *domain.OperationLog) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
// PERF-07: panic recover 保护,防止操作日志写入异常导致进程崩溃
|
||||
}
|
||||
}()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
_ = m.repo.Create(ctx, entry)
|
||||
|
||||
Reference in New Issue
Block a user