refactor(documents): split document models
This commit is contained in:
@@ -40,46 +40,3 @@ type SaDocument struct {
|
|||||||
func (SaDocument) TableName() string {
|
func (SaDocument) TableName() string {
|
||||||
return "sa_documents"
|
return "sa_documents"
|
||||||
}
|
}
|
||||||
|
|
||||||
type SaDocumentContent struct {
|
|
||||||
ID uint `gorm:"primaryKey"`
|
|
||||||
DocumentID uint `gorm:"uniqueIndex;not null"`
|
|
||||||
Markdown string `gorm:"type:text"`
|
|
||||||
CreatedAt time.Time
|
|
||||||
UpdatedAt time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
func (SaDocumentContent) TableName() string {
|
|
||||||
return "sa_document_contents"
|
|
||||||
}
|
|
||||||
|
|
||||||
type SaDocumentBlob struct {
|
|
||||||
ID uint `gorm:"primaryKey"`
|
|
||||||
DocumentID uint `gorm:"uniqueIndex;not null"`
|
|
||||||
StorageKey string `gorm:"size:64;uniqueIndex;not null"`
|
|
||||||
RelativePath string `gorm:"not null"`
|
|
||||||
OriginalName string `gorm:"not null"`
|
|
||||||
Checksum string `gorm:"size:64;not null"`
|
|
||||||
CreatedAt time.Time
|
|
||||||
UpdatedAt time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
func (SaDocumentBlob) TableName() string {
|
|
||||||
return "sa_document_blobs"
|
|
||||||
}
|
|
||||||
|
|
||||||
type SaDocumentShare struct {
|
|
||||||
ID uint `gorm:"primaryKey"`
|
|
||||||
Identity string `gorm:"type:char(36);uniqueIndex"`
|
|
||||||
DocumentID uint `gorm:"index;not null"`
|
|
||||||
DocumentIdentity string `gorm:"type:char(36);index"`
|
|
||||||
CreatedBy uint `gorm:"index;not null"`
|
|
||||||
TokenHash string `gorm:"size:64;uniqueIndex;not null"`
|
|
||||||
ExpiresAt time.Time `gorm:"index;not null"`
|
|
||||||
RevokedAt *time.Time `gorm:"index"`
|
|
||||||
CreatedAt time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
func (SaDocumentShare) TableName() string {
|
|
||||||
return "sa_document_shares"
|
|
||||||
}
|
|
||||||
|
|||||||
18
backend/internal/models/document_blob.go
Normal file
18
backend/internal/models/document_blob.go
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type SaDocumentBlob struct {
|
||||||
|
ID uint `gorm:"primaryKey"`
|
||||||
|
DocumentID uint `gorm:"uniqueIndex;not null"`
|
||||||
|
StorageKey string `gorm:"size:64;uniqueIndex;not null"`
|
||||||
|
RelativePath string `gorm:"not null"`
|
||||||
|
OriginalName string `gorm:"not null"`
|
||||||
|
Checksum string `gorm:"size:64;not null"`
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (SaDocumentBlob) TableName() string {
|
||||||
|
return "sa_document_blobs"
|
||||||
|
}
|
||||||
15
backend/internal/models/document_content.go
Normal file
15
backend/internal/models/document_content.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type SaDocumentContent struct {
|
||||||
|
ID uint `gorm:"primaryKey"`
|
||||||
|
DocumentID uint `gorm:"uniqueIndex;not null"`
|
||||||
|
Markdown string `gorm:"type:text"`
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (SaDocumentContent) TableName() string {
|
||||||
|
return "sa_document_contents"
|
||||||
|
}
|
||||||
19
backend/internal/models/document_share.go
Normal file
19
backend/internal/models/document_share.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type SaDocumentShare struct {
|
||||||
|
ID uint `gorm:"primaryKey"`
|
||||||
|
Identity string `gorm:"type:char(36);uniqueIndex"`
|
||||||
|
DocumentID uint `gorm:"index;not null"`
|
||||||
|
DocumentIdentity string `gorm:"type:char(36);index"`
|
||||||
|
CreatedBy uint `gorm:"index;not null"`
|
||||||
|
TokenHash string `gorm:"size:64;uniqueIndex;not null"`
|
||||||
|
ExpiresAt time.Time `gorm:"index;not null"`
|
||||||
|
RevokedAt *time.Time `gorm:"index"`
|
||||||
|
CreatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (SaDocumentShare) TableName() string {
|
||||||
|
return "sa_document_shares"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user