veza/veza-backend-api/internal/models/gear_document.go
senke a3624ce4b3 feat(v0.802): frontend Cloud/Gear, MSW, docs, scope v0.803, archive
- Cloud: CloudFileVersions, CloudShareModal, versions/share in CloudView
- Gear: GearDocumentsTab, GearRepairsTab, warranty badge, initialTab
- MSW: cloud versions/share, gear documents/repairs, tags suggest
- Stories: CloudFileVersions, CloudShareModal, GearDetailModal variants
- gearService: listDocuments, uploadDocument, deleteDocument, listRepairs, createRepair, deleteRepair
- cloudService: listVersions, restoreVersion, shareFile, getSharedFile
- gear_warranty_notifier: 24h ticker, notifications for expiring warranty
- tag_handler_test: unit tests
- docs: API_REFERENCE, CHANGELOG, PROJECT_STATE, FEATURE_STATUS v0.802
- SCOPE_CONTROL, .cursorrules: scope v0.803
- archive: V0_802_RELEASE_SCOPE, RETROSPECTIVE_V0802
2026-02-25 14:00:58 +01:00

31 lines
854 B
Go

package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// GearDocument stores a document (invoice, manual, etc.) for a gear item
type GearDocument struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
GearID uuid.UUID `gorm:"type:uuid;not null" json:"gear_id"`
Type string `gorm:"size:50;not null;default:'invoice'" json:"type"`
StorageKey string `gorm:"type:text;not null" json:"storage_key"`
Filename string `gorm:"size:255;not null" json:"filename"`
UploadedAt time.Time `gorm:"autoCreateTime" json:"uploaded_at"`
Gear *GearItem `gorm:"foreignKey:GearID;constraint:OnDelete:CASCADE" json:"-"`
}
func (GearDocument) TableName() string {
return "gear_documents"
}
func (m *GearDocument) BeforeCreate(tx *gorm.DB) error {
if m.ID == uuid.Nil {
m.ID = uuid.New()
}
return nil
}