Add multi-image support for task completions and documents
- Add TaskCompletionImage and DocumentImage models with one-to-many relationships
- Update admin panel to display images for completions and documents
- Add image arrays to API request/response DTOs
- Update repositories with Preload("Images") for eager loading
- Fix seed SQL execution to use raw SQL instead of prepared statements
- Fix table names in seed file (admin_users, push_notifications_*)
- Add comprehensive seed test data with 34 completion images and 24 document images
- Add subscription limitations admin feature with toggle
- Update admin sidebar with limitations link
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -37,12 +37,20 @@ type Document struct {
|
||||
MimeType string `gorm:"column:mime_type;size:100" json:"mime_type"`
|
||||
|
||||
// Warranty-specific fields
|
||||
PurchaseDate *time.Time `gorm:"column:purchase_date;type:date" json:"purchase_date"`
|
||||
ExpiryDate *time.Time `gorm:"column:expiry_date;type:date;index" json:"expiry_date"`
|
||||
PurchasePrice *decimal.Decimal `gorm:"column:purchase_price;type:decimal(10,2)" json:"purchase_price"`
|
||||
Vendor string `gorm:"column:vendor;size:200" json:"vendor"`
|
||||
SerialNumber string `gorm:"column:serial_number;size:100" json:"serial_number"`
|
||||
ModelNumber string `gorm:"column:model_number;size:100" json:"model_number"`
|
||||
PurchaseDate *time.Time `gorm:"column:purchase_date;type:date" json:"purchase_date"`
|
||||
ExpiryDate *time.Time `gorm:"column:expiry_date;type:date;index" json:"expiry_date"`
|
||||
PurchasePrice *decimal.Decimal `gorm:"column:purchase_price;type:decimal(10,2)" json:"purchase_price"`
|
||||
Vendor string `gorm:"column:vendor;size:200" json:"vendor"`
|
||||
SerialNumber string `gorm:"column:serial_number;size:100" json:"serial_number"`
|
||||
ModelNumber string `gorm:"column:model_number;size:100" json:"model_number"`
|
||||
|
||||
// Warranty provider contact fields
|
||||
Provider string `gorm:"column:provider;size:200" json:"provider"`
|
||||
ProviderContact string `gorm:"column:provider_contact;size:200" json:"provider_contact"`
|
||||
ClaimPhone string `gorm:"column:claim_phone;size:50" json:"claim_phone"`
|
||||
ClaimEmail string `gorm:"column:claim_email;size:200" json:"claim_email"`
|
||||
ClaimWebsite string `gorm:"column:claim_website;size:500" json:"claim_website"`
|
||||
Notes string `gorm:"column:notes;type:text" json:"notes"`
|
||||
|
||||
// Associated task (optional)
|
||||
TaskID *uint `gorm:"column:task_id;index" json:"task_id"`
|
||||
@@ -50,6 +58,9 @@ type Document struct {
|
||||
|
||||
// State
|
||||
IsActive bool `gorm:"column:is_active;default:true;index" json:"is_active"`
|
||||
|
||||
// Multiple images support
|
||||
Images []DocumentImage `gorm:"foreignKey:DocumentID" json:"images,omitempty"`
|
||||
}
|
||||
|
||||
// TableName returns the table name for GORM
|
||||
@@ -73,3 +84,16 @@ func (d *Document) IsWarrantyExpired() bool {
|
||||
}
|
||||
return time.Now().UTC().After(*d.ExpiryDate)
|
||||
}
|
||||
|
||||
// DocumentImage represents the task_documentimage table
|
||||
type DocumentImage struct {
|
||||
BaseModel
|
||||
DocumentID uint `gorm:"column:document_id;index;not null" json:"document_id"`
|
||||
ImageURL string `gorm:"column:image_url;size:500;not null" json:"image_url"`
|
||||
Caption string `gorm:"column:caption;size:255" json:"caption"`
|
||||
}
|
||||
|
||||
// TableName returns the table name for GORM
|
||||
func (DocumentImage) TableName() string {
|
||||
return "task_documentimage"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user