You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.3 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. package system
  2. import (
  3. adapter "github.com/casbin/gorm-adapter/v3"
  4. "github.com/flipped-aurora/gin-vue-admin/server/global"
  5. "github.com/flipped-aurora/gin-vue-admin/server/model/example"
  6. "github.com/flipped-aurora/gin-vue-admin/server/model/system"
  7. "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
  8. )
  9. type InitDBService struct{}
  10. // InitDB 创建数据库并初始化 总入口
  11. // Author [piexlmax](https://github.com/piexlmax)
  12. // Author [SliverHorn](https://github.com/SliverHorn)
  13. // Author [songzhibin97](https://github.com/songzhibin97)
  14. func (initDBService *InitDBService) InitDB(conf request.InitDB) error {
  15. switch conf.DBType {
  16. case "mysql":
  17. return initDBService.initMsqlDB(conf)
  18. case "pgsql":
  19. return initDBService.initPgsqlDB(conf)
  20. default:
  21. return initDBService.initMsqlDB(conf)
  22. }
  23. }
  24. // initTables 初始化表
  25. // Author SliverHorn
  26. func (initDBService *InitDBService) initTables() error {
  27. return global.GVA_DB.AutoMigrate(
  28. system.SysApi{},
  29. system.SysUser{},
  30. system.SysBaseMenu{},
  31. system.SysAuthority{},
  32. system.JwtBlacklist{},
  33. system.SysDictionary{},
  34. system.SysAutoCodeHistory{},
  35. system.SysOperationRecord{},
  36. system.SysDictionaryDetail{},
  37. system.SysBaseMenuParameter{},
  38. adapter.CasbinRule{},
  39. example.ExaFile{},
  40. example.ExaCustomer{},
  41. example.ExaFileChunk{},
  42. example.ExaFileUploadAndDownload{},
  43. )
  44. }