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.

58 lines
1.3 KiB

  1. package datas
  2. import (
  3. "gin-vue-admin/model"
  4. gormadapter "github.com/casbin/gorm-adapter/v3"
  5. "github.com/gookit/color"
  6. "gorm.io/gorm"
  7. "os"
  8. )
  9. func InitMysqlData(db *gorm.DB) {
  10. InitSysApi(db)
  11. InitSysUser(db)
  12. InitExaCustomer(db)
  13. InitCasbinModel(db)
  14. InitSysAuthority(db)
  15. InitSysBaseMenus(db)
  16. InitAuthorityMenu(db)
  17. InitSysDictionary(db)
  18. InitSysAuthorityMenus(db)
  19. InitSysDataAuthorityId(db)
  20. InitSysDictionaryDetail(db)
  21. InitExaFileUploadAndDownload(db)
  22. InitWkProcess(db)
  23. }
  24. func InitMysqlTables(db *gorm.DB) {
  25. var err error
  26. if !db.Migrator().HasTable("casbin_rule") {
  27. err = db.Migrator().CreateTable(&gormadapter.CasbinRule{})
  28. }
  29. err = db.AutoMigrate(
  30. model.SysApi{},
  31. model.SysUser{},
  32. model.ExaFile{},
  33. model.ExaCustomer{},
  34. model.SysBaseMenu{},
  35. model.SysAuthority{},
  36. model.JwtBlacklist{},
  37. model.ExaFileChunk{},
  38. model.SysDictionary{},
  39. model.ExaSimpleUploader{},
  40. model.SysOperationRecord{},
  41. model.SysDictionaryDetail{},
  42. model.SysBaseMenuParameter{},
  43. model.ExaFileUploadAndDownload{},
  44. model.WorkflowProcess{},
  45. model.WorkflowNode{},
  46. model.WorkflowEdge{},
  47. model.WorkflowStartPoint{},
  48. model.WorkflowEndPoint{},
  49. )
  50. if err != nil {
  51. color.Warn.Printf("[Mysql]-->初始化数据表失败,err: %v\n", err)
  52. os.Exit(0)
  53. }
  54. color.Info.Println("[Mysql]-->初始化数据表成功")
  55. }