Yimaru-BackEnd/internal/domain/result.go
Samuel Tariku c00110a503 feat: Enhance league, odds, events and bets functionality
- Updated league handling to ensure valid page size checks and improved error handling for sport ID parsing.
- Introduced new endpoint to update global league settings with comprehensive validation and error logging.
- Refactored odds settings management, including saving, removing, and updating odds settings with enhanced validation.
- Added tenant slug retrieval by token, ensuring proper user and company validation.
- Improved middleware to check for active company status and adjusted route permissions for various endpoints.
- Added SQL script to fix auto-increment desynchronization across multiple tables.
2025-10-05 23:45:31 +03:00

122 lines
2.5 KiB
Go

package domain
import (
"fmt"
"time"
"github.com/jackc/pgx/v5/pgtype"
)
type MarketConfig struct {
Sport string
MarketCategories map[string]bool
MarketTypes map[int64]bool
}
type Result struct {
ID int64
BetOutcomeID int64
EventID int64
OddID int64
MarketID int64
Status OutcomeStatus
Score string
FullTimeScore string
HalfTimeScore string
SS string
Scores map[string]ScoreResultResponse
CreatedAt time.Time
UpdatedAt time.Time
}
type CreateResult struct {
BetOutcomeID int64
EventID int64
OddID int64
MarketID int64
Status OutcomeStatus
Score string
}
type OutcomeStatus int32
const (
OUTCOME_STATUS_PENDING OutcomeStatus = 0
OUTCOME_STATUS_WIN OutcomeStatus = 1
OUTCOME_STATUS_LOSS OutcomeStatus = 2
OUTCOME_STATUS_VOID OutcomeStatus = 3 //Give Back
OUTCOME_STATUS_HALF OutcomeStatus = 4 //Half Win and Half Given Back
OUTCOME_STATUS_ERROR OutcomeStatus = 5 //Half Win and Half Given Back
)
func (o OutcomeStatus) IsValid() bool {
switch o {
case OUTCOME_STATUS_PENDING,
OUTCOME_STATUS_WIN,
OUTCOME_STATUS_LOSS,
OUTCOME_STATUS_VOID,
OUTCOME_STATUS_HALF,
OUTCOME_STATUS_ERROR:
return true
default:
return false
}
}
func ParseOutcomeStatus(val int) (OutcomeStatus, error) {
o := OutcomeStatus(val)
if !o.IsValid() {
return 0, fmt.Errorf("invalid OutcomeStatus: %d", val)
}
return o, nil
}
func (o *OutcomeStatus) String() string {
switch *o {
case OUTCOME_STATUS_PENDING:
return "PENDING"
case OUTCOME_STATUS_WIN:
return "WIN"
case OUTCOME_STATUS_LOSS:
return "LOSS"
case OUTCOME_STATUS_VOID:
return "VOID"
case OUTCOME_STATUS_HALF:
return "HALF"
case OUTCOME_STATUS_ERROR:
return "ERROR"
default:
return "UNKNOWN"
}
}
type ValidOutcomeStatus struct {
Value OutcomeStatus
Valid bool
}
func (v ValidOutcomeStatus) ToPG() pgtype.Int4 {
return pgtype.Int4{
Int32: int32(v.Value),
Valid: v.Valid,
}
}
type TimeStatus int32
const (
TIME_STATUS_NOT_STARTED TimeStatus = 0
TIME_STATUS_IN_PLAY TimeStatus = 1
TIME_STATUS_TO_BE_FIXED TimeStatus = 2
TIME_STATUS_ENDED TimeStatus = 3
TIME_STATUS_POSTPONED TimeStatus = 4
TIME_STATUS_CANCELLED TimeStatus = 5
TIME_STATUS_WALKOVER TimeStatus = 6
TIME_STATUS_INTERRUPTED TimeStatus = 7
TIME_STATUS_ABANDONED TimeStatus = 8
TIME_STATUS_RETIRED TimeStatus = 9
TIME_STATUS_SUSPENDED TimeStatus = 10
TIME_STATUS_DECIDED_BY_FA TimeStatus = 11
TIME_STATUS_REMOVED TimeStatus = 99
)