domain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAccountConflictOnSave = errors.New("conflic when saving an account: the account version is different from the persisted account")

Functions

This section is empty.

Types

type Account

type Account struct {
	// contains filtered or unexported fields
}

Account is a user account

func CreateAccountFromRepository

func CreateAccountFromRepository(id string, telegramID TelegramID, version uint) *Account

CreateAccountFromRepository map a repository model Account to a domain model Account.

func NewAccount

func NewAccount(id string, telegramID TelegramID) (*Account, error)

NewAccount instantiate a new user account in the application.

func (Account) ID

func (a Account) ID() string

ID is the unique identifier of an account

func (Account) TelegramID

func (a Account) TelegramID() TelegramID

TelegramID is the telegram account ID related to the current account.

func (Account) Version

func (a Account) Version() uint

Version is a util property to ensure the optimistic locking of the account.

type AccountRepository

type AccountRepository interface {
	// Save create or update an account in the repository. Verify optimistic locking.
	Save(ctx context.Context, account *Account) error
	// GetOneByTgID returns an account by a TelegramID.
	GetOneByTgID(ctx context.Context, tgID TelegramID) (*Account, error)
	// GetOneByID returns an account by an ID.
	GetOneByID(ctx context.Context, id string) (*Account, error)
}

AccountRepository is an implementation of the repository pattern for the Account entity.

type TelegramID

type TelegramID struct {
	// contains filtered or unexported fields
}

TelegramID represent a Telegram account ID.

func NewTelegramID

func NewTelegramID(val int64) (TelegramID, error)

func (TelegramID) String

func (t TelegramID) String() string

String returns the account value as string.

func (TelegramID) Value

func (t TelegramID) Value() int64

Value returns the account value as int64.

Jump to

Keyboard shortcuts

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