report_chapter_ticker.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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" 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. //o := orm.NewOrmUsingDB("rddp")
  18. //lastId, err = o.Insert(tickerInfo)
  19. err = global.DmSQL["rddp"].Create(tickerInfo).Error
  20. lastId = int64(tickerInfo.Id)
  21. return
  22. }
  23. // GetTickerListByReportChapterId 根据章节ID获取ticker列表
  24. func GetTickerListByReportChapterId(reportChapterId int) (list []*ReportChapterTicker, err error) {
  25. //o := orm.NewOrmUsingDB("rddp")
  26. sql := ` SELECT * FROM report_chapter_ticker WHERE report_chapter_id = ? ORDER BY sort ASC `
  27. //_, err = o.Raw(sql, reportChapterId).QueryRows(&list)
  28. err = global.DmSQL["rddp"].Raw(sql, reportChapterId).Find(&list).Error
  29. return
  30. }
  31. // ClearReportChapterTicker 清空章节ticker
  32. func ClearReportChapterTicker(reportChapterId int) (err error) {
  33. //o := orm.NewOrmUsingDB("rddp")
  34. sql := ` DELETE FROM report_chapter_ticker WHERE report_chapter_id = ? `
  35. //_, err = o.Raw(sql, reportChapterId).Exec()
  36. err = global.DmSQL["rddp"].Exec(sql, reportChapterId).Error
  37. return
  38. }
  39. // DailyBaseColumn 基础列
  40. type DailyBaseColumn struct {
  41. BaseColumnId int `gorm:"column:base_column_id"` //`orm:"column(base_column_id)" description:"主键ID"`
  42. TableName string `gorm:"column:table_name"` //`description:"表名"`
  43. BaseColumnName string `gorm:"column:base_column_name"` // `description:"列名称"`
  44. BaseColumnChapterType string `gorm:"column:base_column_chapter_type"` // `description:"列类型"`
  45. BaseColumnTicker string `gorm:"column:base_column_ticker"` // `description:"指标"`
  46. Enabled int `gorm:"column:enabled"` // `description:"状态"`
  47. CreatedTime time.Time `gorm:"column:created_time"` //`description:"创建时间"`
  48. LastUpdatedTime time.Time `gorm:"column:last_updated_time"` //`description:"更新时间"`
  49. Freq string `gorm:"column:freq"` //`description:"频率 D-日度 W-周度 M-月度"`
  50. Catalog string `gorm:"column:catalog"` //`description:"分类名称"`
  51. ReportChapterTypeId int `gorm:"column:report_chapter_type_id"` //`description:"分类ID"`
  52. Selected int `gorm:"column:selected"` //`description:"选中状态 0-未选中 1-已选中"`
  53. }
  54. // GetDailyBaseColumnList 获取基础列列表
  55. func GetDailyBaseColumnList(keyword string, typeId int) (list []*DailyBaseColumn, err error) {
  56. //o := orm.NewOrmUsingDB("weekly")
  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).QueryRows(&list)
  66. err = global.DmSQL["weekly"].Raw(sql, pars).Find(&list).Error
  67. return
  68. }