feat: синхронизировать книги партномеров вместе с прайслистами
PullPartnumberBooks вызывается автоматически после каждой синхронизации прайслистов — в фоновом воркере, при ручном триггере /api/sync/pricelists и при полной синхронизации /api/sync/all. Отдельная кнопка «Синхронизировать» на странице Партномера удалена. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -232,6 +232,10 @@ func (h *SyncHandler) SyncPricelists(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
h.localDB.AppendSyncLog("pricelists", "ok", "", synced, startTime, time.Since(startTime).Milliseconds())
|
h.localDB.AppendSyncLog("pricelists", "ok", "", synced, startTime, time.Since(startTime).Milliseconds())
|
||||||
|
|
||||||
|
if _, err := h.syncService.PullPartnumberBooks(); err != nil {
|
||||||
|
slog.Warn("partnumber books pull failed after pricelist sync", "error", err)
|
||||||
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, SyncResultResponse{
|
c.JSON(http.StatusOK, SyncResultResponse{
|
||||||
Success: true,
|
Success: true,
|
||||||
Message: "Pricelists synced successfully",
|
Message: "Pricelists synced successfully",
|
||||||
@@ -352,6 +356,10 @@ func (h *SyncHandler) SyncAll(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
h.localDB.AppendSyncLog("pricelists", "ok", "", pricelistsSynced, plNow, time.Since(plNow).Milliseconds())
|
h.localDB.AppendSyncLog("pricelists", "ok", "", pricelistsSynced, plNow, time.Since(plNow).Milliseconds())
|
||||||
|
|
||||||
|
if _, err := h.syncService.PullPartnumberBooks(); err != nil {
|
||||||
|
slog.Warn("partnumber books pull failed during full sync", "error", err)
|
||||||
|
}
|
||||||
|
|
||||||
projectsResult, err := h.syncService.ImportProjectsToLocal()
|
projectsResult, err := h.syncService.ImportProjectsToLocal()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("project import failed during full sync", "error", err)
|
slog.Error("project import failed during full sync", "error", err)
|
||||||
|
|||||||
@@ -100,5 +100,10 @@ func (w *Worker) runSync() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pull partnumber books together with pricelists
|
||||||
|
if _, err := w.service.PullPartnumberBooks(); err != nil {
|
||||||
|
w.logger.Warn("background sync: failed to pull partnumber books", "error", err)
|
||||||
|
}
|
||||||
|
|
||||||
w.logger.Info("background sync cycle completed")
|
w.logger.Info("background sync cycle completed")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,20 +22,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="summary-empty" class="hidden bg-yellow-50 border border-yellow-200 rounded-lg p-4 text-sm text-yellow-800">
|
<div id="summary-empty" class="hidden bg-yellow-50 border border-yellow-200 rounded-lg p-4 text-sm text-yellow-800">
|
||||||
Нет активного листа сопоставлений. Нажмите «Синхронизировать» для загрузки с сервера.
|
Нет активного листа сопоставлений. Книги загружаются автоматически вместе с прайслистами.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- All books list (collapsed by default) -->
|
<!-- All books list (collapsed by default) -->
|
||||||
<div class="bg-white rounded-lg shadow overflow-hidden">
|
<div class="bg-white rounded-lg shadow overflow-hidden">
|
||||||
<!-- Header row — always visible -->
|
<!-- Header row — always visible -->
|
||||||
<div class="px-4 py-3 flex items-center justify-between">
|
<div class="px-4 py-3">
|
||||||
<button onclick="toggleBooksSection()" class="flex items-center gap-2 text-sm font-semibold text-gray-800 hover:text-gray-600 select-none">
|
<button onclick="toggleBooksSection()" class="flex items-center gap-2 text-sm font-semibold text-gray-800 hover:text-gray-600 select-none">
|
||||||
<svg id="books-chevron" class="w-4 h-4 text-gray-400 transition-transform duration-150" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/></svg>
|
<svg id="books-chevron" class="w-4 h-4 text-gray-400 transition-transform duration-150" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/></svg>
|
||||||
Снимки сопоставлений (Partnumber Books)
|
Снимки сопоставлений (Partnumber Books)
|
||||||
</button>
|
</button>
|
||||||
<button onclick="syncPartnumberBooks()" class="px-4 py-2 bg-orange-500 text-white rounded hover:bg-orange-600 text-sm font-medium">
|
|
||||||
Синхронизировать
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Collapsible body -->
|
<!-- Collapsible body -->
|
||||||
<div id="books-section-body" class="hidden border-t">
|
<div id="books-section-body" class="hidden border-t">
|
||||||
|
|||||||
Reference in New Issue
Block a user