Files
Novault-backend/internal/models/transaction_image.go
2026-01-25 21:59:00 +08:00

42 lines
1.3 KiB
Go

package models
import (
"time"
)
// TransactionImage represents an image attachment for a transaction
// Feature: accounting-feature-upgrade
// Validates: Requirements 4.1-4.8
type TransactionImage struct {
ID uint `gorm:"primarykey" json:"id"`
TransactionID uint `gorm:"not null;index" json:"transaction_id"`
FilePath string `gorm:"size:255;not null" json:"file_path"`
FileName string `gorm:"size:100" json:"file_name"`
FileSize int64 `json:"file_size"`
MimeType string `gorm:"size:50" json:"mime_type"`
CreatedAt time.Time `json:"created_at"`
// Relationships
Transaction Transaction `gorm:"foreignKey:TransactionID" json:"-"`
}
// TableName specifies the table name for TransactionImage
func (TransactionImage) TableName() string {
return "transaction_images"
}
// Image attachment constraints
const (
// MaxImagesPerTransaction limits the number of images per transaction
// Validates: Requirements 4.9
MaxImagesPerTransaction = 9
// MaxImageSizeBytes limits the size of each image to 10MB
// Validates: Requirements 4.10
MaxImageSizeBytes = 10 * 1024 * 1024 // 10MB
// AllowedImageTypes specifies the supported image formats
// Validates: Requirements 4.11
AllowedImageTypes = "image/jpeg,image/png,image/heic"
)