Documentation ¶
Index ¶
- type Account
- type GORMRepository
- func (r *GORMRepository) AddIdentity(userID string, identity domain.Identity) error
- func (r *GORMRepository) AdjustLedger(originalID string, adjustment domain.CreateLedgerRequest) error
- func (r *GORMRepository) AutoMigrate() error
- func (r *GORMRepository) CreateAccount(req domain.CreateAccountRequest) error
- func (r *GORMRepository) CreateLedger(req domain.CreateLedgerRequest) error
- func (r *GORMRepository) CreateUser(req domain.CreateUserRequest) (string, error)
- func (r *GORMRepository) DeactivateAccountByID(id string) error
- func (r *GORMRepository) DeactivateUserByID(id string) error
- func (r *GORMRepository) GetAccountByID(id string) (*domain.Account, error)
- func (r *GORMRepository) GetAccountsByUserID(userID string) ([]*domain.Account, error)
- func (r *GORMRepository) GetAllAccounts() ([]*domain.Account, error)
- func (r *GORMRepository) GetAllUsers() ([]*domain.User, error)
- func (r *GORMRepository) GetLedgerByID(id string) (*domain.Ledger, error)
- func (r *GORMRepository) GetLedgersByAccountID(accountID string) ([]*domain.Ledger, error)
- func (r *GORMRepository) GetUserByID(id string) (*domain.User, error)
- func (r *GORMRepository) GetUserByIdentity(provider domain.IdentityProvider, identifier string) (*domain.User, error)
- func (r *GORMRepository) UpdateAccount(req domain.UpdateAccountRequest) error
- func (r *GORMRepository) UpdateLedger(req domain.UpdateLedgerRequest) error
- func (r *GORMRepository) UpdateUser(req domain.UpdateUserRequest) error
- func (r *GORMRepository) VoidLedger(id string) error
- type Identity
- type Ledger
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID string `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"` CreatedAt time.Time UpdatedAt time.Time UserID string `gorm:"type:uuid;not null"` Name string `gorm:"type:varchar(255);not null"` Status string `gorm:"type:varchar(20);not null"` Currency string `gorm:"type:varchar(3);not null"` Balance decimal.Decimal `gorm:"type:decimal(20,2);not null"` Ledgers []Ledger }
Account represents the database model for an account
type GORMRepository ¶
type GORMRepository struct {
// contains filtered or unexported fields
}
GORMRepository represents a generic gorm repository which implements repository interface.
func NewGORMRepository ¶
func NewGORMRepository(db *gorm.DB) *GORMRepository
NewGORMRepository creates a new gorm repository.
func (*GORMRepository) AddIdentity ¶
func (r *GORMRepository) AddIdentity(userID string, identity domain.Identity) error
AddIdentity adds a new identity for a user
func (*GORMRepository) AdjustLedger ¶
func (r *GORMRepository) AdjustLedger(originalID string, adjustment domain.CreateLedgerRequest) error
AdjustLedger creates a new adjusted ledger entry based on an existing one
func (*GORMRepository) AutoMigrate ¶
func (r *GORMRepository) AutoMigrate() error
AutoMigrate migrates tables.
func (*GORMRepository) CreateAccount ¶
func (r *GORMRepository) CreateAccount(req domain.CreateAccountRequest) error
CreateAccount creates a new account
func (*GORMRepository) CreateLedger ¶
func (r *GORMRepository) CreateLedger(req domain.CreateLedgerRequest) error
CreateLedger creates a new ledger entry
func (*GORMRepository) CreateUser ¶
func (r *GORMRepository) CreateUser(req domain.CreateUserRequest) (string, error)
CreateUser creates a new user
func (*GORMRepository) DeactivateAccountByID ¶
func (r *GORMRepository) DeactivateAccountByID(id string) error
DeactivateAccountByID deactivates an account by setting its status to closed
func (*GORMRepository) DeactivateUserByID ¶
func (r *GORMRepository) DeactivateUserByID(id string) error
DeactivateUserByID deactivates a user by setting their disabled status to true
func (*GORMRepository) GetAccountByID ¶
func (r *GORMRepository) GetAccountByID(id string) (*domain.Account, error)
GetAccountByID retrieves an account by its ID
func (*GORMRepository) GetAccountsByUserID ¶
func (r *GORMRepository) GetAccountsByUserID(userID string) ([]*domain.Account, error)
GetAccountsByUserID retrieves all accounts for an user
func (*GORMRepository) GetAllAccounts ¶
func (r *GORMRepository) GetAllAccounts() ([]*domain.Account, error)
GetAllAccounts retrieves all accounts
func (*GORMRepository) GetAllUsers ¶
func (r *GORMRepository) GetAllUsers() ([]*domain.User, error)
GetAllUsers retrieves all users from the database
func (*GORMRepository) GetLedgerByID ¶
func (r *GORMRepository) GetLedgerByID(id string) (*domain.Ledger, error)
GetLedgerByID retrieves a ledger entry by its ID
func (*GORMRepository) GetLedgersByAccountID ¶
func (r *GORMRepository) GetLedgersByAccountID(accountID string) ([]*domain.Ledger, error)
GetLedgersByAccountID retrieves all ledger entries for a given account ID
func (*GORMRepository) GetUserByID ¶
func (r *GORMRepository) GetUserByID(id string) (*domain.User, error)
GetUserByID retrieves a user by their ID
func (*GORMRepository) GetUserByIdentity ¶
func (r *GORMRepository) GetUserByIdentity(provider domain.IdentityProvider, identifier string) (*domain.User, error)
GetUserByIdentity retrieves a user by their identity provider and identifier
func (*GORMRepository) UpdateAccount ¶
func (r *GORMRepository) UpdateAccount(req domain.UpdateAccountRequest) error
UpdateAccount updates an existing account
func (*GORMRepository) UpdateLedger ¶
func (r *GORMRepository) UpdateLedger(req domain.UpdateLedgerRequest) error
UpdateLedger updates an existing ledger entry
func (*GORMRepository) UpdateUser ¶
func (r *GORMRepository) UpdateUser(req domain.UpdateUserRequest) error
UpdateUser updates an existing user
func (*GORMRepository) VoidLedger ¶
func (r *GORMRepository) VoidLedger(id string) error
VoidLedger marks a ledger entry as voided
type Identity ¶
type Identity struct { ID int `gorm:"primary_key"` UserID string `gorm:"type:uuid;not null;uniqueIndex:idx_user_provider_identifier"` Provider string `gorm:"type:varchar(20);not null;uniqueIndex:idx_user_provider_identifier;uniqueIndex:idx_provider_identifier"` Identifier string `gorm:"type:varchar(255);not null;uniqueIndex:idx_user_provider_identifier;uniqueIndex:idx_provider_identifier"` Credential string `gorm:"type:varchar(255);not null"` LastUsedAt time.Time }
Identity represents the database model for an identity
type Ledger ¶
type Ledger struct { ID string `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"` CreatedAt time.Time UpdatedAt time.Time AccountID string `gorm:"type:uuid;not null"` Date time.Time `gorm:"not null"` Type string `gorm:"type:varchar(20);not null"` Amount decimal.Decimal `gorm:"type:decimal(20,2);not null"` Note string `gorm:"type:text"` IsAdjustment bool `gorm:"not null"` AdjustedFrom *string `gorm:"type:uuid"` IsVoided bool `gorm:"not null"` VoidedAt *time.Time Account Account }
Ledger represents the database model for a ledger entry
type User ¶
type User struct { ID string `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"` CreatedAt time.Time UpdatedAt time.Time Disabled bool `gorm:"not null;default:false"` Name string `gorm:"type:varchar(255);not null"` Nickname string `gorm:"type:varchar(255)"` }
User represents the database model for a user