report_chapter_ticker.go 2.6 KB

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