tercul-backend/models/rights.go
Damir Mukimov 4957117cb6 Initial commit: Tercul Go project with comprehensive architecture
- Core Go application with GraphQL API using gqlgen
- Comprehensive data models for literary works, authors, translations
- Repository pattern with caching layer
- Authentication and authorization system
- Linguistics analysis capabilities with multiple adapters
- Vector search integration with Weaviate
- Docker containerization support
- Python data migration and analysis scripts
- Clean architecture with proper separation of concerns
- Production-ready configuration and middleware
- Proper .gitignore excluding vendor/, database files, and build artifacts
2025-08-13 07:42:32 +02:00

142 lines
4.8 KiB
Go

package models
import (
"time"
)
// Copyright represents a copyright that can be attached to any entity
type Copyright struct {
BaseModel
Identificator string `gorm:"size:100;not null"` // Rails: identificator field
Name string `gorm:"size:255;not null"`
Description string `gorm:"type:text"`
License string `gorm:"size:100"`
StartDate *time.Time
EndDate *time.Time
// Polymorphic relationships - can attach to any entity
Copyrightables []Copyrightable `gorm:"polymorphic:Copyrightable"`
// Translations for multilingual copyright messages
Translations []CopyrightTranslation `gorm:"foreignKey:CopyrightID"`
}
// Copyrightable represents a polymorphic relationship for copyrights
type Copyrightable struct {
BaseModel
CopyrightID uint
Copyright *Copyright `gorm:"foreignKey:CopyrightID"`
CopyrightableID uint // ID of the entity (work, translation, book, etc.)
CopyrightableType string // Type: "Work", "Translation", "Book", "Author", etc.
}
// CopyrightTranslation for multilingual copyright messages
type CopyrightTranslation struct {
BaseModel
CopyrightID uint
Copyright *Copyright `gorm:"foreignKey:CopyrightID"`
LanguageCode string `gorm:"size:10;not null"`
Message string `gorm:"type:text;not null"`
Description string `gorm:"type:text"`
}
// CopyrightClaimStatus represents the status of a copyright claim
type CopyrightClaimStatus string
const (
CopyrightClaimStatusPending CopyrightClaimStatus = "pending"
CopyrightClaimStatusApproved CopyrightClaimStatus = "approved"
CopyrightClaimStatusRejected CopyrightClaimStatus = "rejected"
)
// CopyrightClaim represents a copyright claim
type CopyrightClaim struct {
BaseModel
Details string `gorm:"type:text;not null"`
Status CopyrightClaimStatus `gorm:"size:50;default:'pending'"`
ClaimDate time.Time `gorm:"not null"`
Resolution string `gorm:"type:text"`
ResolvedAt *time.Time
UserID *uint
User *User `gorm:"foreignKey:UserID"`
// Polymorphic relationship - can attach to any entity
Claimables []Copyrightable `gorm:"polymorphic:Copyrightable"`
}
// MonetizationType represents the type of monetization
type MonetizationType string
const (
MonetizationTypeSubscription MonetizationType = "subscription"
MonetizationTypeOneTime MonetizationType = "one_time"
MonetizationTypeDonation MonetizationType = "donation"
MonetizationTypeAdvertisement MonetizationType = "advertisement"
MonetizationTypeLicensing MonetizationType = "licensing"
)
// MonetizationStatus represents the status of monetization
type MonetizationStatus string
const (
MonetizationStatusActive MonetizationStatus = "active"
MonetizationStatusInactive MonetizationStatus = "inactive"
MonetizationStatusPending MonetizationStatus = "pending"
)
// Monetizable represents a polymorphic relationship for monetization
type Monetizable struct {
BaseModel
MonetizationID uint
Monetization *Monetization `gorm:"foreignKey:MonetizationID"`
MonetizableID uint // ID of the entity (work, translation, book, etc.)
MonetizableType string // Type: "Work", "Translation", "Book", "Author", etc.
}
// Monetization represents monetization information for any entity
type Monetization struct {
BaseModel
Amount float64 `gorm:"type:decimal(10,2);default:0.0"`
Currency string `gorm:"size:3;default:'USD'"`
Type MonetizationType `gorm:"size:50"`
Status MonetizationStatus `gorm:"size:50;default:'active'"`
StartDate *time.Time
EndDate *time.Time
Language string `gorm:"size:50;not null"`
// Polymorphic relationships - can attach to any entity
Monetizables []Monetizable `gorm:"polymorphic:Monetizable"`
}
// License represents a standard license record
type License struct {
BaseModel
SPDXIdentifier string `gorm:"size:64;uniqueIndex"`
Name string `gorm:"size:255;not null"`
URL string `gorm:"size:512"`
Description string `gorm:"type:text"`
}
// ModerationFlag represents moderation flags for any entity
type ModerationFlag struct {
BaseModel
TargetType string `gorm:"size:50;not null"`
TargetID uint `gorm:"not null"`
Reason string `gorm:"size:255"`
Status string `gorm:"size:50;default:'open'"`
ReviewerID *uint
Reviewer *User `gorm:"foreignKey:ReviewerID"`
Notes string `gorm:"type:text"`
}
// AuditLog captures changes for governance and traceability
type AuditLog struct {
BaseModel
ActorID *uint
Actor *User `gorm:"foreignKey:ActorID"`
Action string `gorm:"size:50;not null"`
EntityType string `gorm:"size:50;not null"`
EntityID uint `gorm:"not null"`
Before JSONB `gorm:"type:jsonb;default:'{}'"`
After JSONB `gorm:"type:jsonb;default:'{}'"`
At time.Time `gorm:"autoCreateTime"`
}