package models import ( "eta/eta_api/global" "eta/eta_api/utils" "time" ) type ReportChapterTicker struct { Id int `gorm:"column:id;primaryKey;autoIncrement" description:"主键ID"` ReportChapterId int `description:"报告章节ID"` Sort int `description:"排序"` Ticker string `description:"ticker"` CreateTime time.Time `description:"创建时间"` UpdateTime time.Time `description:"更新时间"` } // InsertChapterTicker 新增章节ticker func InsertChapterTicker(tickerInfo *ReportChapterTicker) (lastId int64, err error) { o := global.DbMap[utils.DbNameReport] err = o.Create(tickerInfo).Error if err != nil { return } lastId = int64(tickerInfo.Id) return } // GetTickerListByReportChapterId 根据章节ID获取ticker列表 func GetTickerListByReportChapterId(reportChapterId int) (list []*ReportChapterTicker, err error) { o := global.DbMap[utils.DbNameReport] sql := ` SELECT * FROM report_chapter_ticker WHERE report_chapter_id = ? ORDER BY sort ASC ` err = o.Raw(sql, reportChapterId).Find(&list).Error return } // ClearReportChapterTicker 清空章节ticker func ClearReportChapterTicker(reportChapterId int) (err error) { o := global.DbMap[utils.DbNameReport] sql := ` DELETE FROM report_chapter_ticker WHERE report_chapter_id = ? ` err = o.Exec(sql, reportChapterId).Error return } // DailyBaseColumn 基础列 type DailyBaseColumn struct { BaseColumnId int `gorm:"column:base_column_id;primaryKey;autoIncrement" description:"主键ID"` TableName string `description:"表名"` BaseColumnName string `description:"列名称"` BaseColumnChapterType string `description:"列类型"` BaseColumnTicker string `description:"指标"` Enabled int `description:"状态"` CreatedTime time.Time `description:"创建时间"` LastUpdatedTime time.Time `description:"更新时间"` Freq string `description:"频率 D-日度 W-周度 M-月度"` Catalog string `description:"分类名称"` ReportChapterTypeId int `description:"分类ID"` Selected int `description:"选中状态 0-未选中 1-已选中"` } // GetDailyBaseColumnList 获取基础列列表 func GetDailyBaseColumnList(keyword string, typeId int) (list []*DailyBaseColumn, err error) { o := global.DbMap[utils.DbNameWeekly] sql := ` SELECT * FROM daily_base_column WHERE 1 = 1 ` pars := make([]interface{}, 0) if keyword != "" { pars = append(pars, utils.GetLikeKeyword(keyword)) sql += ` AND base_column_name like ? ` } pars = append(pars, typeId) sql += ` AND report_chapter_type_id = ? ` err = o.Raw(sql, pars...).Find(&list).Error return }