report_chapter_ticker.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package models
  2. import (
  3. "eta/eta_mobile/utils"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type ReportChapterTicker struct {
  8. Id int `orm:"column(id);pk" 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. // 新增章节ticker
  16. func InsertChapterTicker(tickerInfo *ReportChapterTicker) (lastId int64, err error) {
  17. o := orm.NewOrmUsingDB("rddp")
  18. lastId, err = o.Insert(tickerInfo)
  19. return
  20. }
  21. // GetTickerListByReportChapterId 根据章节ID获取ticker列表
  22. func GetTickerListByReportChapterId(reportChapterId int) (list []*ReportChapterTicker, err error) {
  23. o := orm.NewOrmUsingDB("rddp")
  24. sql := ` SELECT * FROM report_chapter_ticker WHERE report_chapter_id = ? ORDER BY sort ASC `
  25. _, err = o.Raw(sql, reportChapterId).QueryRows(&list)
  26. return
  27. }
  28. // ClearReportChapterTicker 清空章节ticker
  29. func ClearReportChapterTicker(reportChapterId int) (err error) {
  30. o := orm.NewOrmUsingDB("rddp")
  31. sql := ` DELETE FROM report_chapter_ticker WHERE report_chapter_id = ? `
  32. _, err = o.Raw(sql, reportChapterId).Exec()
  33. return
  34. }
  35. // DailyBaseColumn 基础列
  36. type DailyBaseColumn struct {
  37. BaseColumnId int `orm:"column(base_column_id)" description:"主键ID"`
  38. TableName string `description:"表名"`
  39. BaseColumnName string `description:"列名称"`
  40. BaseColumnChapterType string `description:"列类型"`
  41. BaseColumnTicker string `description:"指标"`
  42. Enabled int `description:"状态"`
  43. CreatedTime time.Time `description:"创建时间"`
  44. LastUpdatedTime time.Time `description:"更新时间"`
  45. Freq string `description:"频率 D-日度 W-周度 M-月度"`
  46. Catalog string `description:"分类名称"`
  47. ReportChapterTypeId int `description:"分类ID"`
  48. Selected int `description:"选中状态 0-未选中 1-已选中"`
  49. }
  50. // GetDailyBaseColumnList 获取基础列列表
  51. func GetDailyBaseColumnList(keyword string, typeId int) (list []*DailyBaseColumn, err error) {
  52. o := orm.NewOrmUsingDB("weekly")
  53. sql := ` SELECT * FROM daily_base_column WHERE 1 = 1 `
  54. pars := make([]interface{}, 0)
  55. if keyword != "" {
  56. pars = append(pars, utils.GetLikeKeyword(keyword))
  57. sql += ` AND base_column_name like ? `
  58. }
  59. pars = append(pars, typeId)
  60. sql += ` AND report_chapter_type_id = ? `
  61. _, err = o.Raw(sql, pars).QueryRows(&list)
  62. return
  63. }