api

package
v0.0.0-...-9e17550 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Id       int    `json:"id"`
	Name     string `json:"name"`
	Email    string `json:"email"`
	TeamID   int    `json:"team_id"`
	TeamName string `json:"team_name"`
}

type AccountRepository

type AccountRepository interface {
	GetAccount(id int) (*Account, error)
	ListAccounts() ([]*Account, error)
	CreateAccount(a *Account) error
	DeleteAccount(id int) error
}

AccountService makes use of the AccountRepository interface to interact with the storage implentation. The actual implementation can be written to use an RDB, for example, or could also be mocked out for unit testing purposes.

type AccountService

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

func NewAccountService

func NewAccountService(r AccountRepository) AccountService

Takes an AccountRepository implementation and returns an AccountService.

func (*AccountService) CreateAccount

func (s *AccountService) CreateAccount(a *Account) error

Creates a new account.

func (*AccountService) DeleteAccount

func (s *AccountService) DeleteAccount(id int) error

Deletes an account by ID.

func (*AccountService) GetAccount

func (s *AccountService) GetAccount(id int) (*Account, error)

Gets an account by ID.

func (*AccountService) GetAccountUppercase

func (s *AccountService) GetAccountUppercase(id int) (*Account, error)

Gets an account from the repository and coverts all of its fields to uppercase before returning. As converting to uppercase is not infrastructure dependent, the conversion is performed in the service layer.

func (*AccountService) ListAccounts

func (s *AccountService) ListAccounts() ([]*Account, error)

Lists all accounts.

Directories

Path Synopsis
storage

Jump to

Keyboard shortcuts

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