Merge branch 'dev' of github.com:wenjianzhang/go-admin into table/dev
This commit is contained in:
commit
c6735c4b1a
3 files changed
+28
-10
No files matched your search
@@ -17,19 +17,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type {{.ClassName}} struct {
|
type {{.ClassName}} struct {
|
||||||
|
gorm.Model
|
||||||
|
models.ControlBy
|
||||||
{{ range .Columns -}}
|
{{ range .Columns -}}
|
||||||
{{$x := .Pk}}
|
{{$x := .Pk}}
|
||||||
{{- if ($x) }}
|
{{- if ($x) }}
|
||||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};primary_key;AUTO_INCREMENT;"` // {{.ColumnComment}}
|
|
||||||
{{- else if eq .GoField "CreatedAt" -}}
|
{{- else if eq .GoField "CreatedAt" -}}
|
||||||
{{- else if eq .GoField "UpdatedAt" -}}
|
{{- else if eq .GoField "UpdatedAt" -}}
|
||||||
{{- else if eq .GoField "DeletedAt" -}}
|
{{- else if eq .GoField "DeletedAt" -}}
|
||||||
|
{{- else if eq .GoField "CreateBy" -}}
|
||||||
|
{{- else if eq .GoField "UpdateBy" -}}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` {{end -}}
|
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` {{end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
DataScope string `json:"dataScope" gorm:"-"`
|
DataScope string `json:"dataScope" gorm:"-"`
|
||||||
Params string `json:"params" gorm:"-"`
|
Params string `json:"params" gorm:"-"`
|
||||||
BaseModel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ({{.ClassName}}) TableName() string {
|
func ({{.ClassName}}) TableName() string {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go-admin/app/admin/models"
|
"go-admin/app/admin/models"
|
||||||
"go-admin/common/dto"
|
"go-admin/common/dto"
|
||||||
models2 "go-admin/common/models"
|
common "go-admin/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type {{.ClassName}}Search struct {
|
type {{.ClassName}}Search struct {
|
||||||
@@ -44,12 +44,18 @@ type {{.ClassName}}Control struct {
|
|||||||
{{ range .Columns -}}
|
{{ range .Columns -}}
|
||||||
{{$x := .Pk}}
|
{{$x := .Pk}}
|
||||||
{{- if ($x) }}
|
{{- if ($x) }}
|
||||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}""` // {{.ColumnComment}}
|
{{.GoField}} uint `json:"{{.JsonField}}"` // {{.ColumnComment}}
|
||||||
{{- else if eq .GoField "CreatedAt" -}}
|
{{- else if eq .GoField "CreatedAt" -}}
|
||||||
{{- else if eq .GoField "UpdatedAt" -}}
|
{{- else if eq .GoField "UpdatedAt" -}}
|
||||||
{{- else if eq .GoField "DeletedAt" -}}
|
{{- else if eq .GoField "DeletedAt" -}}
|
||||||
|
{{- else if eq .GoField "CreateBy" -}}
|
||||||
|
|
||||||
|
{{.GoField}} uint `json:"{{.JsonField}}"` // {{.ColumnComment}}
|
||||||
|
{{- else if eq .GoField "UpdateBy" -}}
|
||||||
|
|
||||||
|
{{.GoField}} uint `json:"{{.JsonField}}"` // {{.ColumnComment}}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}""` // {{.ColumnComment}}{{end -}}
|
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}"` // {{.ColumnComment}}{{end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,15 +68,21 @@ func (s *{{.ClassName}}Control) Generate() dto.Control {
|
|||||||
return &cp
|
return &cp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *{{.ClassName}}Control) GenerateM() (models2.ActiveRecord, error) {
|
func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
||||||
return &models.{{.ClassName}}{
|
return &models.{{.ClassName}}{
|
||||||
{{ range .Columns -}}
|
{{ range .Columns -}}
|
||||||
{{$x := .Pk}}
|
{{$x := .Pk}}
|
||||||
{{- if ($x) }}
|
{{- if ($x) }}
|
||||||
{{.GoField}}: s.{{.GoField}},
|
Model: gorm.Model{ID: s.Id},
|
||||||
{{- else if eq .GoField "CreatedAt" -}}
|
{{- else if eq .GoField "CreatedAt" -}}
|
||||||
{{- else if eq .GoField "UpdatedAt" -}}
|
{{- else if eq .GoField "UpdatedAt" -}}
|
||||||
{{- else if eq .GoField "DeletedAt" -}}
|
{{- else if eq .GoField "DeletedAt" -}}
|
||||||
|
{{- else if eq .GoField "CreateBy" -}}
|
||||||
|
ControlBy: common.ControlBy{
|
||||||
|
CreateBy: s.CreateBy,
|
||||||
|
UpdateBy: s.UpdateBy,
|
||||||
|
},
|
||||||
|
{{- else if eq .GoField "UpdateBy" -}}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{.GoField}}: s.{{.GoField}},
|
{{.GoField}}: s.{{.GoField}},
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -91,6 +103,6 @@ func (s *{{.ClassName}}ById) Generate() dto.Control {
|
|||||||
return &cp
|
return &cp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *{{.ClassName}}ById) GenerateM() (models2.ActiveRecord, error) {
|
func (s *{{.ClassName}}ById) GenerateM() (common.ActiveRecord, error) {
|
||||||
return &models.{{.ClassName}}{}, nil
|
return &models.{{.ClassName}}{}, nil
|
||||||
}
|
}
|
||||||
@@ -12,19 +12,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type {{.ClassName}} struct {
|
type {{.ClassName}} struct {
|
||||||
|
gorm.Model
|
||||||
|
models.ControlBy
|
||||||
{{ range .Columns -}}
|
{{ range .Columns -}}
|
||||||
{{$x := .Pk}}
|
{{$x := .Pk}}
|
||||||
{{- if ($x) }}
|
{{- if ($x) }}
|
||||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};primary_key;AUTO_INCREMENT;"`
|
|
||||||
{{- else if eq .GoField "CreatedAt" -}}
|
{{- else if eq .GoField "CreatedAt" -}}
|
||||||
{{- else if eq .GoField "UpdatedAt" -}}
|
{{- else if eq .GoField "UpdatedAt" -}}
|
||||||
{{- else if eq .GoField "DeletedAt" -}}
|
{{- else if eq .GoField "DeletedAt" -}}
|
||||||
|
{{- else if eq .GoField "CreateBy" -}}
|
||||||
|
{{- else if eq .GoField "UpdateBy" -}}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` // {{end -}}
|
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` // {{end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
DataScope string `json:"dataScope" gorm:"-"`
|
DataScope string `json:"dataScope" gorm:"-"`
|
||||||
Params string `json:"params" gorm:"-"`
|
Params string `json:"params" gorm:"-"`
|
||||||
BaseModel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ({{.ClassName}}) TableName() string {
|
func ({{.ClassName}}) TableName() string {
|
||||||
|
|||||||
Reference in new issue
Block a user