同步失败时展示错误信息并增加后端状态日志
This commit is contained in:
@@ -123,6 +123,13 @@ func (s *StockSyncService) finishJob(ctx context.Context, jobID string, recordsC
|
||||
}
|
||||
if err := s.db.WithContext(ctx).Model(&models.StockSyncJob{}).Where("id = ?", jobID).Updates(updates).Error; err != nil {
|
||||
log.Printf("[stock sync] update job %s failed: %v", jobID, err)
|
||||
return
|
||||
}
|
||||
|
||||
var job models.StockSyncJob
|
||||
if err := s.db.WithContext(ctx).Where("id = ?", jobID).First(&job).Error; err == nil {
|
||||
log.Printf("[stock sync] job %s final state: status=%s, started_at=%v, finished_at=%v",
|
||||
jobID, job.Status, job.StartedAt, job.FinishedAt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -275,5 +275,8 @@ function formatSyncStatus(job: SyncJob): string {
|
||||
}
|
||||
}
|
||||
const statusText = job.status === 'success' ? '成功' : '失败'
|
||||
if (job.status === 'failed' && job.error_message) {
|
||||
return `${statusText} · ${timeStr} · ${job.error_message}`
|
||||
}
|
||||
return `${statusText} · ${timeStr}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user