chart.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package models
  2. import (
  3. "time"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type ChartInfoView struct {
  7. ChartInfoId int `orm:"column(chart_info_id);pk"`
  8. ChartName string `description:"来源名称"`
  9. ChartNameEn string `description:"英文图表名称"`
  10. Unit string `description:"中文单位名称"`
  11. UnitEn string `description:"英文单位名称"`
  12. ChartClassifyId int `description:"图表分类id"`
  13. ChartClassifyName string `description:"图表名称"`
  14. SysUserId int
  15. SysUserRealName string
  16. UniqueCode string `description:"图表唯一编码"`
  17. CreateTime time.Time
  18. ModifyTime time.Time
  19. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
  20. StartDate string `description:"自定义开始日期"`
  21. EndDate string `description:"自定义结束日期"`
  22. IsSetName int `description:"设置名称"`
  23. EdbInfoIds string `description:"指标id"`
  24. ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
  25. Calendar string `description:"公历/农历"`
  26. SeasonStartDate string `description:"季节性图开始日期"`
  27. SeasonEndDate string `description:"季节性图开始日期"`
  28. ChartImage string `description:"图表图片"`
  29. Sort int `description:"排序字段,数字越小越排前面"`
  30. IsAdd bool `description:"true:已加入我的图库,false:未加入我的图库"`
  31. MyChartId int
  32. MyChartClassifyId string `description:"我的图表分类,多个用逗号隔开"`
  33. ChartClassify []*ChartClassifyView
  34. EdbEndDate string `description:"指标最新更新日期"`
  35. XMin string `description:"图表X轴最小值"`
  36. XMax string `description:"图表X轴最大值"`
  37. LeftMin string `description:"图表左侧最小值"`
  38. LeftMax string `description:"图表左侧最大值"`
  39. RightMin string `description:"图表右侧最小值"`
  40. RightMax string `description:"图表右侧最大值"`
  41. Right2Min string `description:"图表右侧最小值"`
  42. Right2Max string `description:"图表右侧最大值"`
  43. MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
  44. IsEdit bool `description:"是否有编辑权限"`
  45. IsEnChart bool `description:"是否展示英文标识"`
  46. WarnMsg string `description:"错误信息"`
  47. Disabled int `description:"是否禁用,0:启用,1:禁用,默认:0"`
  48. BarConfig string `description:"柱方图的配置,json数据" json:"-"`
  49. Source int `description:"1:ETA图库;2:商品价格曲线;3:相关性图表"`
  50. //CorrelationLeadUnit string `description:"相关性图表-领先单位"`
  51. ExtraConfig string `description:"图表额外配置,json数据"`
  52. ChartSource string `description:"图表来源str"`
  53. ChartSourceEn string `description:"图表来源(英文)"`
  54. Button ChartViewButton `description:"操作按钮"`
  55. SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
  56. StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
  57. ChartThemeId int `description:"图表应用主题ID"`
  58. ChartThemeStyle string `description:"图表应用主题样式"`
  59. SourcesFrom string `description:"图表来源"`
  60. Instructions string `description:"图表说明"`
  61. MarkersLines string `description:"标识线"`
  62. MarkersAreas string `description:"标识区"`
  63. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  64. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  65. ForumChartInfoId int `description:"社区的图表ID"`
  66. }
  67. type ChartClassifyView struct {
  68. ChartClassifyId int `orm:"column(chart_classify_id);pk"`
  69. ChartClassifyName string `description:"分类名称"`
  70. ParentId int `description:"父级id"`
  71. }
  72. type ChartViewButton struct {
  73. IsEdit bool `description:"是否有编辑权限"`
  74. IsEnChart bool `description:"是否展示英文标识"`
  75. IsAdd bool `description:"true:已加入我的图库,false:未加入我的图库"`
  76. IsCopy bool `description:"是否有另存为按钮"`
  77. IsSetName int `description:"设置名称"`
  78. }
  79. func GetChartCount() (count int, err error) {
  80. o := orm.NewOrmUsingDB("data")
  81. sql := ` SELECT COUNT(*) AS count FROM chart_info WHERE 1=1 `
  82. err = o.Raw(sql).QueryRow(&count)
  83. return
  84. }
  85. func GetChartList(startSize, pageSize int) (item []*ChartInfoView, err error) {
  86. o := orm.NewOrmUsingDB("data")
  87. sql := ` SELECT * FROM chart_info WHERE 1=1 ORDER BY create_time DESC LIMIT ?,? `
  88. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&item)
  89. return
  90. }
  91. func GetChartById(chartInfoId int) (item *ChartInfoView, err error) {
  92. o := orm.NewOrmUsingDB("data")
  93. sql := ` SELECT * FROM chart_info WHERE chart_info_id=?`
  94. err = o.Raw(sql, chartInfoId).QueryRow(&item)
  95. return
  96. }
  97. func GetChartByUniqueCode(uniqueCode string) (item *ChartInfoView, err error) {
  98. o := orm.NewOrmUsingDB("data")
  99. sql := ` SELECT * FROM chart_info WHERE unique_code=?`
  100. err = o.Raw(sql, uniqueCode).QueryRow(&item)
  101. return
  102. }