mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 11:50:55 +00:00
refator func
This commit is contained in:
parent
f4e7d63e65
commit
be30fb7937
@ -16,7 +16,7 @@ import (
|
||||
|
||||
// register models.
|
||||
// prefix means table name prefix.
|
||||
func registerModel(model interface{}, prefix string) {
|
||||
func registerModel(prefix string, model interface{}) {
|
||||
val := reflect.ValueOf(model)
|
||||
ind := reflect.Indirect(val)
|
||||
typ := ind.Type()
|
||||
@ -292,23 +292,17 @@ end:
|
||||
|
||||
// register models
|
||||
func RegisterModel(models ...interface{}) {
|
||||
if modelCache.done {
|
||||
panic(fmt.Errorf("RegisterModel must be run before BootStrap"))
|
||||
}
|
||||
|
||||
for _, model := range models {
|
||||
registerModel(model, "")
|
||||
}
|
||||
RegisterModelWithPrefix("", models)
|
||||
}
|
||||
|
||||
// register model with a prefix
|
||||
// register models with a prefix
|
||||
func RegisterModelWithPrefix(prefix string, models ...interface{}) {
|
||||
if modelCache.done {
|
||||
panic(fmt.Errorf("RegisterModel must be run before BootStrap"))
|
||||
}
|
||||
|
||||
for _, model := range models {
|
||||
registerModel(model, prefix)
|
||||
registerModel(prefix, model)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user