用户接口远程调用
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.

96 lines
1.3 KiB

2 years ago
2 years ago
2 years ago
  1. package userrpc
  2. import (
  3. "log"
  4. "git.tetele.net/tgo/conf"
  5. )
  6. const DES_KEY = "usersrpc"
  7. type Req struct {
  8. SiteId string
  9. Dbname string
  10. }
  11. type Third struct {
  12. Userid string
  13. Platform string
  14. Openid string
  15. Openname string
  16. Unionid string
  17. Avatar string
  18. Mobile string
  19. }
  20. type BindThirdReq struct {
  21. Req
  22. Third
  23. }
  24. type GetThirdReq struct {
  25. Req
  26. Userid string
  27. Platform string
  28. }
  29. type GetBusinessReq struct {
  30. Req
  31. BusinessId string
  32. }
  33. type GetUserReq struct {
  34. Req
  35. UserId string
  36. }
  37. type GetAddressReq struct {
  38. Req
  39. AddressId string
  40. }
  41. type Res struct {
  42. Errcode int
  43. Errmsg string
  44. }
  45. type Business struct {
  46. Type string
  47. BusinessId string
  48. CustomerId string
  49. Name string
  50. CompanyId string
  51. Contact string
  52. Mobile string
  53. HandingFee string
  54. IsOpen string
  55. }
  56. type FansReq struct {
  57. Req
  58. UserId string
  59. BusinessId string
  60. Lock bool
  61. }
  62. func rpc_server_conn(url ...string) (*UserServiceClient, error) {
  63. log.Println("userpc rpc_server_conn----", url)
  64. var rpc_url string
  65. if len(url) > 0 && url[0] != "" {
  66. rpc_url = url[0]
  67. } else if conf.USER_RPC_URL != "" {
  68. rpc_url = conf.USER_RPC_URL
  69. } else {
  70. rpc_url = "127.0.0.1:" + conf.USER_RPC_PORT
  71. }
  72. log.Println("userpc rpc_url----", rpc_url)
  73. conn, _, err := DialUserService("tcp", rpc_url)
  74. if err != nil {
  75. return nil, err
  76. }
  77. return conn, nil
  78. }