edb_info_calculate_mapping.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package data_manage
  2. import (
  3. "github.com/rdlucklib/rdluck_tools/orm"
  4. "time"
  5. )
  6. //Seal 计算指标于基础指标,关系表
  7. type EdbInfoCalculateMapping struct {
  8. EdbInfoCalculateMappingId int `orm:"column(edb_info_calculate_mapping_id);pk"`
  9. EdbInfoId int `description:"计算指标id"`
  10. Source int `description:"计算指标来源"`
  11. SourceName string `description:"计算指标来源名称"`
  12. EdbCode string `description:"计算指标编码"`
  13. FromEdbInfoId int `description:"基础指标id"`
  14. FromEdbCode string `description:"基础指标编码"`
  15. FromEdbName string `description:"基础指标名称"`
  16. FromSource int `description:"基础指标来源"`
  17. FromSourceName string `description:"基础指标来源名称"`
  18. FromTag string `description:"来源指标标签"`
  19. Sort int `description:"计算指标名称排序"`
  20. CreateTime time.Time `description:"创建时间"`
  21. ModifyTime time.Time `description:"修改时间"`
  22. }
  23. func AddEdbInfoCalculateMappingMulti(items []*EdbInfoCalculateMapping) (err error) {
  24. o := orm.NewOrm()
  25. o.Using("data")
  26. _, err = o.InsertMulti(1, items)
  27. return
  28. }
  29. func GetEdbInfoCalculateMappingCount(edbInfoId int) (count int, err error) {
  30. o := orm.NewOrm()
  31. o.Using("data")
  32. sql := ` SELECT COUNT(1) AS count FROM edb_info_calculate_mapping WHERE from_edb_info_id=? `
  33. err = o.Raw(sql, edbInfoId).QueryRow(&count)
  34. return
  35. }
  36. type EdbInfoCalculateMappingView struct {
  37. EdbInfoCalculateMappingId int `orm:"column(edb_info_calculate_mapping_id);pk"`
  38. EdbInfoId int `description:"计算指标id"`
  39. Source int `description:"计算指标来源"`
  40. SourceName string `description:"计算指标来源名称"`
  41. EdbCode string `description:"计算指标编码"`
  42. FromEdbInfoId int `description:"基础指标id"`
  43. FromEdbCode string `description:"基础指标编码"`
  44. FromEdbName string `description:"基础指标名称"`
  45. FromSource int `description:"基础指标来源"`
  46. FromSourceName string `description:"基础指标来源名称"`
  47. FromTag string `description:"来源指标标签"`
  48. Sort int `description:"计算指标名称排序"`
  49. CreateTime time.Time `description:"创建时间"`
  50. ModifyTime time.Time `description:"修改时间"`
  51. StartDate string `description:"开始日期"`
  52. EndDate string `description:"结束日期"`
  53. CalculateFormula string `description:"N值"`
  54. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  55. MoveFrequency string `description:"移动频度"`
  56. }
  57. func GetEdbInfoCalculateMappingDetail(edbInfoId int) (item *EdbInfoCalculateMappingView, err error) {
  58. o := orm.NewOrm()
  59. o.Using("data")
  60. sql := ` SELECT a.*,b.start_date,b.end_date,b.calculate_formula,b.move_type,b.move_frequency FROM edb_info_calculate_mapping AS a
  61. INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  62. WHERE a.edb_info_id=? `
  63. err = o.Raw(sql, edbInfoId).QueryRow(&item)
  64. return
  65. }