src/app/models.go (view raw)
1package app
2
3import (
4 "time"
5)
6
7type Bookmaker struct {
8 ID uint `json:"id"`
9 CreatedAt time.Time `json:"created_at"`
10 UpdatedAt time.Time `json:"updated_at"`
11
12 Name string `json:"name" gorm:"not null" `
13 Exchange bool `json:"exchange" gorm:"not null" `
14 DefaultCommission uint `json:"default_commission" gorm:"not null"`
15}
16
17type Account struct {
18 ID uint `json:"id"`
19 CreatedAt time.Time `json:"created_at"`
20 UpdatedAt time.Time `json:"updated_at"`
21
22 Name string `json:"name" gorm:"not null"`
23}
24
25type Record struct {
26 ID uint `json:"id" gorm:"primaryKey"`
27 CreatedAt time.Time `json:"created_at"`
28 UpdatedAt time.Time `json:"updated_at"`
29
30 Done bool `json:"done" gorm:"not null"`
31 Type string `json:"type" gorm:"not null"`
32 Description string `json:"description" gorm:"not null"`
33
34 Date *time.Time `json:"date" gorm:"-"`
35 Value *int `json:"value" gorm:"-"`
36
37 Entries []Entry `json:"entries" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
38}
39
40type Entry struct {
41 ID uint `json:"id"`
42 CreatedAt time.Time `json:"created_at"`
43 UpdatedAt time.Time `json:"updated_at"`
44
45 RecordID uint `json:"record_id" gorm:"not null"`
46 BookmakerID uint `json:"bookmaker_id" gorm:"not null"`
47 AccountID uint `json:"account_id" gorm:"not null"`
48 Amount uint `json:"amount" gorm:"not null"` // In cents (ex: 100 = 1.00)
49 Refund uint `json:"refund" gorm:"not null"` // In cents (ex: 100 = 1.00)
50 Bonus uint `json:"bonus" gorm:"not null"` // In cents (ex: 50 = 0.50)
51 Commission uint `json:"commission" gorm:"not null"` // In cents (ex: 4.5% = 450)
52
53 Odds *uint `json:"odds" gorm:"-"`
54 Won *bool `json:"won" gorm:"-"`
55 Date *time.Time `json:"date" gorm:"-"`
56 Value *int `json:"value" gorm:"-"`
57
58 Bookmaker Bookmaker `json:"bookmaker" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
59 Account Account `json:"account" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
60 SubEntries []SubEntry `json:"sub_entries" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
61}
62
63type SubEntry struct {
64 ID uint `json:"id"`
65 CreatedAt time.Time `json:"created_at"`
66 UpdatedAt time.Time `json:"updated_at"`
67
68 EntryID uint `json:"entry_id" gorm:"not null"`
69 Description string `json:"description" gorm:"not null"`
70 Odds uint `json:"odds" gorm:"not null"` // In cents (ex: 200 = 2.00)
71 Won bool `json:"won" gorm:"not null"`
72 Date time.Time `json:"date" gorm:"not null;default:current_timestamp"`
73
74 Value *int `json:"value" gorm:"-"`
75}