用户接口远程调用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
873 B

  1. package userrpc
  2. import (
  3. "encoding/json"
  4. "errors"
  5. )
  6. func GetAddressInfo(site_id, dbname, address_id string, url ...string) (map[string]string, error) {
  7. if dbname == "" || address_id == "" {
  8. return nil, errors.New("参数错误")
  9. }
  10. conn, err := rpc_server_conn(url...)
  11. if err != nil {
  12. return nil, err
  13. }
  14. defer conn.Close()
  15. data := GetAddressReq{}
  16. data.SiteId = site_id
  17. data.Dbname = dbname
  18. data.AddressId = address_id
  19. req, err := SetReqData(data)
  20. if err != nil {
  21. return nil, err
  22. }
  23. res := &Response{}
  24. err = conn.GetAddressInfo(req, res)
  25. if err != nil {
  26. return nil, err
  27. }
  28. res_data_de, err := GetResData(res)
  29. if err != nil {
  30. return nil, err
  31. }
  32. if res_data_de == "" {
  33. return nil, nil
  34. }
  35. var res_arr map[string]string
  36. err = json.Unmarshal([]byte(res_data_de), &res_arr)
  37. if err != nil {
  38. return nil, err
  39. }
  40. return res_arr, nil
  41. }