Merge branch 'main' into auth

This commit is contained in:
Samuel Tariku 2025-04-12 16:08:08 +03:00
commit b42b056e30
24 changed files with 615 additions and 535 deletions

View File

@ -2770,7 +2770,43 @@ const docTemplate = `{
} }
}, },
"handlers.CreateBetReq": { "handlers.CreateBetReq": {
"type": "object" "type": "object",
"properties": {
"amount": {
"type": "number",
"example": 100
},
"full_name": {
"type": "string",
"example": "John"
},
"is_shop_bet": {
"type": "boolean",
"example": false
},
"outcomes": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.BetOutcome"
}
},
"phone_number": {
"type": "string",
"example": "1234567890"
},
"status": {
"allOf": [
{
"$ref": "#/definitions/domain.BetStatus"
}
],
"example": 1
},
"total_odds": {
"type": "number",
"example": 4.22
}
}
}, },
"handlers.CreateBranchOperationReq": { "handlers.CreateBranchOperationReq": {
"type": "object", "type": "object",
@ -3027,17 +3063,6 @@ const docTemplate = `{
} }
} }
}, },
"handlers.NullableInt64": {
"type": "object",
"properties": {
"valid": {
"type": "boolean"
},
"value": {
"type": "integer"
}
}
},
"handlers.RegisterCodeReq": { "handlers.RegisterCodeReq": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -2762,7 +2762,43 @@
} }
}, },
"handlers.CreateBetReq": { "handlers.CreateBetReq": {
"type": "object" "type": "object",
"properties": {
"amount": {
"type": "number",
"example": 100
},
"full_name": {
"type": "string",
"example": "John"
},
"is_shop_bet": {
"type": "boolean",
"example": false
},
"outcomes": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.BetOutcome"
}
},
"phone_number": {
"type": "string",
"example": "1234567890"
},
"status": {
"allOf": [
{
"$ref": "#/definitions/domain.BetStatus"
}
],
"example": 1
},
"total_odds": {
"type": "number",
"example": 4.22
}
}
}, },
"handlers.CreateBranchOperationReq": { "handlers.CreateBranchOperationReq": {
"type": "object", "type": "object",
@ -3019,17 +3055,6 @@
} }
} }
}, },
"handlers.NullableInt64": {
"type": "object",
"properties": {
"valid": {
"type": "boolean"
},
"value": {
"type": "integer"
}
}
},
"handlers.RegisterCodeReq": { "handlers.RegisterCodeReq": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -233,6 +233,30 @@ definitions:
type: boolean type: boolean
type: object type: object
handlers.CreateBetReq: handlers.CreateBetReq:
properties:
amount:
example: 100
type: number
full_name:
example: John
type: string
is_shop_bet:
example: false
type: boolean
outcomes:
items:
$ref: '#/definitions/handlers.BetOutcome'
type: array
phone_number:
example: "1234567890"
type: string
status:
allOf:
- $ref: '#/definitions/domain.BetStatus'
example: 1
total_odds:
example: 4.22
type: number
type: object type: object
handlers.CreateBranchOperationReq: handlers.CreateBranchOperationReq:
properties: properties:
@ -413,13 +437,6 @@ definitions:
static_updated_at: static_updated_at:
type: string type: string
type: object type: object
handlers.NullableInt64:
properties:
valid:
type: boolean
value:
type: integer
type: object
handlers.RegisterCodeReq: handlers.RegisterCodeReq:
properties: properties:
email: email:

View File

@ -17,11 +17,11 @@ VALUES ($1, $2, $3, $4, $5)
` `
type CreateRefreshTokenParams struct { type CreateRefreshTokenParams struct {
UserID int64 UserID int64 `json:"user_id"`
Token string Token string `json:"token"`
ExpiresAt pgtype.Timestamptz ExpiresAt pgtype.Timestamptz `json:"expires_at"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
Revoked bool Revoked bool `json:"revoked"`
} }
func (q *Queries) CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) error { func (q *Queries) CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) error {
@ -60,8 +60,8 @@ WHERE email = $1 OR phone_number = $2
` `
type GetUserByEmailPhoneParams struct { type GetUserByEmailPhoneParams struct {
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
} }
func (q *Queries) GetUserByEmailPhone(ctx context.Context, arg GetUserByEmailPhoneParams) (User, error) { func (q *Queries) GetUserByEmailPhone(ctx context.Context, arg GetUserByEmailPhoneParams) (User, error) {

View File

@ -28,15 +28,15 @@ RETURNING id, amount, total_odds, status, full_name, phone_number, branch_id, us
` `
type CreateBetParams struct { type CreateBetParams struct {
Amount int64 Amount int64 `json:"amount"`
TotalOdds float32 TotalOdds float32 `json:"total_odds"`
Status int32 Status int32 `json:"status"`
FullName string FullName string `json:"full_name"`
PhoneNumber string PhoneNumber string `json:"phone_number"`
BranchID pgtype.Int8 BranchID pgtype.Int8 `json:"branch_id"`
UserID pgtype.Int8 UserID pgtype.Int8 `json:"user_id"`
IsShopBet bool IsShopBet bool `json:"is_shop_bet"`
CashoutID string CashoutID string `json:"cashout_id"`
} }
func (q *Queries) CreateBet(ctx context.Context, arg CreateBetParams) (Bet, error) { func (q *Queries) CreateBet(ctx context.Context, arg CreateBetParams) (Bet, error) {
@ -71,9 +71,9 @@ func (q *Queries) CreateBet(ctx context.Context, arg CreateBetParams) (Bet, erro
} }
type CreateBetOutcomeParams struct { type CreateBetOutcomeParams struct {
BetID int64 BetID int64 `json:"bet_id"`
EventID int64 EventID int64 `json:"event_id"`
OddID int64 OddID int64 `json:"odd_id"`
} }
const DeleteBet = `-- name: DeleteBet :exec const DeleteBet = `-- name: DeleteBet :exec
@ -242,8 +242,8 @@ WHERE id = $1
` `
type UpdateCashOutParams struct { type UpdateCashOutParams struct {
ID int64 ID int64 `json:"id"`
CashedOut bool CashedOut bool `json:"cashed_out"`
} }
func (q *Queries) UpdateCashOut(ctx context.Context, arg UpdateCashOutParams) error { func (q *Queries) UpdateCashOut(ctx context.Context, arg UpdateCashOutParams) error {

View File

@ -25,12 +25,12 @@ RETURNING id, name, location, wallet_id, branch_manager_id, company_id, is_self_
` `
type CreateBranchParams struct { type CreateBranchParams struct {
Name string Name string `json:"name"`
Location string Location string `json:"location"`
WalletID int64 WalletID int64 `json:"wallet_id"`
BranchManagerID int64 BranchManagerID int64 `json:"branch_manager_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
IsSelfOwned bool IsSelfOwned bool `json:"is_self_owned"`
} }
func (q *Queries) CreateBranch(ctx context.Context, arg CreateBranchParams) (Branch, error) { func (q *Queries) CreateBranch(ctx context.Context, arg CreateBranchParams) (Branch, error) {
@ -64,8 +64,8 @@ RETURNING id, user_id, branch_id
` `
type CreateBranchCashierParams struct { type CreateBranchCashierParams struct {
UserID int64 UserID int64 `json:"user_id"`
BranchID int64 BranchID int64 `json:"branch_id"`
} }
func (q *Queries) CreateBranchCashier(ctx context.Context, arg CreateBranchCashierParams) (BranchCashier, error) { func (q *Queries) CreateBranchCashier(ctx context.Context, arg CreateBranchCashierParams) (BranchCashier, error) {
@ -82,8 +82,8 @@ RETURNING id, operation_id, branch_id, created_at, updated_at
` `
type CreateBranchOperationParams struct { type CreateBranchOperationParams struct {
OperationID int64 OperationID int64 `json:"operation_id"`
BranchID int64 BranchID int64 `json:"branch_id"`
} }
func (q *Queries) CreateBranchOperation(ctx context.Context, arg CreateBranchOperationParams) (BranchOperation, error) { func (q *Queries) CreateBranchOperation(ctx context.Context, arg CreateBranchOperationParams) (BranchOperation, error) {
@ -106,8 +106,8 @@ RETURNING id, name, description
` `
type CreateSupportedOperationParams struct { type CreateSupportedOperationParams struct {
Name string Name string `json:"name"`
Description string Description string `json:"description"`
} }
func (q *Queries) CreateSupportedOperation(ctx context.Context, arg CreateSupportedOperationParams) (SupportedOperation, error) { func (q *Queries) CreateSupportedOperation(ctx context.Context, arg CreateSupportedOperationParams) (SupportedOperation, error) {
@ -144,8 +144,8 @@ WHERE operation_id = $1
` `
type DeleteBranchOperationParams struct { type DeleteBranchOperationParams struct {
OperationID int64 OperationID int64 `json:"operation_id"`
BranchID int64 BranchID int64 `json:"branch_id"`
} }
func (q *Queries) DeleteBranchOperation(ctx context.Context, arg DeleteBranchOperationParams) error { func (q *Queries) DeleteBranchOperation(ctx context.Context, arg DeleteBranchOperationParams) error {
@ -390,13 +390,13 @@ WHERE branch_operations.branch_id = $1
` `
type GetBranchOperationsRow struct { type GetBranchOperationsRow struct {
ID int64 ID int64 `json:"id"`
OperationID int64 OperationID int64 `json:"operation_id"`
BranchID int64 BranchID int64 `json:"branch_id"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
Name string Name string `json:"name"`
Description string Description string `json:"description"`
} }
func (q *Queries) GetBranchOperations(ctx context.Context, branchID int64) ([]GetBranchOperationsRow, error) { func (q *Queries) GetBranchOperations(ctx context.Context, branchID int64) ([]GetBranchOperationsRow, error) {
@ -518,12 +518,12 @@ RETURNING id, name, location, wallet_id, branch_manager_id, company_id, is_self_
` `
type UpdateBranchParams struct { type UpdateBranchParams struct {
Name string Name string `json:"name"`
Location string Location string `json:"location"`
BranchManagerID int64 BranchManagerID int64 `json:"branch_manager_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
IsSelfOwned bool IsSelfOwned bool `json:"is_self_owned"`
ID int64 ID int64 `json:"id"`
} }
func (q *Queries) UpdateBranch(ctx context.Context, arg UpdateBranchParams) (Branch, error) { func (q *Queries) UpdateBranch(ctx context.Context, arg UpdateBranchParams) (Branch, error) {

View File

@ -49,26 +49,26 @@ ON CONFLICT (id) DO UPDATE SET
` `
type InsertEventParams struct { type InsertEventParams struct {
ID string ID string `json:"id"`
SportID pgtype.Text SportID pgtype.Text `json:"sport_id"`
MatchName pgtype.Text MatchName pgtype.Text `json:"match_name"`
HomeTeam pgtype.Text HomeTeam pgtype.Text `json:"home_team"`
AwayTeam pgtype.Text AwayTeam pgtype.Text `json:"away_team"`
HomeTeamID pgtype.Text HomeTeamID pgtype.Text `json:"home_team_id"`
AwayTeamID pgtype.Text AwayTeamID pgtype.Text `json:"away_team_id"`
HomeKitImage pgtype.Text HomeKitImage pgtype.Text `json:"home_kit_image"`
AwayKitImage pgtype.Text AwayKitImage pgtype.Text `json:"away_kit_image"`
LeagueID pgtype.Text LeagueID pgtype.Text `json:"league_id"`
LeagueName pgtype.Text LeagueName pgtype.Text `json:"league_name"`
LeagueCc pgtype.Text LeagueCc pgtype.Text `json:"league_cc"`
StartTime pgtype.Timestamp StartTime pgtype.Timestamp `json:"start_time"`
Score pgtype.Text Score pgtype.Text `json:"score"`
MatchMinute pgtype.Int4 MatchMinute pgtype.Int4 `json:"match_minute"`
TimerStatus pgtype.Text TimerStatus pgtype.Text `json:"timer_status"`
AddedTime pgtype.Int4 AddedTime pgtype.Int4 `json:"added_time"`
MatchPeriod pgtype.Int4 MatchPeriod pgtype.Int4 `json:"match_period"`
IsLive pgtype.Bool IsLive pgtype.Bool `json:"is_live"`
Status pgtype.Text Status pgtype.Text `json:"status"`
} }
func (q *Queries) InsertEvent(ctx context.Context, arg InsertEventParams) error { func (q *Queries) InsertEvent(ctx context.Context, arg InsertEventParams) error {

View File

@ -9,265 +9,265 @@ import (
) )
type Bet struct { type Bet struct {
ID int64 ID int64 `json:"id"`
Amount int64 Amount int64 `json:"amount"`
TotalOdds float32 TotalOdds float32 `json:"total_odds"`
Status int32 Status int32 `json:"status"`
FullName string FullName string `json:"full_name"`
PhoneNumber string PhoneNumber string `json:"phone_number"`
BranchID pgtype.Int8 BranchID pgtype.Int8 `json:"branch_id"`
UserID pgtype.Int8 UserID pgtype.Int8 `json:"user_id"`
CashedOut bool CashedOut bool `json:"cashed_out"`
CashoutID string CashoutID string `json:"cashout_id"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
IsShopBet bool IsShopBet bool `json:"is_shop_bet"`
} }
type BetOutcome struct { type BetOutcome struct {
ID int64 ID int64 `json:"id"`
BetID int64 BetID int64 `json:"bet_id"`
EventID int64 EventID int64 `json:"event_id"`
OddID int64 OddID int64 `json:"odd_id"`
} }
type BetWithOutcome struct { type BetWithOutcome struct {
ID int64 ID int64 `json:"id"`
Amount int64 Amount int64 `json:"amount"`
TotalOdds float32 TotalOdds float32 `json:"total_odds"`
Status int32 Status int32 `json:"status"`
FullName string FullName string `json:"full_name"`
PhoneNumber string PhoneNumber string `json:"phone_number"`
BranchID pgtype.Int8 BranchID pgtype.Int8 `json:"branch_id"`
UserID pgtype.Int8 UserID pgtype.Int8 `json:"user_id"`
CashedOut bool CashedOut bool `json:"cashed_out"`
CashoutID string CashoutID string `json:"cashout_id"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
IsShopBet bool IsShopBet bool `json:"is_shop_bet"`
Outcomes []BetOutcome Outcomes []BetOutcome `json:"outcomes"`
} }
type Branch struct { type Branch struct {
ID int64 ID int64 `json:"id"`
Name string Name string `json:"name"`
Location string Location string `json:"location"`
WalletID int64 WalletID int64 `json:"wallet_id"`
BranchManagerID int64 BranchManagerID int64 `json:"branch_manager_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
IsSelfOwned bool IsSelfOwned bool `json:"is_self_owned"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
} }
type BranchCashier struct { type BranchCashier struct {
ID int64 ID int64 `json:"id"`
UserID int64 UserID int64 `json:"user_id"`
BranchID int64 BranchID int64 `json:"branch_id"`
} }
type BranchDetail struct { type BranchDetail struct {
ID int64 ID int64 `json:"id"`
Name string Name string `json:"name"`
Location string Location string `json:"location"`
WalletID int64 WalletID int64 `json:"wallet_id"`
BranchManagerID int64 BranchManagerID int64 `json:"branch_manager_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
IsSelfOwned bool IsSelfOwned bool `json:"is_self_owned"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
ManagerName interface{} ManagerName interface{} `json:"manager_name"`
ManagerPhoneNumber pgtype.Text ManagerPhoneNumber pgtype.Text `json:"manager_phone_number"`
} }
type BranchOperation struct { type BranchOperation struct {
ID int64 ID int64 `json:"id"`
OperationID int64 OperationID int64 `json:"operation_id"`
BranchID int64 BranchID int64 `json:"branch_id"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
} }
type CustomerWallet struct { type CustomerWallet struct {
ID int64 ID int64 `json:"id"`
CustomerID int64 CustomerID int64 `json:"customer_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
RegularWalletID int64 RegularWalletID int64 `json:"regular_wallet_id"`
StaticWalletID int64 StaticWalletID int64 `json:"static_wallet_id"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
} }
type Event struct { type Event struct {
ID string ID string `json:"id"`
SportID pgtype.Text SportID pgtype.Text `json:"sport_id"`
MatchName pgtype.Text MatchName pgtype.Text `json:"match_name"`
HomeTeam pgtype.Text HomeTeam pgtype.Text `json:"home_team"`
AwayTeam pgtype.Text AwayTeam pgtype.Text `json:"away_team"`
HomeTeamID pgtype.Text HomeTeamID pgtype.Text `json:"home_team_id"`
AwayTeamID pgtype.Text AwayTeamID pgtype.Text `json:"away_team_id"`
HomeKitImage pgtype.Text HomeKitImage pgtype.Text `json:"home_kit_image"`
AwayKitImage pgtype.Text AwayKitImage pgtype.Text `json:"away_kit_image"`
LeagueID pgtype.Text LeagueID pgtype.Text `json:"league_id"`
LeagueName pgtype.Text LeagueName pgtype.Text `json:"league_name"`
LeagueCc pgtype.Text LeagueCc pgtype.Text `json:"league_cc"`
StartTime pgtype.Timestamp StartTime pgtype.Timestamp `json:"start_time"`
Score pgtype.Text Score pgtype.Text `json:"score"`
MatchMinute pgtype.Int4 MatchMinute pgtype.Int4 `json:"match_minute"`
TimerStatus pgtype.Text TimerStatus pgtype.Text `json:"timer_status"`
AddedTime pgtype.Int4 AddedTime pgtype.Int4 `json:"added_time"`
MatchPeriod pgtype.Int4 MatchPeriod pgtype.Int4 `json:"match_period"`
IsLive pgtype.Bool IsLive pgtype.Bool `json:"is_live"`
Status pgtype.Text Status pgtype.Text `json:"status"`
FetchedAt pgtype.Timestamp FetchedAt pgtype.Timestamp `json:"fetched_at"`
} }
type Notification struct { type Notification struct {
ID string ID string `json:"id"`
RecipientID int64 RecipientID int64 `json:"recipient_id"`
Type string Type string `json:"type"`
Level string Level string `json:"level"`
ErrorSeverity pgtype.Text ErrorSeverity pgtype.Text `json:"error_severity"`
Reciever string Reciever string `json:"reciever"`
IsRead bool IsRead bool `json:"is_read"`
DeliveryStatus string DeliveryStatus string `json:"delivery_status"`
DeliveryChannel pgtype.Text DeliveryChannel pgtype.Text `json:"delivery_channel"`
Payload []byte Payload []byte `json:"payload"`
Priority pgtype.Int4 Priority pgtype.Int4 `json:"priority"`
Version int32 Version int32 `json:"version"`
Timestamp pgtype.Timestamptz Timestamp pgtype.Timestamptz `json:"timestamp"`
Metadata []byte Metadata []byte `json:"metadata"`
} }
type Odd struct { type Odd struct {
ID int32 ID int32 `json:"id"`
EventID pgtype.Text EventID pgtype.Text `json:"event_id"`
Fi pgtype.Text Fi pgtype.Text `json:"fi"`
RawEventID pgtype.Text RawEventID pgtype.Text `json:"raw_event_id"`
MarketType string MarketType string `json:"market_type"`
MarketName pgtype.Text MarketName pgtype.Text `json:"market_name"`
MarketCategory pgtype.Text MarketCategory pgtype.Text `json:"market_category"`
MarketID pgtype.Text MarketID pgtype.Text `json:"market_id"`
Header pgtype.Text Header pgtype.Text `json:"header"`
Name pgtype.Text Name pgtype.Text `json:"name"`
Handicap pgtype.Text Handicap pgtype.Text `json:"handicap"`
OddsValue pgtype.Float8 OddsValue pgtype.Float8 `json:"odds_value"`
Section string Section string `json:"section"`
Category pgtype.Text Category pgtype.Text `json:"category"`
RawOdds []byte RawOdds []byte `json:"raw_odds"`
FetchedAt pgtype.Timestamp FetchedAt pgtype.Timestamp `json:"fetched_at"`
Source pgtype.Text Source pgtype.Text `json:"source"`
IsActive pgtype.Bool IsActive pgtype.Bool `json:"is_active"`
} }
type Otp struct { type Otp struct {
ID int64 ID int64 `json:"id"`
SentTo string SentTo string `json:"sent_to"`
Medium string Medium string `json:"medium"`
OtpFor string OtpFor string `json:"otp_for"`
Otp string Otp string `json:"otp"`
Used bool Used bool `json:"used"`
UsedAt pgtype.Timestamptz UsedAt pgtype.Timestamptz `json:"used_at"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
ExpiresAt pgtype.Timestamptz ExpiresAt pgtype.Timestamptz `json:"expires_at"`
} }
type RefreshToken struct { type RefreshToken struct {
ID int64 ID int64 `json:"id"`
UserID int64 UserID int64 `json:"user_id"`
Token string Token string `json:"token"`
ExpiresAt pgtype.Timestamptz ExpiresAt pgtype.Timestamptz `json:"expires_at"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
Revoked bool Revoked bool `json:"revoked"`
} }
type SupportedOperation struct { type SupportedOperation struct {
ID int64 ID int64 `json:"id"`
Name string Name string `json:"name"`
Description string Description string `json:"description"`
} }
type Ticket struct { type Ticket struct {
ID int64 ID int64 `json:"id"`
Amount pgtype.Int8 Amount pgtype.Int8 `json:"amount"`
TotalOdds float32 TotalOdds float32 `json:"total_odds"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
} }
type TicketOutcome struct { type TicketOutcome struct {
ID int64 ID int64 `json:"id"`
TicketID int64 TicketID int64 `json:"ticket_id"`
EventID int64 EventID int64 `json:"event_id"`
OddID int64 OddID int64 `json:"odd_id"`
} }
type TicketWithOutcome struct { type TicketWithOutcome struct {
ID int64 ID int64 `json:"id"`
Amount pgtype.Int8 Amount pgtype.Int8 `json:"amount"`
TotalOdds float32 TotalOdds float32 `json:"total_odds"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
Outcomes []TicketOutcome Outcomes []TicketOutcome `json:"outcomes"`
} }
type Transaction struct { type Transaction struct {
ID int64 ID int64 `json:"id"`
Amount int64 Amount int64 `json:"amount"`
BranchID int64 BranchID int64 `json:"branch_id"`
CashierID int64 CashierID int64 `json:"cashier_id"`
BetID int64 BetID int64 `json:"bet_id"`
Type int64 Type int64 `json:"type"`
PaymentOption int64 PaymentOption int64 `json:"payment_option"`
FullName string FullName string `json:"full_name"`
PhoneNumber string PhoneNumber string `json:"phone_number"`
BankCode string BankCode string `json:"bank_code"`
BeneficiaryName string BeneficiaryName string `json:"beneficiary_name"`
AccountName string AccountName string `json:"account_name"`
AccountNumber string AccountNumber string `json:"account_number"`
ReferenceNumber string ReferenceNumber string `json:"reference_number"`
Verified bool Verified bool `json:"verified"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
} }
type User struct { type User struct {
ID int64 ID int64 `json:"id"`
FirstName string FirstName string `json:"first_name"`
LastName string LastName string `json:"last_name"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Role string Role string `json:"role"`
Password []byte Password []byte `json:"password"`
EmailVerified bool EmailVerified bool `json:"email_verified"`
PhoneVerified bool PhoneVerified bool `json:"phone_verified"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
SuspendedAt pgtype.Timestamptz SuspendedAt pgtype.Timestamptz `json:"suspended_at"`
Suspended bool Suspended bool `json:"suspended"`
} }
type Wallet struct { type Wallet struct {
ID int64 ID int64 `json:"id"`
Balance int64 Balance int64 `json:"balance"`
IsWithdraw bool IsWithdraw bool `json:"is_withdraw"`
IsBettable bool IsBettable bool `json:"is_bettable"`
IsTransferable bool IsTransferable bool `json:"is_transferable"`
UserID int64 UserID int64 `json:"user_id"`
IsActive bool IsActive bool `json:"is_active"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
} }
type WalletTransfer struct { type WalletTransfer struct {
ID int64 ID int64 `json:"id"`
Amount int64 Amount int64 `json:"amount"`
Type string Type string `json:"type"`
ReceiverWalletID int64 ReceiverWalletID int64 `json:"receiver_wallet_id"`
SenderWalletID pgtype.Int8 SenderWalletID pgtype.Int8 `json:"sender_wallet_id"`
CashierID pgtype.Int8 CashierID pgtype.Int8 `json:"cashier_id"`
Verified bool Verified bool `json:"verified"`
PaymentMethod string PaymentMethod string `json:"payment_method"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
} }

View File

@ -20,19 +20,19 @@ INSERT INTO notifications (
` `
type CreateNotificationParams struct { type CreateNotificationParams struct {
ID string ID string `json:"id"`
RecipientID int64 RecipientID int64 `json:"recipient_id"`
Type string Type string `json:"type"`
Level string Level string `json:"level"`
ErrorSeverity pgtype.Text ErrorSeverity pgtype.Text `json:"error_severity"`
Reciever string Reciever string `json:"reciever"`
IsRead bool IsRead bool `json:"is_read"`
DeliveryStatus string DeliveryStatus string `json:"delivery_status"`
DeliveryChannel pgtype.Text DeliveryChannel pgtype.Text `json:"delivery_channel"`
Payload []byte Payload []byte `json:"payload"`
Priority pgtype.Int4 Priority pgtype.Int4 `json:"priority"`
Timestamp pgtype.Timestamptz Timestamp pgtype.Timestamptz `json:"timestamp"`
Metadata []byte Metadata []byte `json:"metadata"`
} }
func (q *Queries) CreateNotification(ctx context.Context, arg CreateNotificationParams) (Notification, error) { func (q *Queries) CreateNotification(ctx context.Context, arg CreateNotificationParams) (Notification, error) {
@ -141,9 +141,9 @@ SELECT id, recipient_id, type, level, error_severity, reciever, is_read, deliver
` `
type ListNotificationsParams struct { type ListNotificationsParams struct {
RecipientID int64 RecipientID int64 `json:"recipient_id"`
Limit int32 Limit int32 `json:"limit"`
Offset int32 Offset int32 `json:"offset"`
} }
func (q *Queries) ListNotifications(ctx context.Context, arg ListNotificationsParams) ([]Notification, error) { func (q *Queries) ListNotifications(ctx context.Context, arg ListNotificationsParams) ([]Notification, error) {
@ -210,10 +210,10 @@ UPDATE notifications SET delivery_status = $2, is_read = $3, metadata = $4 WHERE
` `
type UpdateNotificationStatusParams struct { type UpdateNotificationStatusParams struct {
ID string ID string `json:"id"`
DeliveryStatus string DeliveryStatus string `json:"delivery_status"`
IsRead bool IsRead bool `json:"is_read"`
Metadata []byte Metadata []byte `json:"metadata"`
} }
func (q *Queries) UpdateNotificationStatus(ctx context.Context, arg UpdateNotificationStatusParams) (Notification, error) { func (q *Queries) UpdateNotificationStatus(ctx context.Context, arg UpdateNotificationStatusParams) (Notification, error) {

View File

@ -223,20 +223,20 @@ ON CONFLICT (event_id, market_id, header, name, handicap) DO UPDATE SET
` `
type InsertNonLiveOddParams struct { type InsertNonLiveOddParams struct {
EventID pgtype.Text EventID pgtype.Text `json:"event_id"`
Fi pgtype.Text Fi pgtype.Text `json:"fi"`
RawEventID pgtype.Text RawEventID pgtype.Text `json:"raw_event_id"`
MarketType string MarketType string `json:"market_type"`
MarketName pgtype.Text MarketName pgtype.Text `json:"market_name"`
MarketCategory pgtype.Text MarketCategory pgtype.Text `json:"market_category"`
MarketID pgtype.Text MarketID pgtype.Text `json:"market_id"`
Header pgtype.Text Header pgtype.Text `json:"header"`
Name pgtype.Text Name pgtype.Text `json:"name"`
Handicap pgtype.Text Handicap pgtype.Text `json:"handicap"`
OddsValue pgtype.Float8 OddsValue pgtype.Float8 `json:"odds_value"`
Section string Section string `json:"section"`
Category pgtype.Text Category pgtype.Text `json:"category"`
RawOdds []byte RawOdds []byte `json:"raw_odds"`
} }
func (q *Queries) InsertNonLiveOdd(ctx context.Context, arg InsertNonLiveOddParams) error { func (q *Queries) InsertNonLiveOdd(ctx context.Context, arg InsertNonLiveOddParams) error {

View File

@ -17,12 +17,12 @@ VALUES ($1, $2, $3, $4, FALSE, $5, $6)
` `
type CreateOtpParams struct { type CreateOtpParams struct {
SentTo string SentTo string `json:"sent_to"`
Medium string Medium string `json:"medium"`
OtpFor string OtpFor string `json:"otp_for"`
Otp string Otp string `json:"otp"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
ExpiresAt pgtype.Timestamptz ExpiresAt pgtype.Timestamptz `json:"expires_at"`
} }
func (q *Queries) CreateOtp(ctx context.Context, arg CreateOtpParams) error { func (q *Queries) CreateOtp(ctx context.Context, arg CreateOtpParams) error {
@ -45,9 +45,9 @@ ORDER BY created_at DESC LIMIT 1
` `
type GetOtpParams struct { type GetOtpParams struct {
SentTo string SentTo string `json:"sent_to"`
OtpFor string OtpFor string `json:"otp_for"`
Medium string Medium string `json:"medium"`
} }
func (q *Queries) GetOtp(ctx context.Context, arg GetOtpParams) (Otp, error) { func (q *Queries) GetOtp(ctx context.Context, arg GetOtpParams) (Otp, error) {
@ -74,8 +74,8 @@ WHERE id = $1
` `
type MarkOtpAsUsedParams struct { type MarkOtpAsUsedParams struct {
ID int64 ID int64 `json:"id"`
UsedAt pgtype.Timestamptz UsedAt pgtype.Timestamptz `json:"used_at"`
} }
func (q *Queries) MarkOtpAsUsed(ctx context.Context, arg MarkOtpAsUsedParams) error { func (q *Queries) MarkOtpAsUsed(ctx context.Context, arg MarkOtpAsUsedParams) error {

View File

@ -18,8 +18,8 @@ RETURNING id, amount, total_odds, created_at, updated_at
` `
type CreateTicketParams struct { type CreateTicketParams struct {
Amount pgtype.Int8 Amount pgtype.Int8 `json:"amount"`
TotalOdds float32 TotalOdds float32 `json:"total_odds"`
} }
func (q *Queries) CreateTicket(ctx context.Context, arg CreateTicketParams) (Ticket, error) { func (q *Queries) CreateTicket(ctx context.Context, arg CreateTicketParams) (Ticket, error) {
@ -36,9 +36,9 @@ func (q *Queries) CreateTicket(ctx context.Context, arg CreateTicketParams) (Tic
} }
type CreateTicketOutcomeParams struct { type CreateTicketOutcomeParams struct {
TicketID int64 TicketID int64 `json:"ticket_id"`
EventID int64 EventID int64 `json:"event_id"`
OddID int64 OddID int64 `json:"odd_id"`
} }
const DeleteOldTickets = `-- name: DeleteOldTickets :exec const DeleteOldTickets = `-- name: DeleteOldTickets :exec

View File

@ -14,19 +14,19 @@ INSERT INTO transactions (amount, branch_id, cashier_id, bet_id, type, payment_o
` `
type CreateTransactionParams struct { type CreateTransactionParams struct {
Amount int64 Amount int64 `json:"amount"`
BranchID int64 BranchID int64 `json:"branch_id"`
CashierID int64 CashierID int64 `json:"cashier_id"`
BetID int64 BetID int64 `json:"bet_id"`
Type int64 Type int64 `json:"type"`
PaymentOption int64 PaymentOption int64 `json:"payment_option"`
FullName string FullName string `json:"full_name"`
PhoneNumber string PhoneNumber string `json:"phone_number"`
BankCode string BankCode string `json:"bank_code"`
BeneficiaryName string BeneficiaryName string `json:"beneficiary_name"`
AccountName string AccountName string `json:"account_name"`
AccountNumber string AccountNumber string `json:"account_number"`
ReferenceNumber string ReferenceNumber string `json:"reference_number"`
} }
func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error) { func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error) {
@ -186,8 +186,8 @@ UPDATE transactions SET verified = $2, updated_at = CURRENT_TIMESTAMP WHERE id =
` `
type UpdateTransactionVerifiedParams struct { type UpdateTransactionVerifiedParams struct {
ID int64 ID int64 `json:"id"`
Verified bool Verified bool `json:"verified"`
} }
func (q *Queries) UpdateTransactionVerified(ctx context.Context, arg UpdateTransactionVerifiedParams) error { func (q *Queries) UpdateTransactionVerified(ctx context.Context, arg UpdateTransactionVerifiedParams) error {

View File

@ -16,13 +16,13 @@ INSERT INTO wallet_transfer (amount, type, receiver_wallet_id, sender_wallet_id,
` `
type CreateTransferParams struct { type CreateTransferParams struct {
Amount int64 Amount int64 `json:"amount"`
Type string Type string `json:"type"`
ReceiverWalletID int64 ReceiverWalletID int64 `json:"receiver_wallet_id"`
SenderWalletID pgtype.Int8 SenderWalletID pgtype.Int8 `json:"sender_wallet_id"`
CashierID pgtype.Int8 CashierID pgtype.Int8 `json:"cashier_id"`
Verified bool Verified bool `json:"verified"`
PaymentMethod string PaymentMethod string `json:"payment_method"`
} }
func (q *Queries) CreateTransfer(ctx context.Context, arg CreateTransferParams) (WalletTransfer, error) { func (q *Queries) CreateTransfer(ctx context.Context, arg CreateTransferParams) (WalletTransfer, error) {
@ -148,8 +148,8 @@ UPDATE wallet_transfer SET verified = $1, updated_at = CURRENT_TIMESTAMP WHERE i
` `
type UpdateTransferVerificationParams struct { type UpdateTransferVerificationParams struct {
Verified bool Verified bool `json:"verified"`
ID int64 ID int64 `json:"id"`
} }
func (q *Queries) UpdateTransferVerification(ctx context.Context, arg UpdateTransferVerificationParams) error { func (q *Queries) UpdateTransferVerification(ctx context.Context, arg UpdateTransferVerificationParams) error {

View File

@ -27,13 +27,13 @@ SELECT EXISTS (
` `
type CheckPhoneEmailExistParams struct { type CheckPhoneEmailExistParams struct {
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Email pgtype.Text Email pgtype.Text `json:"email"`
} }
type CheckPhoneEmailExistRow struct { type CheckPhoneEmailExistRow struct {
PhoneExists bool PhoneExists bool `json:"phone_exists"`
EmailExists bool EmailExists bool `json:"email_exists"`
} }
func (q *Queries) CheckPhoneEmailExist(ctx context.Context, arg CheckPhoneEmailExistParams) (CheckPhoneEmailExistRow, error) { func (q *Queries) CheckPhoneEmailExist(ctx context.Context, arg CheckPhoneEmailExistParams) (CheckPhoneEmailExistRow, error) {
@ -70,29 +70,29 @@ RETURNING id,
` `
type CreateUserParams struct { type CreateUserParams struct {
FirstName string FirstName string `json:"first_name"`
LastName string LastName string `json:"last_name"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Role string Role string `json:"role"`
Password []byte Password []byte `json:"password"`
EmailVerified bool EmailVerified bool `json:"email_verified"`
PhoneVerified bool PhoneVerified bool `json:"phone_verified"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
} }
type CreateUserRow struct { type CreateUserRow struct {
ID int64 ID int64 `json:"id"`
FirstName string FirstName string `json:"first_name"`
LastName string LastName string `json:"last_name"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Role string Role string `json:"role"`
EmailVerified bool EmailVerified bool `json:"email_verified"`
PhoneVerified bool PhoneVerified bool `json:"phone_verified"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
} }
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error) { func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error) {
@ -149,16 +149,16 @@ FROM users
` `
type GetAllUsersRow struct { type GetAllUsersRow struct {
ID int64 ID int64 `json:"id"`
FirstName string FirstName string `json:"first_name"`
LastName string LastName string `json:"last_name"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Role string Role string `json:"role"`
EmailVerified bool EmailVerified bool `json:"email_verified"`
PhoneVerified bool PhoneVerified bool `json:"phone_verified"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
} }
func (q *Queries) GetAllUsers(ctx context.Context) ([]GetAllUsersRow, error) { func (q *Queries) GetAllUsers(ctx context.Context) ([]GetAllUsersRow, error) {
@ -208,16 +208,16 @@ WHERE email = $1
` `
type GetUserByEmailRow struct { type GetUserByEmailRow struct {
ID int64 ID int64 `json:"id"`
FirstName string FirstName string `json:"first_name"`
LastName string LastName string `json:"last_name"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Role string Role string `json:"role"`
EmailVerified bool EmailVerified bool `json:"email_verified"`
PhoneVerified bool PhoneVerified bool `json:"phone_verified"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
} }
func (q *Queries) GetUserByEmail(ctx context.Context, email pgtype.Text) (GetUserByEmailRow, error) { func (q *Queries) GetUserByEmail(ctx context.Context, email pgtype.Text) (GetUserByEmailRow, error) {
@ -281,16 +281,16 @@ WHERE phone_number = $1
` `
type GetUserByPhoneRow struct { type GetUserByPhoneRow struct {
ID int64 ID int64 `json:"id"`
FirstName string FirstName string `json:"first_name"`
LastName string LastName string `json:"last_name"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Role string Role string `json:"role"`
EmailVerified bool EmailVerified bool `json:"email_verified"`
PhoneVerified bool PhoneVerified bool `json:"phone_verified"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
} }
func (q *Queries) GetUserByPhone(ctx context.Context, phoneNumber pgtype.Text) (GetUserByPhoneRow, error) { func (q *Queries) GetUserByPhone(ctx context.Context, phoneNumber pgtype.Text) (GetUserByPhoneRow, error) {
@ -329,16 +329,16 @@ WHERE first_name ILIKE '%' || $1 || '%'
` `
type SearchUserByNameOrPhoneRow struct { type SearchUserByNameOrPhoneRow struct {
ID int64 ID int64 `json:"id"`
FirstName string FirstName string `json:"first_name"`
LastName string LastName string `json:"last_name"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Role string Role string `json:"role"`
EmailVerified bool EmailVerified bool `json:"email_verified"`
PhoneVerified bool PhoneVerified bool `json:"phone_verified"`
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
} }
func (q *Queries) SearchUserByNameOrPhone(ctx context.Context, dollar_1 pgtype.Text) ([]SearchUserByNameOrPhoneRow, error) { func (q *Queries) SearchUserByNameOrPhone(ctx context.Context, dollar_1 pgtype.Text) ([]SearchUserByNameOrPhoneRow, error) {
@ -383,10 +383,10 @@ WHERE (
` `
type UpdatePasswordParams struct { type UpdatePasswordParams struct {
Password []byte Password []byte `json:"password"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
} }
func (q *Queries) UpdatePassword(ctx context.Context, arg UpdatePasswordParams) error { func (q *Queries) UpdatePassword(ctx context.Context, arg UpdatePasswordParams) error {
@ -411,13 +411,13 @@ WHERE id = $7
` `
type UpdateUserParams struct { type UpdateUserParams struct {
FirstName string FirstName string `json:"first_name"`
LastName string LastName string `json:"last_name"`
Email pgtype.Text Email pgtype.Text `json:"email"`
PhoneNumber pgtype.Text PhoneNumber pgtype.Text `json:"phone_number"`
Role string Role string `json:"role"`
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz `json:"updated_at"`
ID int64 ID int64 `json:"id"`
} }
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error { func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error {

View File

@ -23,10 +23,10 @@ RETURNING id, customer_id, company_id, regular_wallet_id, static_wallet_id, crea
` `
type CreateCustomerWalletParams struct { type CreateCustomerWalletParams struct {
CustomerID int64 CustomerID int64 `json:"customer_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
RegularWalletID int64 RegularWalletID int64 `json:"regular_wallet_id"`
StaticWalletID int64 StaticWalletID int64 `json:"static_wallet_id"`
} }
func (q *Queries) CreateCustomerWallet(ctx context.Context, arg CreateCustomerWalletParams) (CustomerWallet, error) { func (q *Queries) CreateCustomerWallet(ctx context.Context, arg CreateCustomerWalletParams) (CustomerWallet, error) {
@ -61,10 +61,10 @@ RETURNING id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_ac
` `
type CreateWalletParams struct { type CreateWalletParams struct {
IsWithdraw bool IsWithdraw bool `json:"is_withdraw"`
IsBettable bool IsBettable bool `json:"is_bettable"`
IsTransferable bool IsTransferable bool `json:"is_transferable"`
UserID int64 UserID int64 `json:"user_id"`
} }
func (q *Queries) CreateWallet(ctx context.Context, arg CreateWalletParams) (Wallet, error) { func (q *Queries) CreateWallet(ctx context.Context, arg CreateWalletParams) (Wallet, error) {
@ -105,16 +105,16 @@ FROM branches
` `
type GetAllBranchWalletsRow struct { type GetAllBranchWalletsRow struct {
ID int64 ID int64 `json:"id"`
Balance int64 Balance int64 `json:"balance"`
IsActive bool IsActive bool `json:"is_active"`
UpdatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp `json:"updated_at"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
Name string Name string `json:"name"`
Location string Location string `json:"location"`
BranchManagerID int64 BranchManagerID int64 `json:"branch_manager_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
IsSelfOwned bool IsSelfOwned bool `json:"is_self_owned"`
} }
func (q *Queries) GetAllBranchWallets(ctx context.Context) ([]GetAllBranchWalletsRow, error) { func (q *Queries) GetAllBranchWallets(ctx context.Context) ([]GetAllBranchWalletsRow, error) {
@ -202,21 +202,21 @@ WHERE cw.customer_id = $1
` `
type GetCustomerWalletParams struct { type GetCustomerWalletParams struct {
CustomerID int64 CustomerID int64 `json:"customer_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
} }
type GetCustomerWalletRow struct { type GetCustomerWalletRow struct {
ID int64 ID int64 `json:"id"`
CustomerID int64 CustomerID int64 `json:"customer_id"`
CompanyID int64 CompanyID int64 `json:"company_id"`
RegularID int64 RegularID int64 `json:"regular_id"`
RegularBalance int64 RegularBalance int64 `json:"regular_balance"`
StaticID int64 StaticID int64 `json:"static_id"`
StaticBalance int64 StaticBalance int64 `json:"static_balance"`
RegularUpdatedAt pgtype.Timestamp RegularUpdatedAt pgtype.Timestamp `json:"regular_updated_at"`
StaticUpdatedAt pgtype.Timestamp StaticUpdatedAt pgtype.Timestamp `json:"static_updated_at"`
CreatedAt pgtype.Timestamp CreatedAt pgtype.Timestamp `json:"created_at"`
} }
func (q *Queries) GetCustomerWallet(ctx context.Context, arg GetCustomerWalletParams) (GetCustomerWalletRow, error) { func (q *Queries) GetCustomerWallet(ctx context.Context, arg GetCustomerWalletParams) (GetCustomerWalletRow, error) {
@ -304,8 +304,8 @@ WHERE id = $2
` `
type UpdateBalanceParams struct { type UpdateBalanceParams struct {
Balance int64 Balance int64 `json:"balance"`
ID int64 ID int64 `json:"id"`
} }
func (q *Queries) UpdateBalance(ctx context.Context, arg UpdateBalanceParams) error { func (q *Queries) UpdateBalance(ctx context.Context, arg UpdateBalanceParams) error {
@ -321,8 +321,8 @@ WHERE id = $2
` `
type UpdateWalletActiveParams struct { type UpdateWalletActiveParams struct {
IsActive bool IsActive bool `json:"is_active"`
ID int64 ID int64 `json:"id"`
} }
func (q *Queries) UpdateWalletActive(ctx context.Context, arg UpdateWalletActiveParams) error { func (q *Queries) UpdateWalletActive(ctx context.Context, arg UpdateWalletActiveParams) error {

View File

@ -1,10 +1,10 @@
package domain package domain
type TicketOutcome struct { type TicketOutcome struct {
ID int64 ID int64 `json:"id" example:"1"`
TicketID int64 TicketID int64 `json:"ticket_id" example:"1"`
EventID int64 EventID int64 `json:"event_id" example:"1"`
OddID int64 OddID int64 `json:"odd_id" example:"1"`
} }
type CreateTicketOutcome struct { type CreateTicketOutcome struct {

View File

@ -2,6 +2,7 @@ package repository
import ( import (
"context" "context"
"fmt"
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db" dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain" "github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
@ -78,6 +79,7 @@ func (s *Store) CreateTicketOutcome(ctx context.Context, outcomes []domain.Creat
func (s *Store) GetTicketByID(ctx context.Context, id int64) (domain.GetTicket, error) { func (s *Store) GetTicketByID(ctx context.Context, id int64) (domain.GetTicket, error) {
ticket, err := s.queries.GetTicketByID(ctx, id) ticket, err := s.queries.GetTicketByID(ctx, id)
if err != nil { if err != nil {
return domain.GetTicket{}, err return domain.GetTicket{}, err
} }
@ -87,7 +89,7 @@ func (s *Store) GetTicketByID(ctx context.Context, id int64) (domain.GetTicket,
func (s *Store) GetAllTickets(ctx context.Context) ([]domain.GetTicket, error) { func (s *Store) GetAllTickets(ctx context.Context) ([]domain.GetTicket, error) {
tickets, err := s.queries.GetAllTickets(ctx) tickets, err := s.queries.GetAllTickets(ctx)
fmt.Printf("%v", tickets)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -95,6 +97,7 @@ func (s *Store) GetAllTickets(ctx context.Context) ([]domain.GetTicket, error) {
var result []domain.GetTicket = make([]domain.GetTicket, 0, len(tickets)) var result []domain.GetTicket = make([]domain.GetTicket, 0, len(tickets))
for _, ticket := range tickets { for _, ticket := range tickets {
result = append(result, convertDBTicketOutcomes(ticket)) result = append(result, convertDBTicketOutcomes(ticket))
// fmt.Printf("%v", convertDBTicketOutcomes(ticket))
} }
return result, nil return result, nil

View File

@ -56,7 +56,6 @@ type CreateBetReq struct {
FullName string `json:"full_name" example:"John"` FullName string `json:"full_name" example:"John"`
PhoneNumber string `json:"phone_number" example:"1234567890"` PhoneNumber string `json:"phone_number" example:"1234567890"`
IsShopBet bool `json:"is_shop_bet" example:"false"` IsShopBet bool `json:"is_shop_bet" example:"false"`
BranchID NullableInt64 `json:"branch_id" example:"1"`
} }
type CreateBetRes struct { type CreateBetRes struct {
@ -127,7 +126,6 @@ func CreateBet(logger *slog.Logger, betSvc *bet.Service, userSvc *user.Service,
// Get user_id from middleware // Get user_id from middleware
userID := c.Locals("user_id").(int64) userID := c.Locals("user_id").(int64)
var isShopBet bool
var req CreateBetReq var req CreateBetReq
@ -145,18 +143,12 @@ func CreateBet(logger *slog.Logger, betSvc *bet.Service, userSvc *user.Service,
} }
user, err := userSvc.GetUserByID(c.Context(), userID) user, err := userSvc.GetUserByID(c.Context(), userID)
cashoutUUID := uuid.New()
if user.Role != domain.RoleCustomer { var bet domain.Bet
isShopBet = true if user.Role != domain.RoleCashier {
if !req.BranchID.Valid {
logger.Error("CreateBetReq failed, branch id necessary")
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": "Branch ID necessary",
})
}
// Get the branch from the branch ID // Get the branch from the branch ID
branch, err := branchSvc.GetBranchByID(c.Context(), req.BranchID.Value) branch, err := branchSvc.GetBranchByCashier(c.Context(), user.ID)
if err != nil { if err != nil {
logger.Error("CreateBetReq failed, branch id invalid") logger.Error("CreateBetReq failed, branch id invalid")
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
@ -165,42 +157,57 @@ func CreateBet(logger *slog.Logger, betSvc *bet.Service, userSvc *user.Service,
} }
// Deduct a percentage of the amount // Deduct a percentage of the amount
// TODO move to service layer
var deductedAmount = req.Amount / 10 var deductedAmount = req.Amount / 10
err = walletSvc.DeductFromWallet(c.Context(), branch.WalletID, domain.Currency(deductedAmount)) err = walletSvc.DeductFromWallet(c.Context(), branch.WalletID, domain.ToCurrency(deductedAmount))
if err != nil { if err != nil {
logger.Error("CreateBetReq failed, unable to deduct from WalletID", branch.WalletID) logger.Error("CreateBetReq failed, unable to deduct from WalletID")
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": "Unable to deduct from branch wallet", "error": "Unable to deduct from branch wallet",
}) })
} }
} else { bet, err = betSvc.CreateBet(c.Context(), domain.CreateBet{
isShopBet = false Amount: domain.ToCurrency(req.Amount),
// TODO if user is customer, get id from the token then get the wallet id from there and reduce the amount
}
// TODO Validate Outcomes Here and make sure they didn't expire
cashoutUUID := uuid.New()
bet, err := betSvc.CreateBet(c.Context(), domain.CreateBet{
Amount: domain.Currency(req.Amount),
TotalOdds: req.TotalOdds, TotalOdds: req.TotalOdds,
Status: req.Status, Status: req.Status,
FullName: req.FullName, FullName: req.FullName,
PhoneNumber: req.PhoneNumber, PhoneNumber: req.PhoneNumber,
BranchID: domain.ValidInt64{ BranchID: domain.ValidInt64{
Value: req.BranchID.Value, Value: branch.ID,
Valid: isShopBet, Valid: true,
}, },
UserID: domain.ValidInt64{ UserID: domain.ValidInt64{
Value: userID, Value: userID,
Valid: !isShopBet, Valid: false,
}, },
IsShopBet: req.IsShopBet, IsShopBet: req.IsShopBet,
CashoutID: cashoutUUID.String(), CashoutID: cashoutUUID.String(),
}) })
} else {
// TODO if user is customer, get id from the token then get the wallet id from there and reduce the amount
bet, err = betSvc.CreateBet(c.Context(), domain.CreateBet{
Amount: domain.ToCurrency(req.Amount),
TotalOdds: req.TotalOdds,
Status: req.Status,
FullName: req.FullName,
PhoneNumber: req.PhoneNumber,
BranchID: domain.ValidInt64{
Value: 0,
Valid: false,
},
UserID: domain.ValidInt64{
Value: userID,
Valid: true,
},
IsShopBet: req.IsShopBet,
CashoutID: cashoutUUID.String(),
})
}
// TODO Validate Outcomes Here and make sure they didn't expire
if err != nil { if err != nil {
logger.Error("CreateBetReq failed", "error", err) logger.Error("CreateBetReq failed", "error", err)

View File

@ -57,7 +57,7 @@ func CreateTicket(logger *slog.Logger, ticketSvc *ticket.Service,
// TODO Validate Outcomes Here and make sure they didn't expire // TODO Validate Outcomes Here and make sure they didn't expire
ticket, err := ticketSvc.CreateTicket(c.Context(), domain.CreateTicket{ ticket, err := ticketSvc.CreateTicket(c.Context(), domain.CreateTicket{
Amount: domain.Currency(req.Amount), Amount: domain.ToCurrency(req.Amount),
TotalOdds: req.TotalOdds, TotalOdds: req.TotalOdds,
}) })
if err != nil { if err != nil {

View File

@ -96,7 +96,7 @@ func CreateTransaction(logger *slog.Logger, transactionSvc *transaction.Service,
} }
transaction, err := transactionSvc.CreateTransaction(c.Context(), domain.CreateTransaction{ transaction, err := transactionSvc.CreateTransaction(c.Context(), domain.CreateTransaction{
Amount: domain.Currency(req.Amount), Amount: domain.ToCurrency(req.Amount),
BranchID: req.BranchID, BranchID: req.BranchID,
CashierID: req.CashierID, CashierID: req.CashierID,
BetID: req.BetID, BetID: req.BetID,

View File

@ -64,10 +64,14 @@ func convertTransfer(transfer domain.Transfer) TransferWalletRes {
} }
type CreateTransferReq struct { type CreateTransferReq struct {
Amount float64 `json:"amount" example:"100.0"` Amount float32 `json:"amount" example:"100.0"`
PaymentMethod string `json:"payment_method" example:"cash"` PaymentMethod string `json:"payment_method" example:"cash"`
} }
type CreateRefillReq struct {
Amount float32 `json:"amount" example:"100.0"`
}
// GetTransfersByWallet godoc // GetTransfersByWallet godoc
// @Summary Get transfer by wallet // @Summary Get transfer by wallet
// @Description Get transfer by wallet // @Description Get transfer by wallet
@ -165,7 +169,7 @@ func TransferToWallet(logger *slog.Logger, walletSvc *wallet.Service, branchSvc
return nil return nil
} }
transfer, err := walletSvc.TransferToWallet(c.Context(), senderID, receiverID, domain.Currency(req.Amount), domain.PaymentMethod(req.PaymentMethod), domain.ValidInt64{Value: userID, Valid: true}) transfer, err := walletSvc.TransferToWallet(c.Context(), senderID, receiverID, domain.ToCurrency(req.Amount), domain.PaymentMethod(req.PaymentMethod), domain.ValidInt64{Value: userID, Valid: true})
if !ok { if !ok {
response.WriteJSON(c, fiber.StatusInternalServerError, "Transfer Failed", err, nil) response.WriteJSON(c, fiber.StatusInternalServerError, "Transfer Failed", err, nil)
@ -210,10 +214,10 @@ func RefillWallet(logger *slog.Logger, walletSvc *wallet.Service, validator *cus
return response.WriteJSON(c, fiber.StatusUnauthorized, "Unauthorized access", nil, nil) return response.WriteJSON(c, fiber.StatusUnauthorized, "Unauthorized access", nil, nil)
} }
var req CreateTransferReq var req CreateRefillReq
if err := c.BodyParser(&req); err != nil { if err := c.BodyParser(&req); err != nil {
logger.Error("CreateTransferReq failed", "error", err) logger.Error("CreateRefillReq failed", "error", err)
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": "Invalid request", "error": "Invalid request",
}) })
@ -226,8 +230,8 @@ func RefillWallet(logger *slog.Logger, walletSvc *wallet.Service, validator *cus
} }
transfer, err := walletSvc.RefillWallet(c.Context(), domain.CreateTransfer{ transfer, err := walletSvc.RefillWallet(c.Context(), domain.CreateTransfer{
Amount: domain.Currency(req.Amount), Amount: domain.ToCurrency(req.Amount),
PaymentMethod: domain.PaymentMethod(req.PaymentMethod), PaymentMethod: domain.TRANSFER_BANK,
ReceiverWalletID: receiverID, ReceiverWalletID: receiverID,
CashierID: domain.ValidInt64{ CashierID: domain.ValidInt64{
Value: userID, Value: userID,

View File

@ -57,7 +57,6 @@ func (a *App) initAppRoutes() {
a.fiber.Get("/company/:id/branch", handlers.GetBranchByCompanyID(a.logger, a.branchSvc, a.validator)) a.fiber.Get("/company/:id/branch", handlers.GetBranchByCompanyID(a.logger, a.branchSvc, a.validator))
a.fiber.Get("/prematch/odds/:event_id", handlers.GetPrematchOdds(a.logger, a.prematchSvc)) a.fiber.Get("/prematch/odds/:event_id", handlers.GetPrematchOdds(a.logger, a.prematchSvc))
a.fiber.Get("/prematch/odds", handlers.GetALLPrematchOdds(a.logger, a.prematchSvc)) a.fiber.Get("/prematch/odds", handlers.GetALLPrematchOdds(a.logger, a.prematchSvc))
a.fiber.Get("/prematch/odds/raw/:raw_odds_id", handlers.GetRawOddsByID(a.logger, a.prematchSvc)) a.fiber.Get("/prematch/odds/raw/:raw_odds_id", handlers.GetRawOddsByID(a.logger, a.prematchSvc))
@ -104,7 +103,7 @@ func (a *App) initAppRoutes() {
// /transfer/wallet - transfer from one wallet to another wallet // /transfer/wallet - transfer from one wallet to another wallet
a.fiber.Post("/transfer/wallet/:id", a.authMiddleware, handlers.TransferToWallet(a.logger, a.walletSvc, a.branchSvc, a.validator)) a.fiber.Post("/transfer/wallet/:id", a.authMiddleware, handlers.TransferToWallet(a.logger, a.walletSvc, a.branchSvc, a.validator))
a.fiber.Get("/transfer/wallet/:id", a.authMiddleware, handlers.GetTransfersByWallet(a.logger, a.walletSvc, a.validator)) a.fiber.Get("/transfer/wallet/:id", a.authMiddleware, handlers.GetTransfersByWallet(a.logger, a.walletSvc, a.validator))
a.fiber.Get("/transfer/refill/:id", a.authMiddleware, handlers.RefillWallet(a.logger, a.walletSvc, a.validator)) a.fiber.Post("/transfer/refill/:id", a.authMiddleware, handlers.RefillWallet(a.logger, a.walletSvc, a.validator))
// Transactions // Transactions
a.fiber.Post("/transaction", a.authMiddleware, handlers.CreateTransaction(a.logger, a.transactionSvc, a.validator)) a.fiber.Post("/transaction", a.authMiddleware, handlers.CreateTransaction(a.logger, a.transactionSvc, a.validator))

View File

@ -9,7 +9,7 @@ sql:
sql_package: "pgx/v5" sql_package: "pgx/v5"
out: "./gen/db" out: "./gen/db"
emit_exported_queries: true emit_exported_queries: true
emit_json_tags: false emit_json_tags: true
overrides: overrides:
- db_type: "uuid" - db_type: "uuid"
go_type: "github.com/google/uuid.UUID" go_type: "github.com/google/uuid.UUID"