站点RPC方法
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.

56 lines
825 B

3 years ago
3 years ago
3 years ago
  1. package siterpc
  2. import (
  3. "encoding/json"
  4. "errors"
  5. )
  6. /**
  7. * 获取code_bank一条可用记录
  8. * 2021/09/09
  9. * linsen
  10. */
  11. func GetOneCode(site_id, dbname string, url ...string) (string, error) {
  12. if dbname == "" {
  13. return "", errors.New("参数错误")
  14. }
  15. conn, err := rpc_server_conn(url...)
  16. if err != nil {
  17. return "", err
  18. }
  19. defer conn.Close()
  20. arg := SiteConfigItemReqArg{site_id, dbname, ""}
  21. req, err := SetReqData(arg)
  22. if err != nil {
  23. return "", err
  24. }
  25. res := &Response{}
  26. err = conn.GetOneCode(req, res)
  27. if err != nil {
  28. return "", err
  29. }
  30. res_data_de, err := GetResData(res)
  31. if err != nil {
  32. return "", err
  33. }
  34. var bankCode string
  35. err = json.Unmarshal([]byte(res_data_de),&bankCode)
  36. if err != nil {
  37. return "", err
  38. }
  39. if res_data_de == "" {
  40. return "", nil
  41. }
  42. return bankCode, nil
  43. }