storage

package
v0.0.0-...-276c0fd Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	CreateUser(user models.User) (int64, error)                      //创建用户
	LoginBank(userId string, password string) (models.User, error)   //登录
	SaveMoney(money float64, userId string) error                    //存钱
	WithdrawMoney(money float64, userId string) error                //取钱
	Transfer(money float64, outUserId string, inUserId string) error //转账
	QueryUser(userId string) (models.User, error)                    //查询用户信息

}

type Mem

type Mem struct {
	Users map[string]models.User
}

func (*Mem) CreateUser

func (m *Mem) CreateUser(u models.User) error

func (*Mem) LoginBank

func (m *Mem) LoginBank(userId string, password string) (user models.User, err error)

func (*Mem) NewMem

func (m *Mem) NewMem() Mem

func (*Mem) SaveMoney

func (m *Mem) SaveMoney(money float64, userId string) error

func (*Mem) Transfer

func (m *Mem) Transfer(money float64, outUserId string, inUserId string) error

func (*Mem) WithdrawMoney

func (m *Mem) WithdrawMoney(money float64, userId string) error

type MySQLStorage

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

func NewMySQLStorage

func NewMySQLStorage(conf conf.MySQLConfig) (*MySQLStorage, error)

func (*MySQLStorage) CreateUser

func (m *MySQLStorage) CreateUser(user models.User) (int64, error)

func (*MySQLStorage) LoginBank

func (m *MySQLStorage) LoginBank(userId string, password string) (models.User, error)

func (*MySQLStorage) QueryUser

func (m *MySQLStorage) QueryUser(userId string) (models.User, error)

func (*MySQLStorage) SaveMoney

func (m *MySQLStorage) SaveMoney(money float64, userID string) error

func (*MySQLStorage) Transfer

func (m *MySQLStorage) Transfer(money float64, outUserId string, inUserId string) error

func (*MySQLStorage) WithdrawMoney

func (m *MySQLStorage) WithdrawMoney(money float64, userId string) error

Jump to

Keyboard shortcuts

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