package domain import ( "errors" "time" dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db" ) var ( ErrWalletIDDuplicate = errors.New("there already exists user id with wallet_type") ) type Wallet struct { ID int64 Balance Currency Currency IntCurrency IsWithdraw bool IsBettable bool IsTransferable bool IsActive bool UserID int64 Type WalletType UpdatedAt time.Time CreatedAt time.Time } type WalletFilter struct { IsActive ValidBool Query ValidString CreatedBefore ValidTime CreatedAfter ValidTime } type CustomerWallet struct { ID int64 RegularID int64 StaticID int64 CustomerID int64 } type GetCustomerWallet struct { ID int64 RegularID int64 RegularBalance Currency StaticID int64 StaticBalance Currency CustomerID int64 RegularIsActive bool StaticIsActive bool RegularUpdatedAt time.Time StaticUpdatedAt time.Time CreatedAt time.Time FirstName string LastName string PhoneNumber string } type BranchWallet struct { ID int64 Balance Currency IsActive bool Name string Location string BranchManagerID int64 CompanyID int64 IsSelfOwned bool UpdatedAt time.Time CreatedAt time.Time } type CreateWallet struct { IsWithdraw bool IsBettable bool IsTransferable bool UserID int64 Type WalletType } type CreateCustomerWallet struct { CustomerID int64 RegularWalletID int64 StaticWalletID int64 } type WalletType string const ( RegularWalletType WalletType = "regular_wallet" StaticWalletType WalletType = "static_wallet" BranchWalletType WalletType = "branch_wallet" CompanyWalletType WalletType = "company_wallet" ) func ConvertDBWallet(wallet dbgen.Wallet) Wallet { return Wallet{ ID: wallet.ID, Balance: Currency(wallet.Balance), IsWithdraw: wallet.IsWithdraw, IsBettable: wallet.IsBettable, IsTransferable: wallet.IsTransferable, IsActive: wallet.IsActive, UserID: wallet.UserID, Type: WalletType(wallet.Type), UpdatedAt: wallet.UpdatedAt.Time, CreatedAt: wallet.CreatedAt.Time, } } func ConvertCreateWallet(wallet CreateWallet) dbgen.CreateWalletParams { return dbgen.CreateWalletParams{ IsWithdraw: wallet.IsWithdraw, IsBettable: wallet.IsBettable, IsTransferable: wallet.IsTransferable, UserID: wallet.UserID, Type: string(wallet.Type), } } func ConvertDBCustomerWallet(customerWallet dbgen.CustomerWallet) CustomerWallet { return CustomerWallet{ ID: customerWallet.ID, RegularID: customerWallet.RegularWalletID, StaticID: customerWallet.StaticWalletID, CustomerID: customerWallet.CustomerID, } } func ConvertCreateCustomerWallet(customerWallet CreateCustomerWallet) dbgen.CreateCustomerWalletParams { return dbgen.CreateCustomerWalletParams{ CustomerID: customerWallet.CustomerID, RegularWalletID: customerWallet.RegularWalletID, StaticWalletID: customerWallet.StaticWalletID, } } func ConvertDBGetCustomerWallet(customerWallet dbgen.CustomerWalletDetail) GetCustomerWallet { return GetCustomerWallet{ ID: customerWallet.ID, RegularID: customerWallet.RegularID, RegularBalance: Currency(customerWallet.RegularBalance), StaticID: customerWallet.StaticID, StaticBalance: Currency(customerWallet.StaticBalance), CustomerID: customerWallet.CustomerID, RegularIsActive: customerWallet.RegularIsActive, StaticIsActive: customerWallet.StaticIsActive, RegularUpdatedAt: customerWallet.RegularUpdatedAt.Time, StaticUpdatedAt: customerWallet.StaticUpdatedAt.Time, CreatedAt: customerWallet.CreatedAt.Time, FirstName: customerWallet.FirstName, LastName: customerWallet.LastName, PhoneNumber: customerWallet.PhoneNumber.String, } }