db.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package models
  2. import (
  3. "hongze/hongze_task/models/company_approval"
  4. "hongze/hongze_task/models/company_contract"
  5. "hongze/hongze_task/utils"
  6. _ "github.com/go-sql-driver/mysql"
  7. "time"
  8. "rdluck_tools/orm"
  9. )
  10. func init() {
  11. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  12. orm.SetMaxIdleConns("default", 50)
  13. orm.SetMaxOpenConns("default", 100)
  14. db, _ := orm.GetDB("default")
  15. db.SetConnMaxLifetime(10 * time.Minute)
  16. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  17. orm.SetMaxIdleConns("rddp", 50)
  18. orm.SetMaxOpenConns("rddp", 100)
  19. report_db, _ := orm.GetDB("rddp")
  20. report_db.SetConnMaxLifetime(10 * time.Minute)
  21. _ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
  22. orm.SetMaxIdleConns("edb", 50)
  23. orm.SetMaxOpenConns("edb", 100)
  24. edb_db, _ := orm.GetDB("edb")
  25. edb_db.SetConnMaxLifetime(10 * time.Minute)
  26. //注册对象
  27. orm.RegisterModel(
  28. new(EdbinfoSendMsgRecord),
  29. new(Company),
  30. new(CompanyReportPermission),
  31. new(CompanyReportPermissionLog),
  32. new(DataSourceLongzhong),
  33. new(Longzhonginfo),
  34. new(Longzhongdata),
  35. new(EdbdataClassify),
  36. new(Longzhongpriceinfo),
  37. new(Longzhongpricedata),
  38. new(CompanyOperationRecord),
  39. new(CompanyProduct),
  40. new(StackCompanyStatistic),
  41. new(CompanyPermissionLog),
  42. new(company_contract.CompanyContract),
  43. new(company_approval.CompanyApproval),
  44. )
  45. }