feat: update service
This commit is contained in:
parent
2f5b04de29
commit
4cb6faefdc
|
@ -0,0 +1,18 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.30cm.net/digimon/app-cloudep-wallet-service/pkg/domain/entity"
|
||||||
|
"github.com/shopspring/decimal"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewUserWallet(db *gorm.DB, uid, crypto string) repository.UserWallet {
|
||||||
|
return &userWallet{
|
||||||
|
db: db,
|
||||||
|
uid: uid,
|
||||||
|
crypto: crypto,
|
||||||
|
|
||||||
|
localWalletBalance: make(map[domain.WalletType]entity.Wallet, len(domain.WalletAllType)),
|
||||||
|
localOrderBalance: make(map[int64]decimal.Decimal, len(domain.WalletAllType)),
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
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")
|
||||||
|
}
|
Loading…
Reference in New Issue