Files
aura-crm/production/backend/internal/pcbuilder/spec.go
T

56 lines
2.7 KiB
Go

// Package pcbuilder is the compatibility-checking side of the PC
// configurator (like DNS-shop/Regard's component picker) — the catalog
// itself is just internal/inventory's existing retail parts, tagged with
// pc_component_type/pc_spec (see migrations/052_pc_builder.sql's doc
// comment for why a JSONB spec instead of per-type tables). This package
// owns the one thing the parts catalog doesn't know: which combinations of
// tagged parts actually fit together.
package pcbuilder
// Spec is deliberately one flat sparse struct covering every component
// type's attributes rather than a type per component — the eight types
// share almost no fields, so a sum-type/interface split would buy nothing
// a shared struct with omitempty doesn't already give, and one shape is
// simpler for internal/inventory's PartModal.jsx to serialize regardless
// of which type is currently selected there.
type Spec struct {
// cpu: Socket, TDPWatts
// motherboard: Socket, RAMType, MaxRAMGB, FormFactor
// ram: RAMType, RAMCapacityGB
// gpu: TDPWatts, LengthMM
// psu: WattageW
// case: FormFactorsSupported, MaxGPULengthMM, MaxCoolerHeightMM
// cooler: SocketsSupported, HeightMM
// storage: Interface
Socket string `json:"socket,omitempty"`
TDPWatts int `json:"tdp_watts,omitempty"`
RAMType string `json:"ram_type,omitempty"`
MaxRAMGB int `json:"max_ram_gb,omitempty"`
RAMCapacityGB int `json:"ram_capacity_gb,omitempty"`
FormFactor string `json:"form_factor,omitempty"`
FormFactorsSupported []string `json:"form_factors_supported,omitempty"`
LengthMM int `json:"length_mm,omitempty"`
MaxGPULengthMM int `json:"max_gpu_length_mm,omitempty"`
HeightMM int `json:"height_mm,omitempty"`
MaxCoolerHeightMM int `json:"max_cooler_height_mm,omitempty"`
SocketsSupported []string `json:"sockets_supported,omitempty"`
WattageW int `json:"wattage_w,omitempty"`
Interface string `json:"interface,omitempty"`
}
// AllTypes is the fixed slot list a build fills — one part per type at
// most (no "two GPUs" concept here), same order the pickers render in on
// both the public and CRM pages.
var AllTypes = []string{"cpu", "motherboard", "ram", "gpu", "psu", "case", "cooler", "storage"}
var TypeLabels = map[string]string{
"cpu": "Процессор",
"motherboard": "Материнская плата",
"ram": "Оперативная память",
"gpu": "Видеокарта",
"psu": "Блок питания",
"case": "Корпус",
"cooler": "Охлаждение",
"storage": "Накопитель",
}