-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
61 lines (50 loc) · 1.32 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
59
60
61
package main
import (
"time"
"github.com/m4rw3r/uuid"
)
// Structure during the post.
type ThoughtsPost struct {
Title string `json:"title"`
Thought string `json:"content"`
}
// Structure during the post.
type ThoughtWithLabelPost struct {
Title string `json:"title"`
Thought string `json:"content"`
Label int `json:"label_id"`
}
type LabelsPost struct {
Hexcode string `json:"hex"`
Description string `json:"description"`
}
// Thought : Main structure of the system.
type Thought struct {
ID ThoughtsID `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
CreateTime time.Time `json:"create_time"`
UpdateTime time.Time `json:"update_time"`
}
// Label : A categorical overview associated with the thought.
type Label struct {
Id int `json:"id"` // Should be auto incremental.
Hexcode string `json:"hex"` // Needs to have default.
Description string `json:"description"`
}
// ThoughtWithLabels : Thought attahceds with labels.
type ThoughtWithLabels struct {
Thought Thought `json:"thought"`
Labels Label `json:"labels"`
}
type ThoughtLabel struct {
Thought ThoughtsID `json:"thought_id"`
Label int `json:"label_id"`
}
type ThoughtsID struct {
uuid.UUID
}
func GenThoughtID() ThoughtsID {
id, _ := uuid.V4()
return ThoughtsID{id}
}