58 lines
2.2 KiB
Go
58 lines
2.2 KiB
Go
package repositories
|
|
|
|
import (
|
|
"context"
|
|
"tyapi-server/internal/domains/finance/entities"
|
|
"tyapi-server/internal/domains/finance/repositories/queries"
|
|
"tyapi-server/internal/shared/interfaces"
|
|
)
|
|
|
|
// FinanceStats 财务统计信息
|
|
type FinanceStats struct {
|
|
TotalWallets int64
|
|
ActiveWallets int64
|
|
TotalBalance string
|
|
TodayTransactions int64
|
|
}
|
|
|
|
// WalletRepository 钱包仓储接口
|
|
type WalletRepository interface {
|
|
interfaces.Repository[entities.Wallet]
|
|
|
|
// 基础查询 - 直接使用实体
|
|
GetByUserID(ctx context.Context, userID string) (*entities.Wallet, error)
|
|
GetByWalletAddress(ctx context.Context, walletAddress string) (*entities.Wallet, error)
|
|
GetByWalletType(ctx context.Context, userID string, walletType string) (*entities.Wallet, error)
|
|
|
|
// 复杂查询 - 使用查询参数
|
|
ListWallets(ctx context.Context, query *queries.ListWalletsQuery) ([]*entities.Wallet, int64, error)
|
|
|
|
// 业务操作
|
|
UpdateBalance(ctx context.Context, walletID string, balance string) error
|
|
AddBalance(ctx context.Context, walletID string, amount string) error
|
|
SubtractBalance(ctx context.Context, walletID string, amount string) error
|
|
ActivateWallet(ctx context.Context, walletID string) error
|
|
DeactivateWallet(ctx context.Context, walletID string) error
|
|
|
|
// 统计信息
|
|
GetStats(ctx context.Context) (*FinanceStats, error)
|
|
GetUserWalletStats(ctx context.Context, userID string) (*FinanceStats, error)
|
|
}
|
|
|
|
// UserSecretsRepository 用户密钥仓储接口
|
|
type UserSecretsRepository interface {
|
|
interfaces.Repository[entities.UserSecrets]
|
|
|
|
// 基础查询 - 直接使用实体
|
|
GetByUserID(ctx context.Context, userID string) (*entities.UserSecrets, error)
|
|
GetBySecretType(ctx context.Context, userID string, secretType string) (*entities.UserSecrets, error)
|
|
|
|
// 复杂查询 - 使用查询参数
|
|
ListUserSecrets(ctx context.Context, query *queries.ListUserSecretsQuery) ([]*entities.UserSecrets, int64, error)
|
|
|
|
// 业务操作
|
|
UpdateSecret(ctx context.Context, userID string, secretType string, secretValue string) error
|
|
DeleteSecret(ctx context.Context, userID string, secretType string) error
|
|
ValidateSecret(ctx context.Context, userID string, secretType string, secretValue string) (bool, error)
|
|
}
|