app-cloudep-trade-service/internal/domain/repository/wallet.go

31 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-10-29 14:49:47 +00:00
package repository
import (
2024-10-31 04:05:22 +00:00
"app-cloudep-trade-service/internal/domain/wallet"
2024-10-29 14:49:47 +00:00
"app-cloudep-trade-service/internal/model"
"context"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
// WalletRepository 錢包基礎操作(可能有平台,使用者等多元的錢包)
type WalletRepository interface {
2024-10-30 11:13:56 +00:00
// Create 建立錢包(某 id 的可用,凍結,限制三種)
2024-10-29 14:49:47 +00:00
Create(ctx context.Context, uid, currency, brand string) ([]*model.Wallet, error)
2024-10-30 11:13:56 +00:00
// Balances 取得某個錢包的餘額
2024-10-29 14:49:47 +00:00
Balances(ctx context.Context, req BalanceReq) ([]model.Wallet, error)
// GetUserWalletOperator 取得使用者錢包操作看使否需要使用 transaction
GetUserWalletOperator(uid, currency string, opts ...Option) UserWalletOperator
2024-10-30 11:13:56 +00:00
// Transaction 把 tx 暴露出來
Transaction(ctx context.Context, fn func(tx sqlx.Session) error) error
2024-10-29 14:49:47 +00:00
}
// BalanceReq 取得全部的,因為一個人錢包種類的不會太多,故全撈
type BalanceReq struct {
2024-10-31 04:05:22 +00:00
UID []string
Currency []string
BalanceType []wallet.BalanceType
2024-10-29 14:49:47 +00:00
}
type Option func() sqlx.SqlConn