mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[修复]代码生成
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
package api
|
||||
// ==========================================================================
|
||||
// 生成日期:{{.CreatedAt}}
|
||||
// 生成路径: apps/{{.PackageName}}/api/{{.TableName}}.go
|
||||
|
||||
@@ -14,8 +14,15 @@ package entity
|
||||
{{if $hasGTime -}}import "time"{{- end }}
|
||||
|
||||
type {{.ClassName}} struct {
|
||||
{{range $index, $column := .Columns}}
|
||||
{{if eq $column.IsPk "1"}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"primary_key;{{if eq $column.IsIncrement "1"}}AUTO_INCREMENT{{end}}" json:"{{$column.JsonField}}"` // {{$column.ColumnComment}} {{else}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"{{$column.ColumnName}};type:{{$column.ColumnType}};comment:{{$column.ColumnComment}}" json:"{{$column.JsonField}}" {{if eq $column.IsRequired "1"}}binding:"required"{{end}}` // {{$column.ColumnComment}} {{end}}
|
||||
{{- range $index, $column := .Columns}}
|
||||
{{- if eq $column.IsPk "1" }}
|
||||
{{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"primary_key;{{if eq $column.IsIncrement "1"}}AUTO_INCREMENT{{end}}" json:"{{$column.JsonField}}"` // {{$column.ColumnComment}}
|
||||
{{- else if ne $column.LinkTableName ""}}
|
||||
{{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"{{$column.ColumnName}};type:{{$column.ColumnType}};comment:{{$column.ColumnComment}}" json:"{{$column.JsonField}}"`
|
||||
{{$column.LinkTableClass}} {{$column.LinkTableClass}} `json:"{{$column.LinkTablePackage}}" gorm:"foreignKey:{{$column.LinkLabelName}};references:{{$column.GoField}};"`
|
||||
{{- else }}
|
||||
{{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"{{$column.ColumnName}};type:{{$column.ColumnType}};comment:{{$column.ColumnComment}}" json:"{{$column.JsonField}}" {{if eq $column.IsRequired "1"}}binding:"required"{{- end }}` // {{$column.ColumnComment}}
|
||||
{{- end -}}
|
||||
{{end}}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,9 @@ func (m *{{.BusinessName}}ModelImpl) FindListPage(page, pageSize int, data entit
|
||||
{{- if eq $column.ColumnName "delete_time" }}
|
||||
db.Where("delete_time IS NULL")
|
||||
{{- end -}}
|
||||
{{- if ne $column.LinkTableName "" }}
|
||||
db.Preload("{{$column.LinkTableClass}}")
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
err := db.Count(&total).Error
|
||||
err = db.Order("create_time").Limit(pageSize).Offset(offset).Find(&list).Error
|
||||
|
||||
Reference in New Issue
Block a user