chart_info.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type ChartInfo struct {
  7. ChartInfoId int `orm:"column(chart_info_id);pk"`
  8. ChartName string `description:"来源名称"`
  9. ChartClassifyId int `description:"图表分类id"`
  10. SysUserId int
  11. SysUserRealName string
  12. UniqueCode string `description:"图表唯一编码"`
  13. CreateTime time.Time
  14. ModifyTime time.Time
  15. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
  16. StartDate string `description:"自定义开始日期"`
  17. EndDate string `description:"自定义结束日期"`
  18. IsSetName int `description:"设置名称"`
  19. EdbInfoIds string `description:"指标id"`
  20. ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
  21. Calendar string `description:"公历/农历"`
  22. SeasonStartDate string `description:"季节性图开始日期"`
  23. SeasonEndDate string `description:"季节性图开始日期"`
  24. ChartImage string `description:"图表图片"`
  25. Sort int `description:"排序字段,数字越小越排前面"`
  26. EdbEndDate string `description:"指标最后更新日期"`
  27. }
  28. func GetAllChartInfo() (list []*ChartInfo, err error) {
  29. o := orm.NewOrmUsingDB("data")
  30. sql := ` SELECT * FROM chart_info `
  31. _, err = o.Raw(sql).QueryRows(&list)
  32. return
  33. }
  34. func GetChartInfoEdbEndDate() (list []*ChartInfo, err error) {
  35. o := orm.NewOrmUsingDB("data")
  36. sql := ` SELECT a.*,max(c.end_date) AS edb_end_date FROM chart_info AS a
  37. INNER JOIN chart_edb_mapping AS b ON a.chart_info_id=b.chart_info_id
  38. INNER JOIN edb_info AS c ON b.edb_info_id=c.edb_info_id
  39. GROUP BY a.chart_info_id `
  40. _, err = o.Raw(sql).QueryRows(&list)
  41. return
  42. }
  43. func ModifyChartInfoEdbEndDate(chartInfoId int, edbEndDate string) (err error) {
  44. o := orm.NewOrmUsingDB("data")
  45. sql := ` UPDATE chart_info SET edb_end_date=? WHERE chart_info_id=? `
  46. _, err = o.Raw(sql, edbEndDate, chartInfoId).Exec()
  47. return
  48. }