github.com/naoina/kocha@v0.7.1-0.20171129072645-78c7a531f799/cmd/kocha-generate/kocha-generate-model/skeleton/model/genmai/genmai.go.tmpl (about) 1 package model 2 3 import ( 4 "github.com/naoina/genmai" 5 ) 6 7 type {{.Name}} struct { 8 Id int64 `db:"pk" json:"id"` 9 {{range .Fields}}{{.Name}} {{.Type}} `{{range .OptionTags}}{{.}} {{end}}json:"{{.Column}}"` 10 {{end}} 11 genmai.TimeStamp 12 } 13 14 func (m *{{.Name}}) BeforeInsert() error { 15 // FIXME: This method is auto-generated by Kocha. 16 // You can remove this method if unneeded. 17 return m.TimeStamp.BeforeInsert() 18 } 19 20 func (m *{{.Name}}) AfterInsert() error { 21 // FIXME: This method is auto-generated by Kocha. 22 // You can remove this method if unneeded. 23 return nil 24 } 25 26 func (m *{{.Name}}) BeforeUpdate() error { 27 // FIXME: This method is auto-generated by Kocha. 28 // You can remove this method if unneeded. 29 return m.TimeStamp.BeforeUpdate() 30 } 31 32 func (m *{{.Name}}) AfterUpdate() error { 33 // FIXME: This method is auto-generated by Kocha. 34 // You can remove this method if unneeded. 35 return nil 36 } 37 38 func (m *{{.Name}}) BeforeDelete() error { 39 // FIXME: This method is auto-generated by Kocha. 40 // You can remove this method if unneeded. 41 return nil 42 } 43 44 func (m *{{.Name}}) AfterDelete() error { 45 // FIXME: This method is auto-generated by Kocha. 46 // You can remove this method if unneeded. 47 return nil 48 }