123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package models
- import (
- "eta_gn/eta_api/global"
- "eta_gn/eta_api/utils"
- "time"
- )
- type ReportChapterTicker struct {
- Id int `gorm:"column:id;primaryKey"` //`orm:"column(id);pk" description:"主键ID"`
- ReportChapterId int `gorm:"column:report_chapter_id"` //`description:"报告章节ID"`
- Sort int `gorm:"column:sort"` //`description:"排序"`
- Ticker string `gorm:"column:ticker"` //`description:"ticker"`
- CreateTime time.Time `gorm:"column:create_time"` //`description:"创建时间"`
- UpdateTime time.Time `gorm:"column:update_time"` //`description:"更新时间"`
- }
- // 新增章节ticker
- func InsertChapterTicker(tickerInfo *ReportChapterTicker) (lastId int64, err error) {
- //o := orm.NewOrmUsingDB("rddp")
- //lastId, err = o.Insert(tickerInfo)
- err = global.DmSQL["rddp"].Create(tickerInfo).Error
- lastId = int64(tickerInfo.Id)
- return
- }
- // GetTickerListByReportChapterId 根据章节ID获取ticker列表
- func GetTickerListByReportChapterId(reportChapterId int) (list []*ReportChapterTicker, err error) {
- //o := orm.NewOrmUsingDB("rddp")
- sql := ` SELECT * FROM report_chapter_ticker WHERE report_chapter_id = ? ORDER BY sort ASC `
- //_, err = o.Raw(sql, reportChapterId).QueryRows(&list)
- err = global.DmSQL["rddp"].Raw(sql, reportChapterId).Find(&list).Error
- return
- }
- // ClearReportChapterTicker 清空章节ticker
- func ClearReportChapterTicker(reportChapterId int) (err error) {
- //o := orm.NewOrmUsingDB("rddp")
- sql := ` DELETE FROM report_chapter_ticker WHERE report_chapter_id = ? `
- //_, err = o.Raw(sql, reportChapterId).Exec()
- err = global.DmSQL["rddp"].Exec(sql, reportChapterId).Error
- return
- }
- // DailyBaseColumn 基础列
- type DailyBaseColumn struct {
- BaseColumnId int `gorm:"column:base_column_id"` //`orm:"column(base_column_id)" description:"主键ID"`
- TableName string `gorm:"column:table_name"` //`description:"表名"`
- BaseColumnName string `gorm:"column:base_column_name"` // `description:"列名称"`
- BaseColumnChapterType string `gorm:"column:base_column_chapter_type"` // `description:"列类型"`
- BaseColumnTicker string `gorm:"column:base_column_ticker"` // `description:"指标"`
- Enabled int `gorm:"column:enabled"` // `description:"状态"`
- CreatedTime time.Time `gorm:"column:created_time"` //`description:"创建时间"`
- LastUpdatedTime time.Time `gorm:"column:last_updated_time"` //`description:"更新时间"`
- Freq string `gorm:"column:freq"` //`description:"频率 D-日度 W-周度 M-月度"`
- Catalog string `gorm:"column:catalog"` //`description:"分类名称"`
- ReportChapterTypeId int `gorm:"column:report_chapter_type_id"` //`description:"分类ID"`
- Selected int `gorm:"column:selected"` //`description:"选中状态 0-未选中 1-已选中"`
- }
- // GetDailyBaseColumnList 获取基础列列表
- func GetDailyBaseColumnList(keyword string, typeId int) (list []*DailyBaseColumn, err error) {
- //o := orm.NewOrmUsingDB("weekly")
- 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).QueryRows(&list)
- err = global.DmSQL["weekly"].Raw(sql, pars).Find(&list).Error
- return
- }
|