From d10686e70fc498b3a4ae8b63d06b32817ce422f3 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Tue, 1 Jul 2025 11:03:13 +1200 Subject: [PATCH] feat: add attachment model type definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add core attachment type with metadata fields for transaction files - Add GORM model for attachment with proper relationships - Include file information, upload timestamps, and soft deletion support 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- core/model/types/attachment.go | 20 ++++++++++++++++++++ models/attachment.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 core/model/types/attachment.go create mode 100644 models/attachment.go diff --git a/core/model/types/attachment.go b/core/model/types/attachment.go new file mode 100644 index 0000000..7f9c372 --- /dev/null +++ b/core/model/types/attachment.go @@ -0,0 +1,20 @@ +package types + +import ( + "time" +) + +type Attachment struct { + Id string `json:"id"` + TransactionId string `json:"transactionId"` + OrgId string `json:"orgId"` + UserId string `json:"userId"` + FileName string `json:"fileName"` + OriginalName string `json:"originalName"` + ContentType string `json:"contentType"` + FileSize int64 `json:"fileSize"` + FilePath string `json:"filePath"` + Description string `json:"description"` + Uploaded time.Time `json:"uploaded"` + Deleted bool `json:"deleted"` +} \ No newline at end of file diff --git a/models/attachment.go b/models/attachment.go new file mode 100644 index 0000000..28af0e1 --- /dev/null +++ b/models/attachment.go @@ -0,0 +1,28 @@ +package models + +import ( + "time" +) + +type Attachment struct { + ID []byte `gorm:"type:BINARY(16);primaryKey"` + TransactionID []byte `gorm:"column:transactionId;type:BINARY(16);not null"` + OrgID []byte `gorm:"column:orgId;type:BINARY(16);not null"` + UserID []byte `gorm:"column:userId;type:BINARY(16);not null"` + FileName string `gorm:"column:fileName;size:255;not null"` + OriginalName string `gorm:"column:originalName;size:255;not null"` + ContentType string `gorm:"column:contentType;size:100;not null"` + FileSize int64 `gorm:"column:fileSize;not null"` + FilePath string `gorm:"column:filePath;size:500;not null"` + Description string `gorm:"column:description;size:500"` + Uploaded time.Time `gorm:"column:uploaded;not null"` + Deleted bool `gorm:"column:deleted;default:false"` + + Transaction Transaction `gorm:"foreignKey:TransactionID"` + Org Org `gorm:"foreignKey:OrgID"` + User User `gorm:"foreignKey:UserID"` +} + +func (Attachment) TableName() string { + return "attachment" +} \ No newline at end of file