db_init.go 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. _ "github.com/go-sql-driver/mysql"
  5. "hongze/hongze_mobile_admin/models/cygx"
  6. "hongze/hongze_mobile_admin/models/roadshow"
  7. "hongze/hongze_mobile_admin/models/tables/admin"
  8. "hongze/hongze_mobile_admin/models/tables/admin_record"
  9. "hongze/hongze_mobile_admin/models/tables/approval_flow"
  10. "hongze/hongze_mobile_admin/models/tables/approval_flow_node"
  11. "hongze/hongze_mobile_admin/models/tables/business_trip"
  12. "hongze/hongze_mobile_admin/models/tables/chart_permission"
  13. "hongze/hongze_mobile_admin/models/tables/company"
  14. "hongze/hongze_mobile_admin/models/tables/company_approval"
  15. "hongze/hongze_mobile_admin/models/tables/company_approval_message"
  16. "hongze/hongze_mobile_admin/models/tables/company_contract"
  17. "hongze/hongze_mobile_admin/models/tables/company_delay_permission"
  18. "hongze/hongze_mobile_admin/models/tables/company_log"
  19. "hongze/hongze_mobile_admin/models/tables/company_operation_record"
  20. "hongze/hongze_mobile_admin/models/tables/company_permission_log"
  21. "hongze/hongze_mobile_admin/models/tables/company_product"
  22. "hongze/hongze_mobile_admin/models/tables/company_product_log"
  23. "hongze/hongze_mobile_admin/models/tables/company_product_try_out_update_log"
  24. "hongze/hongze_mobile_admin/models/tables/company_product_try_out_update_permission_log"
  25. "hongze/hongze_mobile_admin/models/tables/company_product_update_log"
  26. "hongze/hongze_mobile_admin/models/tables/company_renewal_record"
  27. "hongze/hongze_mobile_admin/models/tables/company_report_permission"
  28. "hongze/hongze_mobile_admin/models/tables/contract"
  29. "hongze/hongze_mobile_admin/models/tables/contract_approval"
  30. "hongze/hongze_mobile_admin/models/tables/contract_approval_record"
  31. "hongze/hongze_mobile_admin/models/tables/contract_operation_record"
  32. "hongze/hongze_mobile_admin/models/tables/contract_service_detail"
  33. "hongze/hongze_mobile_admin/models/tables/contract_service_template"
  34. "hongze/hongze_mobile_admin/models/tables/contract_template"
  35. "hongze/hongze_mobile_admin/models/tables/cygx_allocation_company_contract"
  36. "hongze/hongze_mobile_admin/models/tables/cygx_company_user_type"
  37. "hongze/hongze_mobile_admin/models/tables/english_company"
  38. "hongze/hongze_mobile_admin/models/tables/h5_admin_session"
  39. "hongze/hongze_mobile_admin/models/tables/report"
  40. "hongze/hongze_mobile_admin/models/tables/research_variety_tag_relation"
  41. "hongze/hongze_mobile_admin/models/tables/resource"
  42. "hongze/hongze_mobile_admin/models/tables/seal"
  43. "hongze/hongze_mobile_admin/models/tables/sys_role"
  44. "hongze/hongze_mobile_admin/models/tables/sys_role_admin"
  45. "hongze/hongze_mobile_admin/models/tables/user_template_record"
  46. "hongze/hongze_mobile_admin/models/tables/variety_classify"
  47. "hongze/hongze_mobile_admin/models/tables/variety_tag"
  48. "hongze/hongze_mobile_admin/models/tables/wx_token"
  49. "hongze/hongze_mobile_admin/models/tables/wx_user"
  50. "hongze/hongze_mobile_admin/models/tables/yb_community_question"
  51. "hongze/hongze_mobile_admin/models/tables/yb_community_question_comment"
  52. "hongze/hongze_mobile_admin/models/tables/yb_price_driven_tag"
  53. "hongze/hongze_mobile_admin/utils"
  54. "time"
  55. )
  56. func init() {
  57. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  58. orm.SetMaxIdleConns("default", 50)
  59. orm.SetMaxOpenConns("default", 100)
  60. db, _ := orm.GetDB("default")
  61. db.SetConnMaxLifetime(10 * time.Minute)
  62. //rddp数据库
  63. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  64. orm.SetMaxIdleConns("rddp", 50)
  65. orm.SetMaxOpenConns("rddp", 100)
  66. report_db, _ := orm.GetDB("rddp")
  67. report_db.SetConnMaxLifetime(10 * time.Minute)
  68. _ = orm.RegisterDataBase("hz_cygx", "mysql", utils.MYSQL_URL_CYGX)
  69. orm.SetMaxIdleConns("hz_cygx", 50)
  70. orm.SetMaxOpenConns("hz_cygx", 100)
  71. cygx_db, _ := orm.GetDB("hz_cygx")
  72. cygx_db.SetConnMaxLifetime(10 * time.Minute)
  73. orm.Debug = true
  74. orm.DebugLog = orm.NewLog(utils.Binlog)
  75. //注册对象
  76. orm.RegisterModel(
  77. new(admin.Admin),
  78. new(admin_record.AdminRecord),
  79. new(sys_role.SysRole),
  80. new(sys_role_admin.SysRoleAdmin),
  81. new(approval_flow.ApprovalFlow),
  82. new(approval_flow_node.ApprovalFlowNode),
  83. new(company.Company),
  84. new(company_approval.CompanyApproval),
  85. new(company_approval_message.CompanyApprovalMessage),
  86. new(company_contract.CompanyContract),
  87. new(company_delay_permission.CompanyDelayPermission),
  88. new(company_log.CompanyLog),
  89. new(company_operation_record.CompanyOperationRecord),
  90. new(company_permission_log.CompanyPermissionLog),
  91. new(company_product.CompanyProduct),
  92. new(company_product_log.CompanyProductLog),
  93. new(company_report_permission.CompanyReportPermission),
  94. new(contract.Contract),
  95. new(contract_approval.ContractApproval),
  96. new(contract_approval_record.ContractApprovalRecord),
  97. new(contract_operation_record.ContractOperationRecord),
  98. new(contract_service_detail.ContractServiceDetail),
  99. new(contract_service_template.ContractServiceTemplate),
  100. new(contract_template.ContractTemplate),
  101. new(h5_admin_session.H5AdminSession),
  102. new(report.Report),
  103. new(resource.Resource),
  104. new(wx_token.WxToken),
  105. new(wx_user.WxUser),
  106. new(seal.Seal), //用印表
  107. new(seal.SealOperationRecord), // 用印操作记录表
  108. new(seal.Attachment), //用印附件
  109. new(roadshow.RsCalendar),
  110. new(roadshow.RsCalendarResearcher),
  111. new(roadshow.RsMatters),
  112. new(roadshow.RsCalendarRelation),
  113. new(roadshow.RsCalendarApiLog),
  114. new(company_product_update_log.CompanyProductUpdateLog), //客户产品状态变更记录表
  115. new(user_template_record.UserTemplateRecord), //模版消息记录表
  116. new(chart_permission.ChartPermission), // 品种权限表
  117. new(company_product_try_out_update_log.CompanyProductTryOutUpdateLog), //客户产品试用变更状态表
  118. new(company_product_try_out_update_permission_log.CompanyProductTryOutUpdatePermissionLog), //客户产品试用变更品种详情表
  119. new(english_company.EnglishCompany), // 英文客户表
  120. new(cygx_company_user_type.CygxCompanyUserType), // 英文客户表
  121. new(cygx.CygxActivitySpecialTripBill), // 专项调研确定行程活动报名流水表
  122. new(cygx.CygxActivitySpecialPermissionPoints), //权益公司专项调研各行业点数剩余表
  123. new(cygx_allocation_company_contract.CygxAllocationCompanyContract), //权益合同派点(研究员)
  124. new(cygx_allocation_company_contract.CygxAllocationCompanyContractLog), //权益合同派点日志(研究员)
  125. new(cygx_allocation_company_contract.CygxAllocationCompanyContractPermission), //权益合同派点(行业)
  126. new(cygx_allocation_company_contract.CygxAllocationCompanyContractPermissionLog), //权益合同派点日志(行业)
  127. new(company_renewal_record.CompanyRenewalRecord), // 客户续约状态记录表
  128. )
  129. // 社区问答相关
  130. initCommunity()
  131. // 品种标签相关
  132. initVariety()
  133. // 价格驱动相关
  134. initPriceDriven()
  135. //出差相关
  136. initBusinessTrip()
  137. }
  138. // initCommunity 社区问答相关
  139. func initCommunity() {
  140. orm.RegisterModel(
  141. new(yb_community_question.CommunityQuestion), //社区问答
  142. new(yb_community_question_comment.YbCommunityQuestionComment), //社区问答评论
  143. )
  144. }
  145. // initVariety 品种标签相关
  146. func initVariety() {
  147. orm.RegisterModel(
  148. new(variety_classify.VarietyClassify), //品种标签分类
  149. new(variety_tag.VarietyTag), //品种标签
  150. new(research_variety_tag_relation.ResearchVarietyTagRelation), //品种标签关系
  151. )
  152. }
  153. // initPriceDriven 价格驱动相关
  154. func initPriceDriven() {
  155. orm.RegisterModel(
  156. new(yb_price_driven_tag.PriceDrivenTag), //价格驱动标签
  157. )
  158. }
  159. func InitDb() {}
  160. // 出差
  161. func initBusinessTrip() {
  162. orm.RegisterModel(
  163. new(business_trip.BusinessApply),
  164. new(business_trip.BusinessApplyPeer),
  165. )
  166. }