-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
40 lines (36 loc) · 1007 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"database/sql"
"math/rand"
"time"
)
type TransferRequest struct {
From int `json:"from"`
To int `json:"to"`
Amount int `json:"amount"`
Timestamp time.Time `json:"timestamp"`
}
type CreateAccountRequest struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
}
type Account struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
Number sql.NullInt64 `json:"number"`
Balance sql.NullInt64 `json:"balance"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func NewAccount(firstName, lastName, email string) *Account {
return &Account{
FirstName: firstName,
LastName: lastName,
Email: email,
Number: sql.NullInt64{Int64: int64(rand.Intn(100000)), Valid: true},
CreatedAt: time.Now().UTC(),
}
}