Refactor and remove sqlite and replace with MySQL
This commit is contained in:
14
internal/models/audit.go
Normal file
14
internal/models/audit.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type AuditEntry struct {
|
||||
ID int
|
||||
UserID int
|
||||
Username string
|
||||
Action string
|
||||
Path string
|
||||
IP string
|
||||
UserAgent string
|
||||
Timestamp time.Time
|
||||
}
|
||||
40
internal/models/config.go
Normal file
40
internal/models/config.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package models
|
||||
|
||||
type Config struct {
|
||||
CSRF struct {
|
||||
CSRFKey string `json:"csrfKey"`
|
||||
} `json:"csrf"`
|
||||
|
||||
Database struct {
|
||||
Server string `json:"server"`
|
||||
Port int `json:"port"`
|
||||
DatabaseNamed string `json:"databaseName"`
|
||||
MaxOpenConnections int `json:"maxOpenConnections"`
|
||||
MaxIdleConnections int `json:"maxIdleConnections"`
|
||||
ConnectionMaxLifetime string `json:"connectionMaxLifetime"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
HttpServer struct {
|
||||
Port int `json:"port"`
|
||||
Address string `json:"address"`
|
||||
ProductionMode bool `json:"productionMode"`
|
||||
} `json:"httpServer"`
|
||||
|
||||
License struct {
|
||||
APIURL string `json:"apiUrl"`
|
||||
APIKey string `json:"apiKey"`
|
||||
} `json:"license"`
|
||||
|
||||
Session struct {
|
||||
AuthKeyPath string `json:"authKeyPath"`
|
||||
EncryptionKeyPath string `json:"encryptionKeyPath"`
|
||||
Name string `json:"name"`
|
||||
} `json:"session"`
|
||||
|
||||
Site struct {
|
||||
SiteName string `json:"siteName"`
|
||||
CopyrightYearStart int `json:"copyrightYearStart"`
|
||||
} `json:"site"`
|
||||
}
|
||||
25
internal/models/draw.go
Normal file
25
internal/models/draw.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
type DrawSummary struct {
|
||||
Id int
|
||||
GameType string
|
||||
DrawDate string
|
||||
BallSet string
|
||||
Machine string
|
||||
PrizeSet bool
|
||||
}
|
||||
|
||||
type ThunderballResult struct {
|
||||
Id int
|
||||
DrawDate string
|
||||
Machine string
|
||||
BallSet int
|
||||
Ball1 int
|
||||
Ball2 int
|
||||
Ball3 int
|
||||
Ball4 int
|
||||
Ball5 int
|
||||
Thunderball int
|
||||
|
||||
SortedBalls []int
|
||||
}
|
||||
9
internal/models/machine.go
Normal file
9
internal/models/machine.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package models
|
||||
|
||||
type MachineUsage struct {
|
||||
Machine string
|
||||
DrawsUsed int
|
||||
PctOfDraws float64
|
||||
FirstUsed string
|
||||
LastUsed string
|
||||
}
|
||||
49
internal/models/match.go
Normal file
49
internal/models/match.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package models
|
||||
|
||||
type MatchTicket struct {
|
||||
ID int
|
||||
GameType string
|
||||
DrawDate string
|
||||
Balls []int
|
||||
BonusBalls []int
|
||||
}
|
||||
|
||||
type DrawResult struct {
|
||||
DrawID int
|
||||
GameType string
|
||||
DrawDate string
|
||||
Balls []int
|
||||
BonusBalls []int
|
||||
}
|
||||
|
||||
type MatchResult struct {
|
||||
MatchedMain int
|
||||
MatchedBonus int
|
||||
PrizeTier string
|
||||
IsWinner bool
|
||||
MatchedDrawID int
|
||||
|
||||
PrizeAmount float64
|
||||
PrizeLabel string
|
||||
}
|
||||
|
||||
type PrizeRule struct {
|
||||
Game string
|
||||
MainMatches int
|
||||
BonusMatches int
|
||||
Tier string
|
||||
}
|
||||
|
||||
type MatchRunStats struct {
|
||||
TicketsMatched int
|
||||
WinnersFound int
|
||||
}
|
||||
|
||||
type MatchLog struct {
|
||||
ID int
|
||||
TriggeredBy string
|
||||
RunAt string
|
||||
TicketsMatched int
|
||||
WinnersFound int
|
||||
Notes string
|
||||
}
|
||||
15
internal/models/prediction.go
Normal file
15
internal/models/prediction.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type NextMachineBallsetPrediction struct {
|
||||
NextDrawDate string
|
||||
CurrentMachine string
|
||||
EstimatedNextMachine string
|
||||
MachineTransitionPct float64
|
||||
CurrentBallset sql.NullString
|
||||
EstimatedNextBallset sql.NullString
|
||||
BallsetTransitionPct sql.NullFloat64
|
||||
}
|
||||
18
internal/models/statistics.go
Normal file
18
internal/models/statistics.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package models
|
||||
|
||||
type TopNum struct {
|
||||
Number int
|
||||
Frequency int
|
||||
}
|
||||
|
||||
type Pair struct {
|
||||
A int
|
||||
B int
|
||||
Frequency int
|
||||
}
|
||||
|
||||
type ZScore struct {
|
||||
Ball int
|
||||
Recent int
|
||||
Z float64
|
||||
}
|
||||
41
internal/models/syndicate.go
Normal file
41
internal/models/syndicate.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Syndicate struct {
|
||||
ID int
|
||||
OwnerID int
|
||||
Name string
|
||||
Description string
|
||||
CreatedBy int
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type SyndicateMember struct {
|
||||
ID int
|
||||
SyndicateID int
|
||||
UserID int
|
||||
Role string
|
||||
JoinedAt time.Time
|
||||
}
|
||||
|
||||
type SyndicateInvite struct {
|
||||
ID int
|
||||
SyndicateID int
|
||||
InvitedUserID int
|
||||
SentByUserID int
|
||||
Status string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type SyndicateInviteToken struct {
|
||||
Token string
|
||||
InvitedByUserID int
|
||||
AcceptedByUserID sql.NullInt64
|
||||
CreatedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
AcceptedAt sql.NullTime
|
||||
}
|
||||
10
internal/models/template.go
Normal file
10
internal/models/template.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
type TemplateData struct {
|
||||
User *User
|
||||
IsAdmin bool
|
||||
NotificationCount int
|
||||
Notifications []Notification
|
||||
MessageCount int
|
||||
Messages []Message
|
||||
}
|
||||
32
internal/models/ticket.go
Normal file
32
internal/models/ticket.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package models
|
||||
|
||||
type Ticket struct {
|
||||
Id int
|
||||
UserId int
|
||||
SyndicateId *int
|
||||
GameType string
|
||||
DrawDate string
|
||||
Ball1 int
|
||||
Ball2 int
|
||||
Ball3 int
|
||||
Ball4 int
|
||||
Ball5 int
|
||||
Ball6 int
|
||||
Bonus1 *int
|
||||
Bonus2 *int
|
||||
PurchaseMethod string
|
||||
PurchaseDate string
|
||||
ImagePath string
|
||||
Duplicate bool
|
||||
MatchedMain int
|
||||
MatchedBonus int
|
||||
PrizeTier string
|
||||
IsWinner bool
|
||||
|
||||
// Used only for display these are not stored in the DB, they mirror MatchTicket structure but are populated on read.
|
||||
Balls []int
|
||||
BonusBalls []int
|
||||
MatchedDraw DrawResult
|
||||
PrizeAmount float64 `db:"prize_amount"`
|
||||
PrizeLabel string `db:"prize_label"`
|
||||
}
|
||||
34
internal/models/user.go
Normal file
34
internal/models/user.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Id int
|
||||
Username string
|
||||
PasswordHash string
|
||||
IsAdmin bool
|
||||
}
|
||||
|
||||
// ToDo: should be in a notification model?
|
||||
type Notification struct {
|
||||
ID int
|
||||
UserId int
|
||||
Subject string
|
||||
Body string
|
||||
IsRead bool
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
// ToDo: should be in a message model?
|
||||
type Message struct {
|
||||
ID int
|
||||
SenderId int
|
||||
RecipientId int
|
||||
Subject string
|
||||
Message string
|
||||
IsRead bool
|
||||
CreatedAt time.Time
|
||||
ArchivedAt *time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user