management_get_name.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package management
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/errors"
  6. "github.com/astaxie/beego/orm"
  7. )
  8. func ManagementGetName(ctx context.Context, req *apis.ManagementGetNameReq, reply *apis.ManagementGetNameReply) error {
  9. o := orm.NewOrm()
  10. if req.MerchantId != 0 {
  11. err := o.Raw("select merchant_name from t_gd_merchants where id=?", req.MerchantId).QueryRow(&reply.MerchantName)
  12. if err != nil {
  13. return errors.DataBaseError
  14. }
  15. }
  16. if req.ApiId != 0 {
  17. err := o.Raw("select name from t_gd_api where id=?", req.ApiId).QueryRow(&reply.ApiName)
  18. if err != nil {
  19. return errors.DataBaseError
  20. }
  21. }
  22. if req.ProviderApiId != 0 {
  23. err := o.Raw("select a.thirdpart_api_name,b.id,b.platform_name from t_gd_provider_api as a left join t_gd_provider as b on a.provider_id= b.id where a.id=?", req.ProviderApiId).QueryRow(&reply.ProviderApiName, &reply.ProviderId, &reply.ProviderName)
  24. if err != nil {
  25. return errors.DataBaseError
  26. }
  27. }
  28. if req.H5ServiceId != 0 {
  29. err := o.Raw("select service_name from t_gd_h5_service where id=?", req.H5ServiceId).QueryRow(&reply.H5ServiceName)
  30. if err != nil {
  31. return errors.DataBaseError
  32. }
  33. }
  34. if req.H5ApiId != 0 {
  35. err := o.Raw("select name from t_gd_h5_api where id=?", req.H5ApiId).QueryRow(&reply.H5ApiName)
  36. if err != nil {
  37. return errors.DataBaseError
  38. }
  39. }
  40. return nil
  41. }