db

package
v0.0.0-...-cd46c0f Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 3 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        int64     `json:"id"`
	Owner     string    `json:"owner"`
	Balance   int64     `json:"balance"`
	Currency  string    `json:"currency"`
	CreatedAt time.Time `json:"createdAt"`
}

type CreateAccountParams

type CreateAccountParams struct {
	Owner    string `json:"owner"`
	Balance  int64  `json:"balance"`
	Currency string `json:"currency"`
}

type CreateEntryParams

type CreateEntryParams struct {
	AccountID int64 `json:"accountId"`
	Amount    int64 `json:"amount"`
}

type CreateTransferParams

type CreateTransferParams struct {
	FromAccountID int64 `json:"fromAccountId"`
	ToAccountID   int64 `json:"toAccountId"`
	Amount        int64 `json:"amount"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Entry

type Entry struct {
	ID        int64 `json:"id"`
	AccountID int64 `json:"accountId"`
	// 可以为正数或负数
	Amount    int64     `json:"amount"`
	CreatedAt time.Time `json:"createdAt"`
}

type GetAccountListParams

type GetAccountListParams struct {
	Limit  int64 `json:"limit"`
	Offset int64 `json:"offset"`
}

type GetEntryListParams

type GetEntryListParams struct {
	AccountID int64 `json:"accountId"`
	Limit     int64 `json:"limit"`
	Offset    int64 `json:"offset"`
}

type GetTransferListParams

type GetTransferListParams struct {
	FromAccountID int64 `json:"fromAccountId"`
	ToAccountID   int64 `json:"toAccountId"`
	Limit         int64 `json:"limit"`
	Offset        int64 `json:"offset"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateAccount

func (q *Queries) CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error)

func (*Queries) CreateEntry

func (q *Queries) CreateEntry(ctx context.Context, arg CreateEntryParams) (Entry, error)

func (*Queries) CreateTransfer

func (q *Queries) CreateTransfer(ctx context.Context, arg CreateTransferParams) (Transfer, error)

func (*Queries) DeleteAccount

func (q *Queries) DeleteAccount(ctx context.Context, id int64) error

func (*Queries) GetAccount

func (q *Queries) GetAccount(ctx context.Context, id int64) (Account, error)

func (*Queries) GetAccountList

func (q *Queries) GetAccountList(ctx context.Context, arg GetAccountListParams) ([]Account, error)

func (*Queries) GetEntry

func (q *Queries) GetEntry(ctx context.Context, id int64) (Entry, error)

func (*Queries) GetEntryList

func (q *Queries) GetEntryList(ctx context.Context, arg GetEntryListParams) ([]Entry, error)

func (*Queries) GetTransfer

func (q *Queries) GetTransfer(ctx context.Context, id int64) (Transfer, error)

func (*Queries) GetTransferList

func (q *Queries) GetTransferList(ctx context.Context, arg GetTransferListParams) ([]Transfer, error)

func (*Queries) UpdateAccount

func (q *Queries) UpdateAccount(ctx context.Context, arg UpdateAccountParams) (Account, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Transfer

type Transfer struct {
	ID            int64 `json:"id"`
	FromAccountID int64 `json:"fromAccountId"`
	ToAccountID   int64 `json:"toAccountId"`
	// 不能为负数
	Amount    int64     `json:"amount"`
	CreatedAt time.Time `json:"createdAt"`
}

type UpdateAccountParams

type UpdateAccountParams struct {
	Balance int64 `json:"balance"`
	ID      int64 `json:"id"`
}

Jump to

Keyboard shortcuts

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