123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package model
- import (
- "time"
- "ulink-admin/pkg/base"
- )
- type {{.ClassNameUpper}} struct { {{range $index, $item := .Columns}}
- {{$item.ColumnNameUpper}} {{$item.GoType}} `excel:"name={{$item.ColumnComment}} {{if eq $item.Source "3"}},format={{$item.Input}}{{end}}" xorm:"{{if $item.ColumnKey }}pk {{if $item.Extra }}autoincr{{end}}{{else}}{{$item.ColumnType}}{{end}} {{if eq $item.IsNullable "NO"}} notnull {{end}} {{if $item.ColumnDefault}}default{{if eq $item.GoType "string"}}('{{$item.ColumnDefault}}'){{else}}({{$item.ColumnDefault}}){{end}}{{end}} comment('{{$item.ColumnComment}}')" json:"{{$item.ColumnNameLower}}" {{if eq $item.IsRequired "1" }}binding:"required{{if eq $item.Source "3"}},oneof={{$item.Keys}}{{end}}"{{end}}` //{{$item.ColumnDesc}}{{end}}
- }
- func (this {{.ClassNameUpper}}) TableName() string {
- return "{{.TableName}}"
- }
- func (this *{{.ClassNameUpper}}) Key() int64 {
- return this.Id
- }
- func (this *{{.ClassNameUpper}}) Model() interface{} {
- return this
- }
- func (this *{{.ClassNameUpper}}) BeforeUpdate() {
- user := base.GetCurUser()
- if user != nil {
- this.UpdateBy = user.Name
- }{{range $index, $item := .Columns}}{{if eq $item.ColumnNameUpper "CompanyId"}}
- if user.ComponyId > 0 {
- this.CompanyId = user.ComponyId
- }{{end}}{{end}}
- }
- func (this *{{.ClassNameUpper}}) BeforeInsert() {
- user := base.GetCurUser()
- if user != nil {
- this.CreateBy = user.Name
- this.UpdateBy = user.Name
- }{{range $index, $item := .Columns}}{{if eq $item.ColumnNameUpper "CompanyId"}}
- if user.ComponyId > 0 {
- this.CompanyId = user.ComponyId
- }{{end}}{{end}}
- }
|