-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
58 lines (51 loc) · 1.9 KB
/
models.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package models
import (
"database/sql"
"time"
"github.com/golang-jwt/jwt/v4"
)
// Note struct
type Note struct {
ID uint64 `json:"id" gorm:"primary_key,autoIncrement,not null"`
Title string `json:"title,omitempty"`
Content string `json:"content" gorm:"not null"`
Username string `json:"username" gorm:"not null"`
Archived bool `json:"archived,omitempty"`
CreatedAt time.Time `json:"created_at" gorm:"not null"`
UpdatedAt time.Time `json:"updated_at" gorm:"index,not null"`
}
// User is a user of the application
type User struct {
ID uint `json:"id" gorm:"primary_key,autoIncrement,not null"`
FirstName string `json:"first_name" gorm:"not null"`
MiddleName string `json:"middle_name,omitempty"`
LastName string `json:"last_name" gorm:"not null"`
Username string `json:"username" gorm:"unique,not null"`
Email string `json:"email" gorm:"unique"`
DOB time.Time `json:"dob" gorm:"not null"`
Password string `json:"password" gorm:"not null"`
Role string `json:"role" gorm:"not null"`
Level int `json:"level" gorm:"not null"`
CreatedAt time.Time `json:"created_at" gorm:"not null"`
UpdatedAt time.Time `json:"updated_at" gorm:"not null"`
DeletedAt sql.NullTime `json:"deleted_at" gorm:"index,not null"`
}
// Create a struct that models the structure of a user in the request body
type Credentials struct {
Username string `json:"username,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password"`
}
// Claims
type Claims struct {
Username string `json:"username"`
Role string `json:"role"`
Level int `json:"level"`
jwt.RegisteredClaims
}
// Config is the configuration for CLI
type Config struct {
Username string `json:"username,omitempty"`
Token string `json:"token,omitempty"`
APIToken string `json:"api_token,omitempty"`
}