71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package repository
|
|
|
|
import (
|
|
"code.30cm.net/digimon/app-cloudep-wallet-service/pkg/domain/entity"
|
|
"code.30cm.net/digimon/app-cloudep-wallet-service/pkg/domain/repository"
|
|
"context"
|
|
"database/sql"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type WalletRepositoryParam struct {
|
|
DB *gorm.DB `name:"dbM"`
|
|
}
|
|
|
|
type WalletRepository struct {
|
|
WalletRepositoryParam
|
|
}
|
|
|
|
func MustCategoryRepository(param WalletRepositoryParam) repository.WalletRepository {
|
|
return &WalletRepository{
|
|
param,
|
|
}
|
|
}
|
|
|
|
func (repo *WalletRepository) NewDB() *gorm.DB {
|
|
return repo.DB
|
|
}
|
|
|
|
func (repo *WalletRepository) Transaction(fn func(db *gorm.DB) error) error {
|
|
db := repo.DB.Begin(&sql.TxOptions{
|
|
Isolation: sql.LevelReadCommitted,
|
|
ReadOnly: false,
|
|
})
|
|
defer db.Rollback()
|
|
|
|
if err := fn(db); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := db.Commit().Error; err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (repo *WalletRepository) Session(uid, asset string) repository.UserWalletService {
|
|
//TODO implement me
|
|
panic("implement me")
|
|
}
|
|
|
|
func (repo *WalletRepository) SessionWithTx(db *gorm.DB, uid, asset string) repository.UserWalletService {
|
|
//TODO implement me
|
|
panic("implement me")
|
|
}
|
|
|
|
func (repo *WalletRepository) InitWallets(ctx context.Context, param []repository.Wallet) error {
|
|
//TODO implement me
|
|
panic("implement me")
|
|
}
|
|
|
|
func (repo *WalletRepository) QueryBalances(ctx context.Context, req repository.BalanceQuery) ([]entity.Wallet, error) {
|
|
//TODO implement me
|
|
panic("implement me")
|
|
}
|
|
|
|
func (repo *WalletRepository) QueryBalancesByUIDs(ctx context.Context, uids []string, req repository.BalanceQuery) ([]entity.Wallet, error) {
|
|
//TODO implement me
|
|
panic("implement me")
|
|
}
|