report_chapter_ticker.go 2.7 KB

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