-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity.go
167 lines (143 loc) · 3.19 KB
/
entity.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package services
import (
"github.com/juxuny/yc/utils"
"html/template"
"strings"
)
type baseEntity struct{}
func (baseEntity) Lt() template.HTML {
return "<"
}
func (baseEntity) Gt() template.HTML {
return ">"
}
func (baseEntity) Le() template.HTML {
return "<="
}
func (baseEntity) Ge() template.HTML {
return ">="
}
type ServiceEntity struct {
baseEntity
ServiceName string
PackageName string
ServiceStruct string
ServiceDir string
// ProtoFileName is base file name, without file extension
ProtoFileName string
PackageAlias string
CommandLineVersion string
Version string
Level string
ClassName string
ServiceCode string
}
func NewServiceEntity(serviceName string, commandLineVersion string) ServiceEntity {
ret := ServiceEntity{
ServiceDir: strings.ReplaceAll(utils.ToUnderLine(serviceName), "_", "-"),
ServiceName: serviceName,
PackageName: utils.ToUnderLine(serviceName),
ProtoFileName: utils.ToUnderLine(serviceName),
ServiceStruct: utils.ToHump(serviceName),
PackageAlias: utils.ToLowerFirst(utils.ToHump(serviceName)),
ClassName: utils.ToUpperFirst(utils.ToHump(serviceName)),
CommandLineVersion: commandLineVersion,
}
return ret
}
type ValidatorEntity struct {
ServiceEntity
Messages []ValidatorMessage
}
type ValidatorFormula struct {
Pattern string
RefValue string
}
type ValidatorMessageField struct {
Name string
Formulas []ValidatorFormula
ParamName string
Error string
}
type ValidatorMessage struct {
Name string
Fields []ValidatorMessageField
Desc string
}
type HandlerInitEntity struct {
baseEntity
ServiceEntity
GoModuleName string
}
type MethodEntity struct {
HandlerInitEntity
Group string
MethodName string
Request string
Response string
UseAuth bool
Desc string
Api string
}
type EntrypointEntity struct {
baseEntity
ServiceEntity
GoModuleName string
ServiceModuleName string
IgnoreAuthList []string
OpenApiList []string
}
type ModelField struct {
baseEntity
TableName string
ModelName string
FieldName string
OrmFieldName string
JsonFieldName string
ModelDataType string
Ignore bool
HasIndex bool
HasUnique bool
HasDeletedAt bool
HasPrimaryKey bool
HasAutoIncrement bool
CSharpDataType string
Desc string
}
type Model struct {
Fields []ModelField
TableName string
ModelName string
TableNameWithoutServicePrefix string
HasDeletedAt bool
Refs []RefModel
Desc string
}
func (t Model) ToRefModel() RefModel {
return RefModel{
ModelName: t.ModelName,
Fields: t.Fields,
}
}
type RefModel struct {
ModelName string
Fields []ModelField
}
type ModelEntity struct {
ServiceEntity
GoModuleName string
CSharpModelNamespace string
CSharpBaseNamespace string
Model
}
type ClientSdkEntity struct {
Methods []MethodEntity
ServiceEntity
}
type CloneMessage struct {
Name string
}
type CloneEntity struct {
ServiceEntity
Messages []CloneMessage
}