/
types.go
152 lines (135 loc) · 4.19 KB
/
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package lib
// DatabaseType is the type of database to be used.
type DatabaseType string
const (
// DatabaseTypeMysql is the MySQL flavor of database
DatabaseTypeMysql DatabaseType = "mysql"
)
// Options are the available runtime flags
type Options uint
// Command is the command line functionality
type Command struct {
Options Options
}
// Changeset represents all of the changes in an environment and their changes
type Changeset struct {
ChangeFiles map[string]ChangeFile
Signature string
}
// ChangeFile represents both a physical file on the local file system
// along with the entry in the changefile database
type ChangeFile struct {
ID int64
DateCreated int64
Hash string
Name string
DVCSetID int64
IsRun bool
IsDeleted bool
Content string
FullPath string
Ordinal int
}
const (
// OptLogInfo triggers verbose logging
OptLogInfo = 1 << iota
// OptLogDebug triggers extremely verbose logging
OptLogDebug
// OptSilent suppresses all logging
OptSilent
// OptReverse reverses the function
OptReverse
// OptSummary shows a summary of the actions instead of a raw stdout dump
OptSummary
// OptClean cleans
OptClean
// OptForce forces
OptForce
)
// RoutesJSONContainer is a container for JSON Routes
type RoutesJSONContainer struct {
Routes map[string]*ControllerRoute `json:"routes"`
DTOs map[string]map[string]string `json:"dtos"`
Models map[string]map[string]string `json:"models"`
Aggregates map[string]map[string]string `json:"aggregates"`
Constants map[string][]string `json:"constants"`
}
// Controller represents a REST controller
type Controller struct {
Name string `json:"Name"`
Description string `json:"Description"`
Path string `json:"-"`
Routes []*ControllerRoute `json:"Routes"`
HasDTOsImport bool `json:"-"`
HasResponseImport bool `json:"-"`
PermCount int `json:"-"`
Package string `json:"Package"`
}
// ControllerRoute represents a route inside a REST controller
type ControllerRoute struct {
Name string `json:"Name"`
Description string `json:"Description"`
Raw string `json:"Path"`
Path string `json:"-"`
Method string `json:"Method"`
Params []ControllerRouteParam `json:"Params"`
Queries []ControllerRouteQuery `json:"Queries"`
IsAuth bool `json:"IsAuth"`
BodyType string `json:"BodyType"`
BodyFormat string `json:"BodyFormat"`
HasBody bool `json:"HasBody"`
ResponseType string `json:"ResponseType"`
ResponseFormat string `json:"ResponseFormat"`
ResponseCode int `json:"ResponseCode"`
Permission string `json:"Permission"`
}
// ControllerRouteParam represents a param inside a controller route
type ControllerRouteParam struct {
Name string
Pattern string
Type string
}
// ControllerRouteQuery represents a query inside a controller route
type ControllerRouteQuery struct {
Name string
Pattern string
Type string
VariableName string
ValueRaw string
}
// DocRoute is a route in the documentation
type DocRoute struct {
Name string
Description string
Method string
Path string
HasBody bool
BodyType string
BodyFormat string
ResponseType string
ResponseFormat string
ResponseCode int
}
func newDocRoute(route ControllerRoute) (docRoute *DocRoute) {
docRoute = &DocRoute{
Name: route.Name,
Description: route.Description,
Method: route.Method,
Path: route.Path,
HasBody: route.HasBody,
BodyType: route.BodyType,
}
return
}
// DocRouteParam represents a parameter inside a route for documentation
type DocRouteParam struct {
Name string
Pattern string
Type string
}
// DocRouteQuery represents a query inside a route for documentation
type DocRouteQuery struct {
Name string
Pattern string
Type string
}