models

package
v0.0.0-...-a8afb48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditLog

type AuditLog struct {
	Base
	UserID         uuid.UUID
	User           User
	OrganizationID uuid.UUID
	Organization   Organization
	Action         string `gorm:"not null"`
	Details        []byte `gorm:"type:jsonb"`
}

AuditLog represents a system audit event

type Base

type Base struct {
	ID        uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

Base contains common fields

func (*Base) BeforeCreate

func (base *Base) BeforeCreate(tx *gorm.DB) error

BeforeCreate is called before creating a record

type Organization

type Organization struct {
	Base
	Name  string `gorm:"not null"`
	Type  string `gorm:"not null"`
	Users []User `gorm:"many2many:user_organizations;"`
	Roles []Role
}

Organization represents a group of users

type Payment

type Payment struct {
	ID          string        `db:"id"`
	Status      PaymentStatus `db:"status"`
	Amount      string        `db:"amount"`
	Currency    string        `db:"currency"`
	Description string        `db:"description"`
	OrderID     string        `db:"order_id"`
	CustomerID  string        `db:"customer_id"`
	CreatedAt   time.Time     `db:"created_at"`
	PaidAt      *time.Time    `db:"paid_at"`
	ExpiresAt   *time.Time    `db:"expires_at"`
	RedirectURL string        `db:"redirect_url"`
	WebhookURL  string        `db:"webhook_url"`
	Metadata    []byte        `db:"metadata"` // JSON encoded
}

type PaymentFilter

type PaymentFilter struct {
	CustomerID string
	Status     PaymentStatus
	StartDate  time.Time
	EndDate    time.Time
}

type PaymentStatus

type PaymentStatus string
const (
	PaymentStatusPending   PaymentStatus = "pending"
	PaymentStatusPaid      PaymentStatus = "paid"
	PaymentStatusFailed    PaymentStatus = "failed"
	PaymentStatusCancelled PaymentStatus = "cancelled"
	PaymentStatusExpired   PaymentStatus = "expired"
)

type Permission

type Permission struct {
	Base
	Name        string `gorm:"not null"`
	Description string
	Roles       []Role `gorm:"many2many:role_permissions;"`
}

Permission represents an action that can be performed

type Role

type Role struct {
	Base
	Name           string `gorm:"not null"`
	Description    string
	OrganizationID uuid.UUID
	Organization   Organization
	Permissions    []Permission `gorm:"many2many:role_permissions;"`
}

Role represents a set of permissions

type User

type User struct {
	Base
	Email            string `gorm:"uniqueIndex;not null"`
	Name             string `gorm:"not null"`
	PasswordHash     string `gorm:"not null"`
	TwoFactorEnabled bool   `gorm:"default:false"`
	TwoFactorSecret  string
	Organizations    []Organization `gorm:"many2many:user_organizations;"`
}

User represents a system user

type VaultItem

type VaultItem struct {
	Base
	UserID         uuid.UUID
	User           User
	OrganizationID uuid.UUID
	Organization   Organization
	Type           string `gorm:"not null"`
	Name           string `gorm:"not null"`
	EncryptedData  string `gorm:"not null;type:text"`
}

VaultItem represents an encrypted item in a user's vault

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL