- Migrations 026-028: qt_partnumber_books + qt_partnumber_book_items tables; is_primary_pn on lot_partnumbers; version VARCHAR(30); description VARCHAR(10000) on items (required by QuoteForge sync) - Service: CreateSnapshot expands bundles, filters empty lot_name and ignored PNs, copies description, activates new book atomically, applies GFS retention (7d/5w/12m/10y) with explicit item deletion - Task type TaskTypePartnumberBookCreate; handlers ListPartnumberBooks and CreatePartnumberBook; routes GET/POST /api/admin/pricing/partnumber-books - UI: snapshot list + "Создать снапшот сопоставлений" button with progress polling on /vendor-mappings page - Bible: history, api, background-tasks, vendor-mapping updated Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package tasks
|
|
|
|
import "time"
|
|
|
|
// TaskStatus represents the current status of a task
|
|
type TaskStatus string
|
|
|
|
const (
|
|
TaskStatusRunning TaskStatus = "running"
|
|
TaskStatusCompleted TaskStatus = "completed"
|
|
TaskStatusError TaskStatus = "error"
|
|
)
|
|
|
|
// TaskType represents the type of background task
|
|
type TaskType string
|
|
|
|
const (
|
|
TaskTypeRecalculate TaskType = "recalculate"
|
|
TaskTypeStockImport TaskType = "stock_import"
|
|
TaskTypePricelistCreate TaskType = "pricelist_create"
|
|
TaskTypePartnumberBookCreate TaskType = "partnumber_book_create"
|
|
)
|
|
|
|
// Task represents a background task with progress tracking
|
|
type Task struct {
|
|
ID string `json:"id"`
|
|
Type TaskType `json:"type"`
|
|
Status TaskStatus `json:"status"`
|
|
Progress int `json:"progress"` // 0-100
|
|
Message string `json:"message"`
|
|
Result map[string]interface{} `json:"result,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
DoneAt *time.Time `json:"done_at,omitempty"`
|
|
}
|