123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- package models
- import (
- "eta/eta_mobile/models/data_manage"
- "eta/eta_mobile/models/data_stat"
- "eta/eta_mobile/models/ppt_english"
- "eta/eta_mobile/models/sandbox"
- saModel "eta/eta_mobile/models/semantic_analysis"
- "eta/eta_mobile/models/system"
- "eta/eta_mobile/utils"
- _ "github.com/go-sql-driver/mysql"
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- func init() {
- _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
- orm.SetMaxIdleConns("default", 50)
- orm.SetMaxOpenConns("default", 100)
- db, _ := orm.GetDB("default")
- db.SetConnMaxLifetime(10 * time.Minute)
- _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
- orm.SetMaxIdleConns("rddp", 50)
- orm.SetMaxOpenConns("rddp", 100)
- report_db, _ := orm.GetDB("rddp")
- report_db.SetConnMaxLifetime(10 * time.Minute)
- _ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
- orm.SetMaxIdleConns("edb", 50)
- orm.SetMaxOpenConns("edb", 100)
- edb_db, _ := orm.GetDB("edb")
- edb_db.SetConnMaxLifetime(10 * time.Minute)
- _ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA)
- orm.SetMaxIdleConns("data", 50)
- orm.SetMaxOpenConns("data", 100)
- data_db, _ := orm.GetDB("data")
- data_db.SetConnMaxLifetime(10 * time.Minute)
- _ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
- orm.SetMaxIdleConns("gl", 50)
- orm.SetMaxOpenConns("gl", 100)
- gl, _ := orm.GetDB("gl")
- gl.SetConnMaxLifetime(10 * time.Minute)
- // 用户主库
- if utils.MYSQL_WEEKLY_URL != `` && (utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox) {
- _ = orm.RegisterDataBase("weekly", "mysql", utils.MYSQL_WEEKLY_URL)
- orm.SetMaxIdleConns("weekly", 50)
- orm.SetMaxOpenConns("weekly", 100)
- weeklyDb, _ := orm.GetDB("weekly")
- weeklyDb.SetConnMaxLifetime(10 * time.Minute)
- }
- orm.Debug = true
- orm.DebugLog = orm.NewLog(utils.Binlog)
- //注册对象
- orm.RegisterModel(
- new(Classify),
- new(Resource),
- new(Ppt),
- new(PptPages),
- new(PptPublishRecord),
- new(PptV2),
- new(PptV2PublishRecord),
- new(PptV2SaveLog),
- new(PptV2Group),
- new(PptV2GroupMapping),
- new(PptV2Grant), //ppt授权操作表
- )
- // 报告相关 数据表
- initReport()
- initSystem()
- initChart()
- // 指标服务 数据表
- initEdbData()
- // 英文ppt
- initPptEnglish()
- //多图配置
- initMultipleGraphConfig()
- // 英文报告
- initEnglishReport()
- // 沙盘推演
- initSandbox()
- // 文档对比
- initSaCompare()
- // 商家配置
- initBusinessConf()
- // 初始化部分数据表变量(直接init会有顺序问题=_=!)
- data_manage.InitEdbSource()
- // initDataStat 数据源统计管理相关表
- initDataStat()
- }
- // initSystem 系统表 数据表
- func initSystem() {
- orm.RegisterModel(
- new(system.SysUserLoginRecord),
- new(system.SysSession),
- new(system.Admin),
- new(system.AdminConfig), //系统用户配置表
- new(system.AdminVerifyCodeRecord), // 用户短信邮箱验证码记录表
- )
- }
- // initReport 报告相关 数据表
- func initReport() {
- orm.RegisterModel(
- new(Report),
- new(ChartPermissionSearchKeyWordMapping), //报告分类权限表
- new(ReportChapter), // 报告章节表
- new(ReportChapterTicker), // 晨报章节ticker
- new(ReportChapterTypePermission), // 晨周报章节类型权限表
- new(YbPcSuncode),
- new(YbSuncodePars),
- new(ReportAuthor), //报告作者
- new(ClassifyMenu), // 报告分类-子目录表
- new(ClassifyMenuRelation), // 报告分类-子目录关联表
- new(ReportChapterType), // 报告章节类型表
- )
- }
- // initChart 图表 数据表
- func initChart() {
- orm.RegisterModel(
- new(data_manage.ChartClassify),
- new(data_manage.ChartInfo),
- new(data_manage.ChartEdbMapping),
- new(data_manage.MyChartClassify),
- new(data_manage.MyChart),
- new(data_manage.MyChartLog),
- new(data_manage.MyChartClassifyMapping),
- new(data_manage.ChartInfoLog),
- new(data_manage.ChartInfoCorrelation),
- )
- }
- // initEdbData 指标服务 数据表
- func initEdbData() {
- orm.RegisterModel(
- new(data_manage.EdbClassify),
- new(data_manage.EdbInfo), //hz_data库的edb_info表
- new(data_manage.EdbDataThs),
- new(data_manage.EdbDataWind),
- new(data_manage.EdbDataPb),
- new(data_manage.EdbInfoCalculate),
- new(data_manage.EdbDataCalculate),
- new(data_manage.EdbInfoCalculateTbz),
- new(data_manage.SearchKeyword),
- new(data_manage.BaseFromSmm),
- new(data_manage.BaseFromSmmIndex),
- new(data_manage.BaseFromSmmData),
- new(data_manage.EdbInfoLog),
- new(data_manage.EdbInfoCalculateMapping),
- new(data_manage.ExcelClassify), //ETA excel表格分类
- new(data_manage.ExcelInfo), //ETA excel表格
- new(data_manage.PredictEdbConf), //预测指标配置
- new(data_manage.BaseFromMysteelChemicalIndex), //钢联化工
- new(data_manage.BaseFromEiaSteoClassify), // Eia steo 报告指标
- new(data_manage.BaseFromEiaSteoIndex), // Eia steo 报告指标分类
- new(data_manage.PredictEdbRuleData), //预测指标,动态规则的计算数据
- new(data_manage.BaseFromSci),
- new(data_manage.BaseFromSciIndex),
- new(data_manage.BaseFromSciData),
- new(data_manage.BaseFromBaiinfo),
- new(data_manage.BaseFromBaiinfoIndex),
- new(data_manage.BaseFromBaiinfoData),
- new(data_manage.EdbDataInsertConfig), // 指标数据插入配置表
- new(data_manage.EdbInfoNoPermissionAdmin), //指标不可见用户配置表
- )
- }
- // initPptEnglish ppt英文
- func initPptEnglish() {
- orm.RegisterModel(
- new(ppt_english.PptEnglish),
- new(ppt_english.PptEnglishPublishRecord),
- new(ppt_english.PptEnglishSaveLog),
- new(ppt_english.PptEnglishGroup),
- new(ppt_english.PptEnglishGroupMapping),
- new(ppt_english.PptEnglishGrant), //ppt授权操作表
- new(ppt_english.ReportPptEnglishImg), //Ppt转报告的图片记录表
- )
- }
- // initMultipleGraphConfig 多图配置 数据表
- func initMultipleGraphConfig() {
- //注册对象
- orm.RegisterModel(
- new(data_manage.MultipleGraphConfig), //多图配置表
- new(data_manage.MultipleGraphConfigChartMapping), //图表与多图配置的关系表
- //new(data_manage.MultipleGraphConfigEdbMapping), //指标与多图配置的关系表
- )
- }
- // initEnglishReport 英文报告
- func initEnglishReport() {
- orm.RegisterModel(
- new(EnglishReport),
- new(EnglishPolicyReport),
- new(EnglishReportEmail),
- new(EnglishReportEmailLog),
- new(EnglishClassify),
- new(EnglishCompany), // 英文客户
- new(EnglishCompanyTodo), // 英文客户TODO任务
- new(EnglishVideo), // 英文研报线上路演
- new(EnPermission), // 英文品种权限表
- new(EnCompanyPermission), // 英文客户品种权限关联表
- new(EnClassifyPermission), // 英文分类品种权限关联表
- )
- }
- // initSandbox 注册Edb沙盘 数据表
- func initSandbox() {
- //注册对象
- orm.RegisterModel(
- new(sandbox.Sandbox), //沙盘主表
- )
- }
- func initSaCompare() {
- orm.RegisterModel(
- new(saModel.SaCompare), //文档对比
- )
- }
- // initBusinessConf 商家配置
- func initBusinessConf() {
- orm.RegisterModel(
- new(BusinessConf), // 商家配置表
- new(BusinessConfOperationRecord), // 商家配置操作记录表
- )
- }
- // initDataStat 数据源统计管理相关表
- func initDataStat() {
- orm.RegisterModel(
- new(data_stat.EdbInfoDeleteLog), // 指标删除日志表
- new(data_stat.EdbInfoUpdateLog), // 指标更新/刷新日志列表
- )
- }
|