veza/veza-backend-api/internal/models/gear.go
senke 04c25aa24f Phase 2 stabilisation: code mort, Modal→Dialog, feature flags, tests, router split, Rust legacy
Bloc A - Code mort:
- Suppression Studio (components, views, features)
- Suppression gamification + services mock (projectService, storageService, gamificationService)
- Mise à jour Sidebar, Navbar, locales

Bloc B - Frontend:
- Suppression modal.tsx deprecated, Modal.stories (doublon Dialog)
- Feature flags: PLAYLIST_SEARCH, PLAYLIST_RECOMMENDATIONS, ROLE_MANAGEMENT = true
- Suppression 19 tests orphelins, retrait exclusions vitest.config

Bloc C - Backend:
- Extraction routes_auth.go depuis router.go

Bloc D - Rust:
- Suppression security_legacy.rs (code mort, patterns déjà dans security/)
2026-02-14 17:23:32 +01:00

53 lines
2.8 KiB
Go

package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// GearItem represents a user's equipment/gear in their inventory
type GearItem struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id" db:"id"`
UserID uuid.UUID `gorm:"type:uuid;not null" json:"user_id" db:"user_id"`
Name string `gorm:"size:200;not null" json:"name" db:"name"`
Category string `gorm:"size:100" json:"category" db:"category"`
Brand string `gorm:"size:200" json:"brand" db:"brand"`
Model string `gorm:"size:200" json:"model" db:"model"`
SerialNumber string `gorm:"size:100" json:"serialNumber" db:"serial_number"`
Image string `gorm:"size:500" json:"image" db:"image"`
Images []string `gorm:"type:jsonb;default:'[]'" json:"images" db:"images"`
Status string `gorm:"size:50;default:'Active'" json:"status" db:"status"`
Condition string `gorm:"size:50;default:'Good'" json:"condition" db:"condition"`
PurchaseDate *time.Time `json:"purchaseDate" db:"purchase_date"`
PurchasePrice float64 `gorm:"type:decimal(12,2);default:0" json:"purchasePrice" db:"purchase_price"`
Currency string `gorm:"size:3;default:'USD'" json:"currency" db:"currency"`
Vendor string `gorm:"size:200" json:"vendor" db:"vendor"`
OrderNumber string `gorm:"size:100" json:"orderNumber" db:"order_number"`
WarrantyExpire *time.Time `json:"warrantyExpire" db:"warranty_expire"`
WarrantyType string `gorm:"size:50" json:"warrantyType" db:"warranty_type"`
SupportContact string `gorm:"size:200" json:"supportContact" db:"support_contact"`
Specs map[string]interface{} `gorm:"type:jsonb;default:'{}'" json:"specs" db:"specs"`
Notes string `gorm:"type:text" json:"notes" db:"notes"`
Documents []map[string]interface{} `gorm:"type:jsonb;default:'[]'" json:"documents" db:"documents"`
MaintenanceHistory []map[string]interface{} `gorm:"type:jsonb;default:'[]'" json:"maintenanceHistory" db:"maintenance_history"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" db:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" db:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" db:"deleted_at"`
User *User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE" json:"-"`
}
// TableName defines the table name for GORM
func (GearItem) TableName() string {
return "gear_items"
}
// BeforeCreate hook for GORM to generate UUID
func (m *GearItem) BeforeCreate(tx *gorm.DB) error {
if m.ID == uuid.Nil {
m.ID = uuid.New()
}
return nil
}