api_threshold.go 581 B

1234567891011121314151617181920212223
  1. package management
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/errors"
  6. "fmt"
  7. "github.com/astaxie/beego/orm"
  8. )
  9. func GetApiThreshold(ctx context.Context, req *apis.GetApiThresholdReq, reply *apis.GetApiThresholdReply) (err error) {
  10. tab := "t_gd_api"
  11. if req.Type == 1 {
  12. tab = "t_gd_provider_api"
  13. }
  14. sql := fmt.Sprintf("select threshold_timeout, threshold_fail_rate, threshold_norecord_rate, warning_enable from %s where id=?", tab)
  15. o := orm.NewOrm()
  16. err = o.Raw(sql, req.ApiId).QueryRow(&reply)
  17. if err != nil {
  18. return errors.DataBaseError
  19. }
  20. return nil
  21. }