package dto import ( "errors" "github.com/gin-gonic/gin" "github.com/go-admin-team/go-admin-core/sdk/api" "go-admin/app/{{.PackageName}}/models" "go-admin/common/dto" common "go-admin/common/models" ) type {{.ClassName}}Search 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}}Search) GetNeedSearch() interface{} { return *m } type {{.ClassName}}Control 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 }} } func (s *{{.ClassName}}Control) Generate(model *models.SysConfig) { {{- 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}}Control) GetId() interface{} { return s.{{.PkGoField}} } type {{.ClassName}}ById struct { Id int `uri:"id"` Ids []int `json:"ids"` } func (s *{{.ClassName}}ById) GetId() interface{} { if len(s.Ids) > 0 { s.Ids = append(s.Ids, s.Id) return s.Ids } return s.Id } func (s *{{.ClassName}}ById) Generate() *{{.ClassName}}ById { o := *s return &o }