calculate_stl_config_mapping.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package stl
  2. import (
  3. "time"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type CalculateStlConfigMapping struct {
  7. Id int `orm:"pk" description:"主键"`
  8. CalculateStlConfigId int `description:"stl配置id"`
  9. EdbInfoId int `description:"edb信息id"`
  10. StlEdbType int `description:"stl指标类型: 1-Trend, 2-Seasonal, 3-Residual"`
  11. CreateTime time.Time `description:"创建时间"`
  12. ModifyTime time.Time `description:"修改时间"`
  13. }
  14. func (c *CalculateStlConfigMapping) Insert() (insertId int64, err error) {
  15. o := orm.NewOrmUsingDB("data")
  16. insertId, err = o.Insert(c)
  17. return
  18. }
  19. // GetCalculateStlConfigMappingIdByEdbInfoId 获取配置文件id
  20. func GetCalculateStlConfigMappingIdByEdbInfoId(edbInfoId int) (configId int, err error) {
  21. o := orm.NewOrmUsingDB("data")
  22. sql := `SELECT calculate_stl_config_id FROM calculate_stl_config_mapping WHERE edb_info_id=? LIMIT 1`
  23. err = o.Raw(sql, edbInfoId).QueryRow(&configId)
  24. return
  25. }
  26. // GetCalculateStlConfigMappingByConfigId 根据配置文件id获取配置文件映射信息
  27. func GetCalculateStlConfigMappingByConfigId(configId int) (items []*CalculateStlConfigMapping, err error) {
  28. o := orm.NewOrmUsingDB("data")
  29. sql := `SELECT * FROM calculate_stl_config_mapping WHERE calculate_stl_config_id=?`
  30. _, err = o.Raw(sql, configId).QueryRows(&items)
  31. return
  32. }