edb_data_from_python.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // EdbDataPython python指标数据结构体
  7. type EdbDataPython struct {
  8. EdbDataId int `orm:"column(edb_data_id);pk"`
  9. EdbInfoId int
  10. EdbCode string
  11. DataTime string
  12. Value float64
  13. CreateTime time.Time
  14. ModifyTime time.Time
  15. DataTimestamp int64
  16. }
  17. // GetAllEdbDataPythonByEdbInfoId 根据指标id获取全部的数据
  18. func GetAllEdbDataPythonByEdbInfoId(edbInfoId int) (items []*EdbDataPython, err error) {
  19. o := orm.NewOrmUsingDB("data")
  20. sql := ` SELECT * FROM edb_data_python WHERE edb_info_id=? ORDER BY data_time DESC `
  21. _, err = o.Raw(sql, edbInfoId).QueryRows(&items)
  22. return
  23. }
  24. // EdbInfoPythonSaveReq 计算(运算)指标请求参数
  25. type EdbInfoPythonSaveReq struct {
  26. AdminId int `description:"添加人id"`
  27. AdminName string `description:"添加人名称"`
  28. EdbName string `description:"指标名称"`
  29. Frequency string `description:"频率"`
  30. Unit string `description:"单位"`
  31. ClassifyId int `description:"分类id"`
  32. CalculateFormula string `description:"计算公式"`
  33. EdbInfoIdArr []struct {
  34. EdbInfoId int `description:"指标id"`
  35. FromTag string `description:"指标对应标签"`
  36. }
  37. }
  38. // ExecPythonEdbReq 执行python代码运算指标的请求参数
  39. type ExecPythonEdbReq struct {
  40. PythonCode string `description:"python代码"`
  41. }
  42. // AddPythonEdbReq 添加python代码运算指标的请求参数
  43. type AddPythonEdbReq struct {
  44. EdbInfoId int `description:"指标id"`
  45. EdbName string `description:"指标名称"`
  46. Frequency string `description:"频度"`
  47. Unit string `description:"单位"`
  48. ClassifyId int `description:"分类id"`
  49. PythonCode string `description:"python代码"`
  50. }
  51. // PostAddPythonEdbReq 添加python代码运算指标的请求参数(请求指标服务)
  52. type PostAddPythonEdbReq struct {
  53. AdminId int `description:"添加人id"`
  54. AdminName string `description:"添加人名称"`
  55. EdbInfoId int `description:"指标id"`
  56. EdbName string `description:"指标名称"`
  57. Frequency string `description:"频度"`
  58. Unit string `description:"单位"`
  59. ClassifyId int `description:"分类id"`
  60. PythonCode string `description:"python代码"`
  61. }
  62. // PythonEdbDetailResp python指标详情接口
  63. type PythonEdbDetailResp struct {
  64. EdbInfoDetail *EdbInfo
  65. PythonCode string
  66. }
  67. // TableInfoResp 指标数据表结构
  68. type TableInfoResp struct {
  69. ColumnList []map[string]string
  70. TableName string
  71. TemplateStr string
  72. }