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
package dto
import (
"go-admin/app/{{.PackageName}}/models"
"go-admin/common/dto"
common "go-admin/common/models"
{{- $bb := false -}}
{{- range .Columns -}}
{{$z := .IsQuery}}
{{- if ($z) }}
{{if eq .GoType "time.Time"}}{{- $bb = true -}}{{- end -}}
{{- end -}}
{{- end -}}
{{- range .Columns -}}
{{if eq .GoType "time.Time"}}{{- $bb = true -}}{{- end -}}
{{- end -}}
{{- if eq $bb true -}}
"time"
{{- end }}
)
type {{.ClassName}}GetPageReq struct {
dto.Pagination `search:"-"`
{{- $tablename := .TBName -}}
{{- range .Columns -}}
{{$z := .IsQuery}}
{{- if ($z) }}
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}" search:"type:{{if eq .QueryType "EQ"}}exact{{ else if eq .QueryType "NE"}}iexact{{ else if eq .QueryType "LIKE"}}contains{{ else if eq .QueryType "GT"}}gt{{ else if eq .QueryType "GTE"}}gte{{ else if eq .QueryType "LT"}}lt{{ else if eq .QueryType "LTE"}}lte{{- end }};column:{{.ColumnName}};table:{{$tablename}}" comment:"{{.ColumnComment}}"`
{{- end }}
{{- end }}
{{.ClassName}}Order
}
type {{.ClassName}}Order struct {
{{- $tablename := .TBName -}}
{{- range .Columns -}}
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}Order" search:"type:order;column:{{.ColumnName}};table:{{$tablename}}"`
{{ end }}
}
func (m *{{.ClassName}}GetPageReq) GetNeedSearch() interface{} {
return *m
}
type {{.ClassName}}InsertReq struct {
{{- range .Columns -}}
{{$x := .Pk}}
{{- if ($x) }}
{{.GoField}} {{.GoType}} `json:"-" comment:"{{.ColumnComment}}"` // {{.ColumnComment}}
{{- else if eq .GoField "CreatedAt" -}}
{{- else if eq .GoField "UpdatedAt" -}}
{{- else if eq .GoField "DeletedAt" -}}
{{- else if eq .GoField "CreateBy" -}}
{{- else if eq .GoField "UpdateBy" -}}
{{- else }}
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
{{- end -}}
{{- end }}
common.ControlBy
}
func (s *{{.ClassName}}InsertReq) Generate(model *models.{{.ClassName}}) {
{{- range .Columns -}}
{{$x := .Pk}}
{{- if ($x) }}
if s.{{.GoField}} == 0 {
model.Model = common.Model{ {{.GoField}}: s.{{.GoField}} }
}
{{- else if eq .GoField "CreatedAt" -}}
{{- else if eq .GoField "UpdatedAt" -}}
{{- else if eq .GoField "DeletedAt" -}}
{{- else if eq .GoField "CreateBy" -}}
{{- else if eq .GoField "UpdateBy" -}}
{{- else }}
model.{{.GoField}} = s.{{.GoField}}
{{- end -}}
{{- end }}
}
func (s *{{.ClassName}}InsertReq) GetId() interface{} {
return s.{{.PkGoField}}
}
type {{.ClassName}}UpdateReq struct {
{{- range .Columns -}}
{{$x := .Pk}}
{{- if ($x) }}
{{.GoField}} {{.GoType}} `uri:"{{.JsonField}}" comment:"{{.ColumnComment}}"` // {{.ColumnComment}}
{{- else if eq .GoField "CreatedAt" -}}
{{- else if eq .GoField "UpdatedAt" -}}
{{- else if eq .GoField "DeletedAt" -}}
{{- else if eq .GoField "CreateBy" -}}
{{- else if eq .GoField "UpdateBy" -}}
{{- else }}
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
{{- end -}}
{{- end }}
common.ControlBy
}
func (s *{{.ClassName}}UpdateReq) Generate(model *models.{{.ClassName}}) {
{{- range .Columns -}}
{{$x := .Pk}}
{{- if ($x) }}
if s.{{.GoField}} == 0 {
model.Model = common.Model{ {{.GoField}}: s.{{.GoField}} }
}
{{- else if eq .GoField "CreatedAt" -}}
{{- else if eq .GoField "UpdatedAt" -}}
{{- else if eq .GoField "DeletedAt" -}}
{{- else if eq .GoField "CreateBy" -}}
{{- else if eq .GoField "UpdateBy" -}}
{{- else }}
model.{{.GoField}} = s.{{.GoField}}
{{- end -}}
{{- end }}
}
func (s *{{.ClassName}}UpdateReq) GetId() interface{} {
return s.{{.PkGoField}}
}
// {{.ClassName}}GetReq 功能获取请求参数
type {{.ClassName}}GetReq struct {
{{- range .Columns -}}
{{$x := .Pk}}
{{- if ($x) }}
{{.GoField}} {{.GoType}} `uri:"{{.JsonField}}"`
{{- end }}
{{- end }}
}
func (s *{{.ClassName}}GetReq) GetId() interface{} {
return s.{{.PkGoField}}
}
// {{.ClassName}}DeleteReq 功能删除请求参数
type {{.ClassName}}DeleteReq struct {
Ids []int `json:"ids"`
}
func (s *{{.ClassName}}DeleteReq) GetId() interface{} {
return s.Ids
}