2024-10-29 14:49:47 +00:00
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
|
|
|
"app-cloudep-trade-service/internal/domain"
|
|
|
|
"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 {
|
|
|
|
UID []string
|
|
|
|
Currency []string
|
|
|
|
Kind []domain.WalletType
|
|
|
|
}
|
|
|
|
|
|
|
|
type Option func() sqlx.SqlConn
|