/
model.go
68 lines (61 loc) · 1.5 KB
/
model.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
62
63
64
65
66
67
68
package example
import (
"time"
)
type Book struct {
ID HashID `json:"id" desc:"书籍 ID"`
CreatedAt JSONTime `json:"created_at" desc:"创建时间"`
ISBN string `json:"isbn" desc:"ISBN"`
Title string `json:"title" desc:"书名"`
Authors []Author `json:"authors" desc:"作者"`
Press string `json:"press" desc:"出版社"`
PublishDate string `json:"publish_date" desc:"出版日期"`
Price float64 `json:"price" desc:"定价"`
Ignored bool `json:"-"`
}
type Author struct {
ID HashID `json:"id" desc:"作者 ID"`
CreatedAt time.Time `json:"created_at" desc:"创建时间"`
Name string `json:"name" desc:"姓名"`
Age int `json:"age" desc:"年龄"`
Sex int `json:"sex" desc:"性别(0-男,1-女)"`
}
var exampleBook = Book{
ID: 1,
CreatedAt: JSONTime(time.Now()),
ISBN: "9780262033848",
Title: "Introduction to Algorithms, 3rd Edition",
Authors: []Author{
{
ID: 1,
CreatedAt: time.Now(),
Name: "Thomas H. Cormen",
Age: 62,
Sex: 0,
},
{
ID: 2,
CreatedAt: time.Now(),
Name: "Charles E. Leiserson",
Age: 64,
Sex: 0,
},
{
ID: 3,
CreatedAt: time.Now(),
Name: "Ronald L. Rivest",
Age: 71,
Sex: 0,
},
{
ID: 4,
CreatedAt: time.Now(),
Name: "Clifford Stein",
Age: 52,
Sex: 0,
},
},
Press: "The MIT Press",
PublishDate: "2009-07-31",
Price: 94.00,
}