report_chapter_ticker.go 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. )
  7. type ReportChapterTicker struct {
  8. Id int `gorm:"column:id;primaryKey"` //`orm:"column(id);pk" gorm:"primaryKey" description:"主键ID"`
  9. ReportChapterId int `gorm:"column:report_chapter_id"` //`description:"报告章节ID"`
  10. Sort int `gorm:"column:sort"` //`description:"排序"`
  11. Ticker string `gorm:"column:ticker"` //`description:"ticker"`
  12. CreateTime time.Time `gorm:"column:create_time"` //`description:"创建时间"`
  13. UpdateTime time.Time `gorm:"column:update_time"` //`description:"更新时间"`
  14. }
  15. // 新增章节ticker
  16. func InsertChapterTicker(tickerInfo *ReportChapterTicker) (lastId int64, err error) {
  17. err = global.DmSQL["rddp"].Create(tickerInfo).Error
  18. lastId = int64(tickerInfo.Id)
  19. return
  20. }
  21. // GetTickerListByReportChapterId 根据章节ID获取ticker列表
  22. func GetTickerListByReportChapterId(reportChapterId int) (list []*ReportChapterTicker, err error) {
  23. sql := ` SELECT * FROM report_chapter_ticker WHERE report_chapter_id = ? ORDER BY sort ASC `
  24. err = global.DmSQL["rddp"].Raw(sql, reportChapterId).Find(&list).Error
  25. return
  26. }
  27. // ClearReportChapterTicker 清空章节ticker
  28. func ClearReportChapterTicker(reportChapterId int) (err error) {
  29. sql := ` DELETE FROM report_chapter_ticker WHERE report_chapter_id = ? `
  30. err = global.DmSQL["rddp"].Exec(sql, reportChapterId).Error
  31. return
  32. }
  33. // DailyBaseColumn 基础列
  34. type DailyBaseColumn struct {
  35. BaseColumnId int `gorm:"column:base_column_id"` //`orm:"column(base_column_id)" description:"主键ID"`
  36. TableName string `gorm:"column:table_name"` //`description:"表名"`
  37. BaseColumnName string `gorm:"column:base_column_name"` // `description:"列名称"`
  38. BaseColumnChapterType string `gorm:"column:base_column_chapter_type"` // `description:"列类型"`
  39. BaseColumnTicker string `gorm:"column:base_column_ticker"` // `description:"指标"`
  40. Enabled int `gorm:"column:enabled"` // `description:"状态"`
  41. CreatedTime time.Time `gorm:"column:created_time"` //`description:"创建时间"`
  42. LastUpdatedTime time.Time `gorm:"column:last_updated_time"` //`description:"更新时间"`
  43. Freq string `gorm:"column:freq"` //`description:"频率 D-日度 W-周度 M-月度"`
  44. Catalog string `gorm:"column:catalog"` //`description:"分类名称"`
  45. ReportChapterTypeId int `gorm:"column:report_chapter_type_id"` //`description:"分类ID"`
  46. Selected int `gorm:"column:selected"` //`description:"选中状态 0-未选中 1-已选中"`
  47. }
  48. // GetDailyBaseColumnList 获取基础列列表
  49. func GetDailyBaseColumnList(keyword string, typeId int) (list []*DailyBaseColumn, err error) {
  50. sql := ` SELECT * FROM daily_base_column WHERE 1 = 1 `
  51. pars := make([]interface{}, 0)
  52. if keyword != "" {
  53. pars = append(pars, utils.GetLikeKeyword(keyword))
  54. sql += ` AND base_column_name like ? `
  55. }
  56. pars = append(pars, typeId)
  57. sql += ` AND report_chapter_type_id = ? `
  58. err = global.DmSQL["weekly"].Raw(sql, pars...).Find(&list).Error
  59. return
  60. }