common.go 277 B

12345678910111213141516171819202122
  1. package dao
  2. import (
  3. "fmt"
  4. "github.com/jinzhu/gorm"
  5. )
  6. var Db *gorm.DB
  7. func InitDB(db *gorm.DB) {
  8. Db = db
  9. err := Db.AutoMigrate(
  10. &User{},
  11. &Tenant{},
  12. &Role{},
  13. &RoleMenu{},
  14. &Menu{},
  15. ).Error
  16. if err != nil {
  17. panic(fmt.Sprintf("AutoMigrate err : %v", err))
  18. }
  19. }