common.go 702 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dao
  2. import (
  3. "fmt"
  4. _ "github.com/go-sql-driver/mysql"
  5. "github.com/jinzhu/gorm"
  6. "iot_manager_service/app/system/dao"
  7. )
  8. var Db *gorm.DB
  9. func InitDB(db *gorm.DB) {
  10. Db = db
  11. err := Db.AutoMigrate(
  12. &dao.User{},
  13. &Dict{},
  14. &LampPoleGroup{},
  15. &LampPole{},
  16. &Gateway{},
  17. &GatewayRelation{},
  18. &Transformer{},
  19. &LightControl{},
  20. &Garbage{},
  21. &GarbageWayGroup{},
  22. &OnDemandGroup{},
  23. &OnDemandSensor{},
  24. &Zigbee{},
  25. &CameraDevice{},
  26. &InfoBoard{},
  27. &Alarm{},
  28. &CaptureUint{},
  29. &CheckPoint{},
  30. &AlarmTerminal{},
  31. &Bridge{},
  32. &BridgeSensor{},
  33. &IpBroadcast{},
  34. &ManholeCover{},
  35. &OptoSensor{},
  36. ).Error
  37. if err != nil {
  38. panic(fmt.Sprintf("AutoMigrate err : %v", err))
  39. }
  40. }