db.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/hongze_web_mfyx/models/order"
  5. "hongze/hongze_web_mfyx/utils"
  6. "time"
  7. "github.com/beego/beego/v2/client/orm"
  8. )
  9. func init() {
  10. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_CYGX)
  11. orm.SetMaxIdleConns("default", 50)
  12. orm.SetMaxOpenConns("default", 100)
  13. cygx_db, _ := orm.GetDB("default")
  14. cygx_db.SetConnMaxLifetime(10 * time.Minute)
  15. _ = orm.RegisterDataBase("weekly_report", "mysql", utils.MYSQL_URL)
  16. orm.SetMaxIdleConns("weekly_report", 50)
  17. orm.SetMaxOpenConns("weekly_report", 100)
  18. db, _ := orm.GetDB("weekly_report")
  19. db.SetConnMaxLifetime(10 * time.Minute)
  20. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  21. orm.SetMaxIdleConns("rddp", 50)
  22. orm.SetMaxOpenConns("rddp", 100)
  23. report_db, _ := orm.GetDB("rddp")
  24. report_db.SetConnMaxLifetime(10 * time.Minute)
  25. //注册对象
  26. orm.RegisterModel(
  27. new(WxUser),
  28. new(WxUserCode),
  29. new(UserRecord),
  30. new(CygxUserRecord),
  31. new(CygxMfyxWebSession),
  32. new(CygxIndustryFllow),
  33. new(MsgCode),
  34. new(CygxArticleCollect),
  35. new(CygxInterviewApply),
  36. new(CygxArticleAsk),
  37. new(CygxSearchKeyWord),
  38. new(CygxSearchKeyWordLog),
  39. new(Resource),
  40. new(CygxXzsChooseCategory),
  41. new(CygxReportIndustrialSeaarchHistory),
  42. new(CygxMicroRoadshowVideoHistory),
  43. new(CygxActivitySignup),
  44. new(CygxActivitySignupLog),
  45. new(CygxMySchedule),
  46. new(CygxActivitySpecialSignup),
  47. new(CygxUserFollowSpecial),
  48. new(CygxActivitySpecialTrip),
  49. new(CygxActivityMeetingReminder),
  50. new(CygxActivityMeetingReminderLog),
  51. new(CygxActivityAppointment),
  52. new(CygxActivityHelpAsk),
  53. new(UserTemplateRecord),
  54. new(CygxAdvice),
  55. new(CygxPageHistoryRecord),
  56. new(CygxArticleDepartmentFollow),
  57. new(CygxArticleComment),
  58. new(CygxArticleViewRecord),
  59. new(CygxArticleHistoryRecordNewpv),
  60. new(CygxArticleHistoryRecord),
  61. new(CygxArticleHistoryRecordAll),
  62. new(CygxActivitySpecialTripBill),
  63. new(CygxReportHistoryRecord),
  64. new(CygxReportSelectionSubjectHistory),
  65. new(CygxMinutesSummaryVoiceHistory),
  66. new(CygxResearchSummaryVoiceHistory),
  67. new(CygxProductInteriorHistory),
  68. new(CygxAboutUsVideoHistory),
  69. new(CygxTacticsTimeLineHistory),
  70. new(CygxBannerHistory),
  71. new(CygxReportHistoryRecordLog),
  72. new(CygxUserLabel),
  73. new(CygxInviteCompany),
  74. new(CygxApplyRecord),
  75. new(CygxTagHistory),
  76. new(CygxActivitySpecialMeetingDetail),
  77. new(CygxActivityVoiceHistory),
  78. new(CygxApplyCollection),
  79. new(CygxActivitySpecialInheritPointsCompany),
  80. new(CygxArticleApplyAppointmentExpert),
  81. new(CygxBannerYxSurvey),
  82. new(CygxReportSelectionLogApply),
  83. new(CygxIndustryFllowLog),
  84. new(CygxYanxuanSpecialRecord),
  85. new(CygxYanxuanSpecialRecordLog),
  86. new(CygxYanxuanSpecialCollect),
  87. new(CygxYanxuanSpecial),
  88. new(CygxYanxuanSpecialFollow),
  89. new(CygxYanxuanSpecialCompany),
  90. new(CygxYanxuanSpecialApprovalLog),
  91. new(CygxYanxuanSpecialMessage),
  92. new(CygxYanxuanSpecialMessageLike),
  93. new(CygxYanxuanSpecialSpecialLike),
  94. new(CygxResourceData),
  95. new(CygxMorningMeetingReviewChapterHistory),
  96. new(CygxAskserieVideoHistoryRecord),
  97. new(CygxAskserieVideoCollection),
  98. new(CygxAskserieVideoCollect),
  99. new(CygxVoiceAndVideoHistory),
  100. new(CygxActivityVideoHistory),
  101. new(CygxUserAdminShareHistory),
  102. new(CygxUserAdminShareCode),
  103. new(CygxUserPassword),
  104. new(CygxActivityVivoPointRecord),
  105. )
  106. initOrder() // 订单模块
  107. // 记录ORM查询日志
  108. orm.Debug = true
  109. orm.DebugLog = orm.NewLog(utils.Binlog)
  110. }
  111. // initOrder 买方研选订单模块
  112. func initOrder() {
  113. orm.RegisterModel(
  114. new(order.CygxUserBusinessCard), //用户上传名片
  115. new(order.CygxOrder), //订单表
  116. new(order.CygxOrderAction), //订单操表
  117. new(order.CygxOrderUserCard), //用户持卡表
  118. new(order.CygxOrderUserCardLog), //用户持卡日志表
  119. new(order.CygxOrderPayment), //支付记录表
  120. new(order.CygxOrderVirtualAsset), //用户虚拟资产表(所购买的单篇报告,活动等)
  121. )
  122. }