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.

478 lines
12 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. // Code generated by protoc-gen-go.
  2. // source: user.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package user is a generated protocol buffer package.
  6. It is generated from these files:
  7. user.proto
  8. It has these top-level messages:
  9. UserRequest
  10. UserInfoByUsername
  11. UserInfoByUsercode
  12. UserResponse
  13. LoginRequest
  14. LoginResponse
  15. */
  16. package user
  17. import proto "github.com/chai2010/protorpc/proto"
  18. import math "math"
  19. import "io"
  20. import "log"
  21. import "net"
  22. import "net/rpc"
  23. import "time"
  24. import protorpc "github.com/chai2010/protorpc"
  25. // Reference imports to suppress errors if they are not otherwise used.
  26. var _ = proto.Marshal
  27. var _ = math.Inf
  28. // 使用token查询用户信息请求结构
  29. type UserRequest struct {
  30. Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`
  31. Token *string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
  32. XXX_unrecognized []byte `json:"-"`
  33. }
  34. func (m *UserRequest) Reset() { *m = UserRequest{} }
  35. func (m *UserRequest) String() string { return proto.CompactTextString(m) }
  36. func (*UserRequest) ProtoMessage() {}
  37. func (m *UserRequest) GetDbname() string {
  38. if m != nil && m.Dbname != nil {
  39. return *m.Dbname
  40. }
  41. return ""
  42. }
  43. func (m *UserRequest) GetToken() string {
  44. if m != nil && m.Token != nil {
  45. return *m.Token
  46. }
  47. return ""
  48. }
  49. // 使用username查询用户信息请求结构
  50. type UserInfoByUsername struct {
  51. Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`
  52. Username *string `protobuf:"bytes,2,opt,name=username" json:"username,omitempty"`
  53. XXX_unrecognized []byte `json:"-"`
  54. }
  55. func (m *UserInfoByUsername) Reset() { *m = UserInfoByUsername{} }
  56. func (m *UserInfoByUsername) String() string { return proto.CompactTextString(m) }
  57. func (*UserInfoByUsername) ProtoMessage() {}
  58. func (m *UserInfoByUsername) GetDbname() string {
  59. if m != nil && m.Dbname != nil {
  60. return *m.Dbname
  61. }
  62. return ""
  63. }
  64. func (m *UserInfoByUsername) GetUsername() string {
  65. if m != nil && m.Username != nil {
  66. return *m.Username
  67. }
  68. return ""
  69. }
  70. // 使用usercode查询用户信息请求结构
  71. type UserInfoByUsercode struct {
  72. Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`
  73. Usercode *string `protobuf:"bytes,2,opt,name=usercode" json:"usercode,omitempty"`
  74. XXX_unrecognized []byte `json:"-"`
  75. }
  76. func (m *UserInfoByUsercode) Reset() { *m = UserInfoByUsercode{} }
  77. func (m *UserInfoByUsercode) String() string { return proto.CompactTextString(m) }
  78. func (*UserInfoByUsercode) ProtoMessage() {}
  79. func (m *UserInfoByUsercode) GetDbname() string {
  80. if m != nil && m.Dbname != nil {
  81. return *m.Dbname
  82. }
  83. return ""
  84. }
  85. func (m *UserInfoByUsercode) GetUsercode() string {
  86. if m != nil && m.Usercode != nil {
  87. return *m.Usercode
  88. }
  89. return ""
  90. }
  91. // 使用token查询用户信息响应结构
  92. type UserResponse struct {
  93. UserId *string `protobuf:"bytes,1,opt,name=user_id" json:"user_id,omitempty"`
  94. Username *string `protobuf:"bytes,2,opt,name=username" json:"username,omitempty"`
  95. Nickname *string `protobuf:"bytes,3,opt,name=nickname" json:"nickname,omitempty"`
  96. Mobile *string `protobuf:"bytes,4,opt,name=mobile" json:"mobile,omitempty"`
  97. Email *string `protobuf:"bytes,5,opt,name=email" json:"email,omitempty"`
  98. Status *string `protobuf:"bytes,6,opt,name=status" json:"status,omitempty"`
  99. BusinessId *string `protobuf:"bytes,7,opt,name=business_id" json:"business_id,omitempty"`
  100. StoreId *string `protobuf:"bytes,8,opt,name=store_id" json:"store_id,omitempty"`
  101. FansTo *string `protobuf:"bytes,9,opt,name=fans_to" json:"fans_to,omitempty"`
  102. IsVip *string `protobuf:"bytes,10,opt,name=is_vip" json:"is_vip,omitempty"`
  103. Usercode *string `protobuf:"bytes,11,opt,name=usercode" json:"usercode,omitempty"`
  104. GroupId *string `protobuf:"bytes,12,opt,name=group_id" json:"group_id,omitempty"`
  105. Type *string `protobuf:"bytes,13,opt,name=type" json:"type,omitempty"`
  106. XXX_unrecognized []byte `json:"-"`
  107. }
  108. func (m *UserResponse) Reset() { *m = UserResponse{} }
  109. func (m *UserResponse) String() string { return proto.CompactTextString(m) }
  110. func (*UserResponse) ProtoMessage() {}
  111. func (m *UserResponse) GetUserId() string {
  112. if m != nil && m.UserId != nil {
  113. return *m.UserId
  114. }
  115. return ""
  116. }
  117. func (m *UserResponse) GetUsername() string {
  118. if m != nil && m.Username != nil {
  119. return *m.Username
  120. }
  121. return ""
  122. }
  123. func (m *UserResponse) GetNickname() string {
  124. if m != nil && m.Nickname != nil {
  125. return *m.Nickname
  126. }
  127. return ""
  128. }
  129. func (m *UserResponse) GetMobile() string {
  130. if m != nil && m.Mobile != nil {
  131. return *m.Mobile
  132. }
  133. return ""
  134. }
  135. func (m *UserResponse) GetEmail() string {
  136. if m != nil && m.Email != nil {
  137. return *m.Email
  138. }
  139. return ""
  140. }
  141. func (m *UserResponse) GetStatus() string {
  142. if m != nil && m.Status != nil {
  143. return *m.Status
  144. }
  145. return ""
  146. }
  147. func (m *UserResponse) GetBusinessId() string {
  148. if m != nil && m.BusinessId != nil {
  149. return *m.BusinessId
  150. }
  151. return ""
  152. }
  153. func (m *UserResponse) GetStoreId() string {
  154. if m != nil && m.StoreId != nil {
  155. return *m.StoreId
  156. }
  157. return ""
  158. }
  159. func (m *UserResponse) GetFansTo() string {
  160. if m != nil && m.FansTo != nil {
  161. return *m.FansTo
  162. }
  163. return ""
  164. }
  165. func (m *UserResponse) GetIsVip() string {
  166. if m != nil && m.IsVip != nil {
  167. return *m.IsVip
  168. }
  169. return ""
  170. }
  171. func (m *UserResponse) GetUsercode() string {
  172. if m != nil && m.Usercode != nil {
  173. return *m.Usercode
  174. }
  175. return ""
  176. }
  177. func (m *UserResponse) GetGroupId() string {
  178. if m != nil && m.GroupId != nil {
  179. return *m.GroupId
  180. }
  181. return ""
  182. }
  183. func (m *UserResponse) GetType() string {
  184. if m != nil && m.Type != nil {
  185. return *m.Type
  186. }
  187. return ""
  188. }
  189. // 用户登录请求结构
  190. type LoginRequest struct {
  191. Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`
  192. Account *string `protobuf:"bytes,2,opt,name=account" json:"account,omitempty"`
  193. Password *string `protobuf:"bytes,3,opt,name=password" json:"password,omitempty"`
  194. XXX_unrecognized []byte `json:"-"`
  195. }
  196. func (m *LoginRequest) Reset() { *m = LoginRequest{} }
  197. func (m *LoginRequest) String() string { return proto.CompactTextString(m) }
  198. func (*LoginRequest) ProtoMessage() {}
  199. func (m *LoginRequest) GetDbname() string {
  200. if m != nil && m.Dbname != nil {
  201. return *m.Dbname
  202. }
  203. return ""
  204. }
  205. func (m *LoginRequest) GetAccount() string {
  206. if m != nil && m.Account != nil {
  207. return *m.Account
  208. }
  209. return ""
  210. }
  211. func (m *LoginRequest) GetPassword() string {
  212. if m != nil && m.Password != nil {
  213. return *m.Password
  214. }
  215. return ""
  216. }
  217. // 使用token查询用户信息响应结构
  218. type LoginResponse struct {
  219. UserId *string `protobuf:"bytes,1,opt,name=user_id" json:"user_id,omitempty"`
  220. Username *string `protobuf:"bytes,2,opt,name=username" json:"username,omitempty"`
  221. Nickname *string `protobuf:"bytes,3,opt,name=nickname" json:"nickname,omitempty"`
  222. Mobile *string `protobuf:"bytes,4,opt,name=mobile" json:"mobile,omitempty"`
  223. Email *string `protobuf:"bytes,5,opt,name=email" json:"email,omitempty"`
  224. Status *string `protobuf:"bytes,6,opt,name=status" json:"status,omitempty"`
  225. BusinessId *string `protobuf:"bytes,7,opt,name=business_id" json:"business_id,omitempty"`
  226. StoreId *string `protobuf:"bytes,8,opt,name=store_id" json:"store_id,omitempty"`
  227. FansTo *string `protobuf:"bytes,9,opt,name=fans_to" json:"fans_to,omitempty"`
  228. IsVip *string `protobuf:"bytes,10,opt,name=is_vip" json:"is_vip,omitempty"`
  229. Token *string `protobuf:"bytes,11,opt,name=token" json:"token,omitempty"`
  230. Usercode *string `protobuf:"bytes,12,opt,name=usercode" json:"usercode,omitempty"`
  231. GroupId *string `protobuf:"bytes,13,opt,name=group_id" json:"group_id,omitempty"`
  232. Type *string `protobuf:"bytes,14,opt,name=type" json:"type,omitempty"`
  233. XXX_unrecognized []byte `json:"-"`
  234. }
  235. func (m *LoginResponse) Reset() { *m = LoginResponse{} }
  236. func (m *LoginResponse) String() string { return proto.CompactTextString(m) }
  237. func (*LoginResponse) ProtoMessage() {}
  238. func (m *LoginResponse) GetUserId() string {
  239. if m != nil && m.UserId != nil {
  240. return *m.UserId
  241. }
  242. return ""
  243. }
  244. func (m *LoginResponse) GetUsername() string {
  245. if m != nil && m.Username != nil {
  246. return *m.Username
  247. }
  248. return ""
  249. }
  250. func (m *LoginResponse) GetNickname() string {
  251. if m != nil && m.Nickname != nil {
  252. return *m.Nickname
  253. }
  254. return ""
  255. }
  256. func (m *LoginResponse) GetMobile() string {
  257. if m != nil && m.Mobile != nil {
  258. return *m.Mobile
  259. }
  260. return ""
  261. }
  262. func (m *LoginResponse) GetEmail() string {
  263. if m != nil && m.Email != nil {
  264. return *m.Email
  265. }
  266. return ""
  267. }
  268. func (m *LoginResponse) GetStatus() string {
  269. if m != nil && m.Status != nil {
  270. return *m.Status
  271. }
  272. return ""
  273. }
  274. func (m *LoginResponse) GetBusinessId() string {
  275. if m != nil && m.BusinessId != nil {
  276. return *m.BusinessId
  277. }
  278. return ""
  279. }
  280. func (m *LoginResponse) GetStoreId() string {
  281. if m != nil && m.StoreId != nil {
  282. return *m.StoreId
  283. }
  284. return ""
  285. }
  286. func (m *LoginResponse) GetFansTo() string {
  287. if m != nil && m.FansTo != nil {
  288. return *m.FansTo
  289. }
  290. return ""
  291. }
  292. func (m *LoginResponse) GetIsVip() string {
  293. if m != nil && m.IsVip != nil {
  294. return *m.IsVip
  295. }
  296. return ""
  297. }
  298. func (m *LoginResponse) GetToken() string {
  299. if m != nil && m.Token != nil {
  300. return *m.Token
  301. }
  302. return ""
  303. }
  304. func (m *LoginResponse) GetUsercode() string {
  305. if m != nil && m.Usercode != nil {
  306. return *m.Usercode
  307. }
  308. return ""
  309. }
  310. func (m *LoginResponse) GetGroupId() string {
  311. if m != nil && m.GroupId != nil {
  312. return *m.GroupId
  313. }
  314. return ""
  315. }
  316. func (m *LoginResponse) GetType() string {
  317. if m != nil && m.Type != nil {
  318. return *m.Type
  319. }
  320. return ""
  321. }
  322. func init() {
  323. }
  324. type UserService interface {
  325. GetByToken(in *UserRequest, out *UserResponse) error
  326. Login(in *LoginRequest, out *LoginResponse) error
  327. }
  328. // AcceptUserServiceClient accepts connections on the listener and serves requests
  329. // for each incoming connection. Accept blocks; the caller typically
  330. // invokes it in a go statement.
  331. func AcceptUserServiceClient(lis net.Listener, x UserService) {
  332. srv := rpc.NewServer()
  333. if err := srv.RegisterName("UserService", x); err != nil {
  334. log.Fatal(err)
  335. }
  336. for {
  337. conn, err := lis.Accept()
  338. if err != nil {
  339. log.Fatalf("lis.Accept(): %v\n", err)
  340. }
  341. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  342. }
  343. }
  344. // RegisterUserService publish the given UserService implementation on the server.
  345. func RegisterUserService(srv *rpc.Server, x UserService) error {
  346. if err := srv.RegisterName("UserService", x); err != nil {
  347. return err
  348. }
  349. return nil
  350. }
  351. // NewUserServiceServer returns a new UserService Server.
  352. func NewUserServiceServer(x UserService) *rpc.Server {
  353. srv := rpc.NewServer()
  354. if err := srv.RegisterName("UserService", x); err != nil {
  355. log.Fatal(err)
  356. }
  357. return srv
  358. }
  359. // ListenAndServeUserService listen announces on the local network address laddr
  360. // and serves the given UserService implementation.
  361. func ListenAndServeUserService(network, addr string, x UserService) error {
  362. lis, err := net.Listen(network, addr)
  363. if err != nil {
  364. return err
  365. }
  366. defer lis.Close()
  367. srv := rpc.NewServer()
  368. if err := srv.RegisterName("UserService", x); err != nil {
  369. return err
  370. }
  371. for {
  372. conn, err := lis.Accept()
  373. if err != nil {
  374. log.Fatalf("lis.Accept(): %v\n", err)
  375. }
  376. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  377. }
  378. }
  379. type UserServiceClient struct {
  380. *rpc.Client
  381. }
  382. // NewUserServiceClient returns a UserService rpc.Client and stub to handle
  383. // requests to the set of UserService at the other end of the connection.
  384. func NewUserServiceClient(conn io.ReadWriteCloser) (*UserServiceClient, *rpc.Client) {
  385. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  386. return &UserServiceClient{c}, c
  387. }
  388. func (c *UserServiceClient) GetByToken(in *UserRequest, out *UserResponse) error {
  389. return c.Call("UserService.GetByToken", in, out)
  390. }
  391. func (c *UserServiceClient) Login(in *LoginRequest, out *LoginResponse) error {
  392. return c.Call("UserService.Login", in, out)
  393. }
  394. // DialUserService connects to an UserService at the specified network address.
  395. func DialUserService(network, addr string) (*UserServiceClient, *rpc.Client, error) {
  396. c, err := protorpc.Dial(network, addr)
  397. if err != nil {
  398. return nil, nil, err
  399. }
  400. return &UserServiceClient{c}, c, nil
  401. }
  402. // DialUserServiceTimeout connects to an UserService at the specified network address.
  403. func DialUserServiceTimeout(network, addr string,
  404. timeout time.Duration) (*UserServiceClient, *rpc.Client, error) {
  405. c, err := protorpc.DialTimeout(network, addr, timeout)
  406. if err != nil {
  407. return nil, nil, err
  408. }
  409. return &UserServiceClient{c}, c, nil
  410. }