Documentation ¶
Index ¶
- type Interface
- type Mem
- func (m *Mem) CreateUser(u models.User) error
- func (m *Mem) LoginBank(userId string, password string) (user models.User, err error)
- func (m *Mem) NewMem() Mem
- func (m *Mem) SaveMoney(money float64, userId string) error
- func (m *Mem) Transfer(money float64, outUserId string, inUserId string) error
- func (m *Mem) WithdrawMoney(money float64, userId string) error
- type MySQLStorage
- func (m *MySQLStorage) CreateUser(user models.User) (int64, error)
- func (m *MySQLStorage) LoginBank(userId string, password string) (models.User, error)
- func (m *MySQLStorage) QueryUser(userId string) (models.User, error)
- func (m *MySQLStorage) SaveMoney(money float64, userID string) error
- func (m *MySQLStorage) Transfer(money float64, outUserId string, inUserId string) error
- func (m *MySQLStorage) WithdrawMoney(money float64, userId string) error
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 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) 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
Click to show internal directories.
Click to hide internal directories.