db.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package models
  2. import (
  3. "eta/eta_mini_crm_ht/utils"
  4. "time"
  5. "github.com/beego/beego/v2/client/orm"
  6. _ "github.com/go-sql-driver/mysql"
  7. )
  8. func init() {
  9. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  10. orm.SetMaxIdleConns("rddp", 50)
  11. orm.SetMaxOpenConns("rddp", 100)
  12. report_db, err := orm.GetDB("rddp")
  13. if err != nil {
  14. utils.FileLog.Error("连接研报数据库失败" + err.Error())
  15. }
  16. report_db.SetConnMaxLifetime(10 * time.Minute)
  17. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_MASTER)
  18. orm.SetMaxIdleConns("default", 50)
  19. orm.SetMaxOpenConns("default", 100)
  20. db, _ := orm.GetDB("default")
  21. db.SetConnMaxLifetime(10 * time.Minute)
  22. orm.Debug = true
  23. orm.DebugLog = orm.NewLog(utils.BinLog)
  24. orm.RegisterModel(
  25. new(SysSession),
  26. new(SysRole),
  27. new(SysUser),
  28. new(SysDepartment),
  29. new(SysMenu),
  30. new(SysRoleMenuMapping),
  31. new(ChartPermission),
  32. new(UserChartPermissionMapping),
  33. new(User),
  34. new(CrmConfig),
  35. new(ReportPdf),
  36. new(TemplateUser),
  37. new(CrmFinancialAnalyst),
  38. new(Media),
  39. new(MetaInfo),
  40. new(FeedBack),
  41. new(MediaPermissionMapping),
  42. new(ImageSource),
  43. new(Report),
  44. new(RiskConfig),
  45. new(Permission),
  46. new(CustomerProductRiskMapping),
  47. new(UserSourceClickFlow),
  48. new(MerchantProduct),
  49. new(ProductOrder),
  50. new(TradeOrder),
  51. new(RefundDealFlow),
  52. )
  53. }