provider_get_all_api.go 969 B

123456789101112131415161718192021222324252627282930
  1. package provider
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/errors"
  6. "fmt"
  7. "gd_management/common.in/utils"
  8. "github.com/astaxie/beego/orm"
  9. "go.uber.org/zap"
  10. )
  11. func ManagementGetAllProviderApi(ctx context.Context, req *apis.ManagementGetAllProviderApiReq, reply *apis.ManagementGetAllProviderApiReply) error {
  12. o := orm.NewOrm()
  13. sql := "select t1.id,thirdpart_host,thirdpart_api_name,thirdpart_api_router,thirdpart_api_method,platform_name, provider_api_code from t_gd_provider_api as t1 left join t_gd_provider as t2 on t1.provider_id = t2.id"
  14. if req.ProviderId > 0 {
  15. sql = fmt.Sprintf("%s where t2.id=%d", sql, req.ProviderId)
  16. }
  17. _, err := o.Raw(sql).QueryRows(&reply.ProviderApiBaseInfoList)
  18. if err != nil && err != orm.ErrNoRows {
  19. l.Error("mysql",
  20. zap.String("sql", "select t_gd_provider_api"),
  21. zap.String("fields", utils.MarshalJsonString(req)),
  22. zap.String("error", err.Error()))
  23. return errors.DataBaseError
  24. }
  25. return nil
  26. }