74 lines
4.0 KiB
Plaintext
74 lines
4.0 KiB
Plaintext
// ==========================================================================
|
|
// GFast自动生成model操作代码。
|
|
// 生成日期:{{date "Y-m-d H:i:s"}}
|
|
// 生成路径: {{.table.PackageName}}/model/{{.table.TableName}}.go
|
|
// 生成人:{{.table.FunctionAuthor}}
|
|
// desc:{{.table.FunctionName}}
|
|
// company:云南奇讯科技有限公司
|
|
// ==========================================================================
|
|
////
|
|
package model
|
|
////
|
|
import (
|
|
{{if .table.HasTimeColumn}}
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
{{end}}
|
|
"github.com/gogf/gf/v2/util/gmeta"
|
|
)
|
|
|
|
////
|
|
// {{.table.ClassName}}InfoRes is the golang structure for table {{.table.TableName}}.
|
|
type {{.table.ClassName}}InfoRes struct {
|
|
gmeta.Meta `orm:"table:{{.table.TableName}}"`
|
|
{{range $index, $column := .table.Columns}}
|
|
{{if $column.IsPk}}{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `orm:"{{$column.ColumnName}},primary" json:"{{$column.HtmlField}}"` // {{$column.ColumnComment}} {{else}}{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `orm:"{{$column.ColumnName}}" json:"{{$column.HtmlField}}"` // {{$column.ColumnComment}} {{end}}
|
|
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
|
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
|
Linked{{$column.GoField}} *Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" json:"linked{{$column.GoField}}"`
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
}
|
|
|
|
////
|
|
{{range $ti, $linkedTable := .table.LinkedTables}}
|
|
type Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} struct {
|
|
gmeta.Meta `orm:"table:{{$linkedTable.TableName}}"`
|
|
{{range $ci, $linkedColumn := $linkedTable.RefColumns.Values}}
|
|
{{$linkedColumn.GoField}} {{if eq $linkedColumn.GoType "Time"}}*gtime.Time{{else}}{{$linkedColumn.GoType}}{{end}} `orm:"{{$linkedColumn.ColumnName}}" json:"{{$linkedColumn.HtmlField}}"` // {{$linkedColumn.ColumnComment}}
|
|
{{end}}
|
|
}
|
|
{{end}}
|
|
|
|
////
|
|
type {{.table.ClassName}}ListRes struct{
|
|
{{if eq .table.TplCategory "tree"}}
|
|
{{range $index, $column := .table.Columns}}
|
|
{{if or (eq $column.HtmlField $.table.TreeCode) (eq $column.HtmlField $.table.TreeParentCode) (eq $column.HtmlField $.table.TreeName) }}
|
|
{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}"`
|
|
{{end}}
|
|
{{end}}
|
|
{{range $index, $column := .table.Columns}}
|
|
{{if and $column.IsList (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }}
|
|
{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}"`
|
|
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
|
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
|
Linked{{$column.GoField}} *Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" json:"linked{{$column.GoField}}"`
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
{{else}}
|
|
{{if not .table.IsPkListable }}
|
|
{{.table.PkColumn.GoField}} {{.table.PkColumn.GoType}} `json:"{{.table.PkColumn.HtmlField}}"`
|
|
{{end}}
|
|
{{range $index, $column := .table.ListColumns}}
|
|
{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}"`
|
|
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
|
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
|
Linked{{$column.GoField}} *Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" json:"linked{{$column.GoField}}"`
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
} |