data

package
v0.0.0-...-f99db60 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package data 封装db方法

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	db.Querier
	// contains filtered or unexported fields
}

Store 提供封装的db方法和事务

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

NewStore 工厂方法 * sqlc配置中使用sql_package="pgx/v5",所以这里使用database/sql接口会冲突

func (*Store) TransferTx

func (s *Store) TransferTx(ctx context.Context, arg TransferTxParams) (TransferTxResults, error)

TransferTx 转账事务

type TransferTxParams

type TransferTxParams struct {
	FromAccountID int64 `json:"from_account_id"`
	ToAccountID   int64 `json:"to_account_id"`
	Amount        int64 `json:"amount"`
}

TransferTxParams 转账事务入参

type TransferTxResults

type TransferTxResults struct {
	Transfer    db.Transfer `json:"transfer"`
	FromAccount db.Account  `json:"from_account"`
	ToAccount   db.Account  `json:"to_account"`
	FromEntry   db.Entry    `json:"from_entry"`
	ToEntry     db.Entry    `json:"to_entry"`
}

TransferTxResults 转账事务结果

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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