init
This commit is contained in:
@@ -0,0 +1,315 @@
|
||||
// Code generated by Fastpb v0.0.2. DO NOT EDIT.
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
fastpb "github.com/cloudwego/fastpb"
|
||||
)
|
||||
|
||||
var (
|
||||
_ = fmt.Errorf
|
||||
_ = fastpb.Skip
|
||||
)
|
||||
|
||||
func (x *RegisterReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) {
|
||||
switch number {
|
||||
case 1:
|
||||
offset, err = x.fastReadField1(buf, _type)
|
||||
if err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
case 2:
|
||||
offset, err = x.fastReadField2(buf, _type)
|
||||
if err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
default:
|
||||
offset, err = fastpb.Skip(buf, _type, number)
|
||||
if err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
return offset, nil
|
||||
SkipFieldError:
|
||||
return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err)
|
||||
ReadFieldError:
|
||||
return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_RegisterReq[number], err)
|
||||
}
|
||||
|
||||
func (x *RegisterReq) fastReadField1(buf []byte, _type int8) (offset int, err error) {
|
||||
x.Email, offset, err = fastpb.ReadString(buf, _type)
|
||||
return offset, err
|
||||
}
|
||||
|
||||
func (x *RegisterReq) fastReadField2(buf []byte, _type int8) (offset int, err error) {
|
||||
x.Password, offset, err = fastpb.ReadString(buf, _type)
|
||||
return offset, err
|
||||
}
|
||||
|
||||
func (x *RegisterResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) {
|
||||
switch number {
|
||||
case 1:
|
||||
offset, err = x.fastReadField1(buf, _type)
|
||||
if err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
default:
|
||||
offset, err = fastpb.Skip(buf, _type, number)
|
||||
if err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
return offset, nil
|
||||
SkipFieldError:
|
||||
return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err)
|
||||
ReadFieldError:
|
||||
return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_RegisterResp[number], err)
|
||||
}
|
||||
|
||||
func (x *RegisterResp) fastReadField1(buf []byte, _type int8) (offset int, err error) {
|
||||
x.UserId, offset, err = fastpb.ReadInt32(buf, _type)
|
||||
return offset, err
|
||||
}
|
||||
|
||||
func (x *LoginReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) {
|
||||
switch number {
|
||||
case 1:
|
||||
offset, err = x.fastReadField1(buf, _type)
|
||||
if err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
case 2:
|
||||
offset, err = x.fastReadField2(buf, _type)
|
||||
if err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
default:
|
||||
offset, err = fastpb.Skip(buf, _type, number)
|
||||
if err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
return offset, nil
|
||||
SkipFieldError:
|
||||
return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err)
|
||||
ReadFieldError:
|
||||
return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_LoginReq[number], err)
|
||||
}
|
||||
|
||||
func (x *LoginReq) fastReadField1(buf []byte, _type int8) (offset int, err error) {
|
||||
x.Email, offset, err = fastpb.ReadString(buf, _type)
|
||||
return offset, err
|
||||
}
|
||||
|
||||
func (x *LoginReq) fastReadField2(buf []byte, _type int8) (offset int, err error) {
|
||||
x.Password, offset, err = fastpb.ReadString(buf, _type)
|
||||
return offset, err
|
||||
}
|
||||
|
||||
func (x *LoginResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) {
|
||||
switch number {
|
||||
case 1:
|
||||
offset, err = x.fastReadField1(buf, _type)
|
||||
if err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
default:
|
||||
offset, err = fastpb.Skip(buf, _type, number)
|
||||
if err != nil {
|
||||
goto SkipFieldError
|
||||
}
|
||||
}
|
||||
return offset, nil
|
||||
SkipFieldError:
|
||||
return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err)
|
||||
ReadFieldError:
|
||||
return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_LoginResp[number], err)
|
||||
}
|
||||
|
||||
func (x *LoginResp) fastReadField1(buf []byte, _type int8) (offset int, err error) {
|
||||
x.UserId, offset, err = fastpb.ReadInt32(buf, _type)
|
||||
return offset, err
|
||||
}
|
||||
|
||||
func (x *RegisterReq) FastWrite(buf []byte) (offset int) {
|
||||
if x == nil {
|
||||
return offset
|
||||
}
|
||||
offset += x.fastWriteField1(buf[offset:])
|
||||
offset += x.fastWriteField2(buf[offset:])
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *RegisterReq) fastWriteField1(buf []byte) (offset int) {
|
||||
if x.Email == "" {
|
||||
return offset
|
||||
}
|
||||
offset += fastpb.WriteString(buf[offset:], 1, x.GetEmail())
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *RegisterReq) fastWriteField2(buf []byte) (offset int) {
|
||||
if x.Password == "" {
|
||||
return offset
|
||||
}
|
||||
offset += fastpb.WriteString(buf[offset:], 2, x.GetPassword())
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *RegisterResp) FastWrite(buf []byte) (offset int) {
|
||||
if x == nil {
|
||||
return offset
|
||||
}
|
||||
offset += x.fastWriteField1(buf[offset:])
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *RegisterResp) fastWriteField1(buf []byte) (offset int) {
|
||||
if x.UserId == 0 {
|
||||
return offset
|
||||
}
|
||||
offset += fastpb.WriteInt32(buf[offset:], 1, x.GetUserId())
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *LoginReq) FastWrite(buf []byte) (offset int) {
|
||||
if x == nil {
|
||||
return offset
|
||||
}
|
||||
offset += x.fastWriteField1(buf[offset:])
|
||||
offset += x.fastWriteField2(buf[offset:])
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *LoginReq) fastWriteField1(buf []byte) (offset int) {
|
||||
if x.Email == "" {
|
||||
return offset
|
||||
}
|
||||
offset += fastpb.WriteString(buf[offset:], 1, x.GetEmail())
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *LoginReq) fastWriteField2(buf []byte) (offset int) {
|
||||
if x.Password == "" {
|
||||
return offset
|
||||
}
|
||||
offset += fastpb.WriteString(buf[offset:], 2, x.GetPassword())
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *LoginResp) FastWrite(buf []byte) (offset int) {
|
||||
if x == nil {
|
||||
return offset
|
||||
}
|
||||
offset += x.fastWriteField1(buf[offset:])
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *LoginResp) fastWriteField1(buf []byte) (offset int) {
|
||||
if x.UserId == 0 {
|
||||
return offset
|
||||
}
|
||||
offset += fastpb.WriteInt32(buf[offset:], 1, x.GetUserId())
|
||||
return offset
|
||||
}
|
||||
|
||||
func (x *RegisterReq) Size() (n int) {
|
||||
if x == nil {
|
||||
return n
|
||||
}
|
||||
n += x.sizeField1()
|
||||
n += x.sizeField2()
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *RegisterReq) sizeField1() (n int) {
|
||||
if x.Email == "" {
|
||||
return n
|
||||
}
|
||||
n += fastpb.SizeString(1, x.GetEmail())
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *RegisterReq) sizeField2() (n int) {
|
||||
if x.Password == "" {
|
||||
return n
|
||||
}
|
||||
n += fastpb.SizeString(2, x.GetPassword())
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *RegisterResp) Size() (n int) {
|
||||
if x == nil {
|
||||
return n
|
||||
}
|
||||
n += x.sizeField1()
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *RegisterResp) sizeField1() (n int) {
|
||||
if x.UserId == 0 {
|
||||
return n
|
||||
}
|
||||
n += fastpb.SizeInt32(1, x.GetUserId())
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *LoginReq) Size() (n int) {
|
||||
if x == nil {
|
||||
return n
|
||||
}
|
||||
n += x.sizeField1()
|
||||
n += x.sizeField2()
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *LoginReq) sizeField1() (n int) {
|
||||
if x.Email == "" {
|
||||
return n
|
||||
}
|
||||
n += fastpb.SizeString(1, x.GetEmail())
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *LoginReq) sizeField2() (n int) {
|
||||
if x.Password == "" {
|
||||
return n
|
||||
}
|
||||
n += fastpb.SizeString(2, x.GetPassword())
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *LoginResp) Size() (n int) {
|
||||
if x == nil {
|
||||
return n
|
||||
}
|
||||
n += x.sizeField1()
|
||||
return n
|
||||
}
|
||||
|
||||
func (x *LoginResp) sizeField1() (n int) {
|
||||
if x.UserId == 0 {
|
||||
return n
|
||||
}
|
||||
n += fastpb.SizeInt32(1, x.GetUserId())
|
||||
return n
|
||||
}
|
||||
|
||||
var fieldIDToName_RegisterReq = map[int32]string{
|
||||
1: "Email",
|
||||
2: "Password",
|
||||
}
|
||||
|
||||
var fieldIDToName_RegisterResp = map[int32]string{
|
||||
1: "UserId",
|
||||
}
|
||||
|
||||
var fieldIDToName_LoginReq = map[int32]string{
|
||||
1: "Email",
|
||||
2: "Password",
|
||||
}
|
||||
|
||||
var fieldIDToName_LoginResp = map[int32]string{
|
||||
1: "UserId",
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v5.29.2
|
||||
// source: user.proto
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
context "context"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type RegisterReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RegisterReq) Reset() {
|
||||
*x = RegisterReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RegisterReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RegisterReq) ProtoMessage() {}
|
||||
|
||||
func (x *RegisterReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RegisterReq.ProtoReflect.Descriptor instead.
|
||||
func (*RegisterReq) Descriptor() ([]byte, []int) {
|
||||
return file_user_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *RegisterReq) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RegisterReq) GetPassword() string {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type RegisterResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RegisterResp) Reset() {
|
||||
*x = RegisterResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RegisterResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RegisterResp) ProtoMessage() {}
|
||||
|
||||
func (x *RegisterResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RegisterResp.ProtoReflect.Descriptor instead.
|
||||
func (*RegisterResp) Descriptor() ([]byte, []int) {
|
||||
return file_user_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *RegisterResp) GetUserId() int32 {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
|
||||
}
|
||||
|
||||
func (x *LoginReq) Reset() {
|
||||
*x = LoginReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *LoginReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LoginReq) ProtoMessage() {}
|
||||
|
||||
func (x *LoginReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use LoginReq.ProtoReflect.Descriptor instead.
|
||||
func (*LoginReq) Descriptor() ([]byte, []int) {
|
||||
return file_user_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *LoginReq) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *LoginReq) GetPassword() string {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
|
||||
}
|
||||
|
||||
func (x *LoginResp) Reset() {
|
||||
*x = LoginResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *LoginResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LoginResp) ProtoMessage() {}
|
||||
|
||||
func (x *LoginResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use LoginResp.ProtoReflect.Descriptor instead.
|
||||
func (*LoginResp) Descriptor() ([]byte, []int) {
|
||||
return file_user_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *LoginResp) GetUserId() int32 {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_user_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_user_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73,
|
||||
0x65, 0x72, 0x22, 0x3f, 0x0a, 0x0b, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65,
|
||||
0x71, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77,
|
||||
0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77,
|
||||
0x6f, 0x72, 0x64, 0x22, 0x27, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52,
|
||||
0x65, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x3c, 0x0a, 0x08,
|
||||
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69,
|
||||
0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x24, 0x0a, 0x09, 0x4c, 0x6f,
|
||||
0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f,
|
||||
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
|
||||
0x32, 0x6f, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
|
||||
0x34, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x75, 0x73,
|
||||
0x65, 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x1a,
|
||||
0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52,
|
||||
0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x2a, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0e,
|
||||
0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0f,
|
||||
0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22,
|
||||
0x00, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
||||
0x73, 0x75, 0x79, 0x69, 0x69, 0x79, 0x69, 0x69, 0x2f, 0x68, 0x65, 0x72, 0x74, 0x7a, 0x31, 0x30,
|
||||
0x31, 0x2f, 0x72, 0x70, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f,
|
||||
0x67, 0x65, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_user_proto_rawDescOnce sync.Once
|
||||
file_user_proto_rawDescData = file_user_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_user_proto_rawDescGZIP() []byte {
|
||||
file_user_proto_rawDescOnce.Do(func() {
|
||||
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData)
|
||||
})
|
||||
return file_user_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_user_proto_goTypes = []interface{}{
|
||||
(*RegisterReq)(nil), // 0: user.RegisterReq
|
||||
(*RegisterResp)(nil), // 1: user.RegisterResp
|
||||
(*LoginReq)(nil), // 2: user.LoginReq
|
||||
(*LoginResp)(nil), // 3: user.LoginResp
|
||||
}
|
||||
var file_user_proto_depIdxs = []int32{
|
||||
1, // 0: user.UserService.Register:input_type -> user.RegisterResp
|
||||
2, // 1: user.UserService.Login:input_type -> user.LoginReq
|
||||
1, // 2: user.UserService.Register:output_type -> user.RegisterResp
|
||||
3, // 3: user.UserService.Login:output_type -> user.LoginResp
|
||||
2, // [2:4] is the sub-list for method output_type
|
||||
0, // [0:2] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_user_proto_init() }
|
||||
func file_user_proto_init() {
|
||||
if File_user_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*RegisterReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*RegisterResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*LoginReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*LoginResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_user_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_user_proto_goTypes,
|
||||
DependencyIndexes: file_user_proto_depIdxs,
|
||||
MessageInfos: file_user_proto_msgTypes,
|
||||
}.Build()
|
||||
File_user_proto = out.File
|
||||
file_user_proto_rawDesc = nil
|
||||
file_user_proto_goTypes = nil
|
||||
file_user_proto_depIdxs = nil
|
||||
}
|
||||
|
||||
var _ context.Context
|
||||
|
||||
// Code generated by Kitex v0.9.1. DO NOT EDIT.
|
||||
|
||||
type UserService interface {
|
||||
Register(ctx context.Context, req *RegisterResp) (res *RegisterResp, err error)
|
||||
Login(ctx context.Context, req *LoginReq) (res *LoginResp, err error)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// Code generated by Kitex v0.9.1. DO NOT EDIT.
|
||||
|
||||
package userservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
client "github.com/cloudwego/kitex/client"
|
||||
callopt "github.com/cloudwego/kitex/client/callopt"
|
||||
user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user"
|
||||
)
|
||||
|
||||
// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework.
|
||||
type Client interface {
|
||||
Register(ctx context.Context, Req *user.RegisterResp, callOptions ...callopt.Option) (r *user.RegisterResp, err error)
|
||||
Login(ctx context.Context, Req *user.LoginReq, callOptions ...callopt.Option) (r *user.LoginResp, err error)
|
||||
}
|
||||
|
||||
// NewClient creates a client for the service defined in IDL.
|
||||
func NewClient(destService string, opts ...client.Option) (Client, error) {
|
||||
var options []client.Option
|
||||
options = append(options, client.WithDestService(destService))
|
||||
|
||||
options = append(options, opts...)
|
||||
|
||||
kc, err := client.NewClient(serviceInfo(), options...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &kUserServiceClient{
|
||||
kClient: newServiceClient(kc),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs.
|
||||
func MustNewClient(destService string, opts ...client.Option) Client {
|
||||
kc, err := NewClient(destService, opts...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return kc
|
||||
}
|
||||
|
||||
type kUserServiceClient struct {
|
||||
*kClient
|
||||
}
|
||||
|
||||
func (p *kUserServiceClient) Register(ctx context.Context, Req *user.RegisterResp, callOptions ...callopt.Option) (r *user.RegisterResp, err error) {
|
||||
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
||||
return p.kClient.Register(ctx, Req)
|
||||
}
|
||||
|
||||
func (p *kUserServiceClient) Login(ctx context.Context, Req *user.LoginReq, callOptions ...callopt.Option) (r *user.LoginResp, err error) {
|
||||
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
||||
return p.kClient.Login(ctx, Req)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Code generated by Kitex v0.9.1. DO NOT EDIT.
|
||||
|
||||
package userservice
|
||||
|
||||
import (
|
||||
server "github.com/cloudwego/kitex/server"
|
||||
user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user"
|
||||
)
|
||||
|
||||
// NewInvoker creates a server.Invoker with the given handler and options.
|
||||
func NewInvoker(handler user.UserService, opts ...server.Option) server.Invoker {
|
||||
var options []server.Option
|
||||
|
||||
options = append(options, opts...)
|
||||
|
||||
s := server.NewInvoker(options...)
|
||||
if err := s.RegisterService(serviceInfo(), handler); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := s.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Code generated by Kitex v0.9.1. DO NOT EDIT.
|
||||
package userservice
|
||||
|
||||
import (
|
||||
server "github.com/cloudwego/kitex/server"
|
||||
user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user"
|
||||
)
|
||||
|
||||
// NewServer creates a server.Server with the given handler and options.
|
||||
func NewServer(handler user.UserService, opts ...server.Option) server.Server {
|
||||
var options []server.Option
|
||||
|
||||
options = append(options, opts...)
|
||||
|
||||
svr := server.NewServer(options...)
|
||||
if err := svr.RegisterService(serviceInfo(), handler); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return svr
|
||||
}
|
||||
|
||||
func RegisterService(svr server.Server, handler user.UserService, opts ...server.RegisterOption) error {
|
||||
return svr.RegisterService(serviceInfo(), handler, opts...)
|
||||
}
|
||||
@@ -0,0 +1,432 @@
|
||||
// Code generated by Kitex v0.9.1. DO NOT EDIT.
|
||||
|
||||
package userservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
client "github.com/cloudwego/kitex/client"
|
||||
kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
|
||||
streaming "github.com/cloudwego/kitex/pkg/streaming"
|
||||
user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user"
|
||||
proto "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var errInvalidMessageType = errors.New("invalid message type for service method handler")
|
||||
|
||||
var serviceMethods = map[string]kitex.MethodInfo{
|
||||
"Register": kitex.NewMethodInfo(
|
||||
registerHandler,
|
||||
newRegisterArgs,
|
||||
newRegisterResult,
|
||||
false,
|
||||
kitex.WithStreamingMode(kitex.StreamingUnary),
|
||||
),
|
||||
"Login": kitex.NewMethodInfo(
|
||||
loginHandler,
|
||||
newLoginArgs,
|
||||
newLoginResult,
|
||||
false,
|
||||
kitex.WithStreamingMode(kitex.StreamingUnary),
|
||||
),
|
||||
}
|
||||
|
||||
var (
|
||||
userServiceServiceInfo = NewServiceInfo()
|
||||
userServiceServiceInfoForClient = NewServiceInfoForClient()
|
||||
userServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient()
|
||||
)
|
||||
|
||||
// for server
|
||||
func serviceInfo() *kitex.ServiceInfo {
|
||||
return userServiceServiceInfo
|
||||
}
|
||||
|
||||
// for client
|
||||
func serviceInfoForStreamClient() *kitex.ServiceInfo {
|
||||
return userServiceServiceInfoForStreamClient
|
||||
}
|
||||
|
||||
// for stream client
|
||||
func serviceInfoForClient() *kitex.ServiceInfo {
|
||||
return userServiceServiceInfoForClient
|
||||
}
|
||||
|
||||
// NewServiceInfo creates a new ServiceInfo containing all methods
|
||||
func NewServiceInfo() *kitex.ServiceInfo {
|
||||
return newServiceInfo(false, true, true)
|
||||
}
|
||||
|
||||
// NewServiceInfo creates a new ServiceInfo containing non-streaming methods
|
||||
func NewServiceInfoForClient() *kitex.ServiceInfo {
|
||||
return newServiceInfo(false, false, true)
|
||||
}
|
||||
func NewServiceInfoForStreamClient() *kitex.ServiceInfo {
|
||||
return newServiceInfo(true, true, false)
|
||||
}
|
||||
|
||||
func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo {
|
||||
serviceName := "UserService"
|
||||
handlerType := (*user.UserService)(nil)
|
||||
methods := map[string]kitex.MethodInfo{}
|
||||
for name, m := range serviceMethods {
|
||||
if m.IsStreaming() && !keepStreamingMethods {
|
||||
continue
|
||||
}
|
||||
if !m.IsStreaming() && !keepNonStreamingMethods {
|
||||
continue
|
||||
}
|
||||
methods[name] = m
|
||||
}
|
||||
extra := map[string]interface{}{
|
||||
"PackageName": "user",
|
||||
}
|
||||
if hasStreaming {
|
||||
extra["streaming"] = hasStreaming
|
||||
}
|
||||
svcInfo := &kitex.ServiceInfo{
|
||||
ServiceName: serviceName,
|
||||
HandlerType: handlerType,
|
||||
Methods: methods,
|
||||
PayloadCodec: kitex.Protobuf,
|
||||
KiteXGenVersion: "v0.9.1",
|
||||
Extra: extra,
|
||||
}
|
||||
return svcInfo
|
||||
}
|
||||
|
||||
func registerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
||||
switch s := arg.(type) {
|
||||
case *streaming.Args:
|
||||
st := s.Stream
|
||||
req := new(user.RegisterResp)
|
||||
if err := st.RecvMsg(req); err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := handler.(user.UserService).Register(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return st.SendMsg(resp)
|
||||
case *RegisterArgs:
|
||||
success, err := handler.(user.UserService).Register(ctx, s.Req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
realResult := result.(*RegisterResult)
|
||||
realResult.Success = success
|
||||
return nil
|
||||
default:
|
||||
return errInvalidMessageType
|
||||
}
|
||||
}
|
||||
func newRegisterArgs() interface{} {
|
||||
return &RegisterArgs{}
|
||||
}
|
||||
|
||||
func newRegisterResult() interface{} {
|
||||
return &RegisterResult{}
|
||||
}
|
||||
|
||||
type RegisterArgs struct {
|
||||
Req *user.RegisterResp
|
||||
}
|
||||
|
||||
func (p *RegisterArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) {
|
||||
if !p.IsSetReq() {
|
||||
p.Req = new(user.RegisterResp)
|
||||
}
|
||||
return p.Req.FastRead(buf, _type, number)
|
||||
}
|
||||
|
||||
func (p *RegisterArgs) FastWrite(buf []byte) (n int) {
|
||||
if !p.IsSetReq() {
|
||||
return 0
|
||||
}
|
||||
return p.Req.FastWrite(buf)
|
||||
}
|
||||
|
||||
func (p *RegisterArgs) Size() (n int) {
|
||||
if !p.IsSetReq() {
|
||||
return 0
|
||||
}
|
||||
return p.Req.Size()
|
||||
}
|
||||
|
||||
func (p *RegisterArgs) Marshal(out []byte) ([]byte, error) {
|
||||
if !p.IsSetReq() {
|
||||
return out, nil
|
||||
}
|
||||
return proto.Marshal(p.Req)
|
||||
}
|
||||
|
||||
func (p *RegisterArgs) Unmarshal(in []byte) error {
|
||||
msg := new(user.RegisterResp)
|
||||
if err := proto.Unmarshal(in, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Req = msg
|
||||
return nil
|
||||
}
|
||||
|
||||
var RegisterArgs_Req_DEFAULT *user.RegisterResp
|
||||
|
||||
func (p *RegisterArgs) GetReq() *user.RegisterResp {
|
||||
if !p.IsSetReq() {
|
||||
return RegisterArgs_Req_DEFAULT
|
||||
}
|
||||
return p.Req
|
||||
}
|
||||
|
||||
func (p *RegisterArgs) IsSetReq() bool {
|
||||
return p.Req != nil
|
||||
}
|
||||
|
||||
func (p *RegisterArgs) GetFirstArgument() interface{} {
|
||||
return p.Req
|
||||
}
|
||||
|
||||
type RegisterResult struct {
|
||||
Success *user.RegisterResp
|
||||
}
|
||||
|
||||
var RegisterResult_Success_DEFAULT *user.RegisterResp
|
||||
|
||||
func (p *RegisterResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) {
|
||||
if !p.IsSetSuccess() {
|
||||
p.Success = new(user.RegisterResp)
|
||||
}
|
||||
return p.Success.FastRead(buf, _type, number)
|
||||
}
|
||||
|
||||
func (p *RegisterResult) FastWrite(buf []byte) (n int) {
|
||||
if !p.IsSetSuccess() {
|
||||
return 0
|
||||
}
|
||||
return p.Success.FastWrite(buf)
|
||||
}
|
||||
|
||||
func (p *RegisterResult) Size() (n int) {
|
||||
if !p.IsSetSuccess() {
|
||||
return 0
|
||||
}
|
||||
return p.Success.Size()
|
||||
}
|
||||
|
||||
func (p *RegisterResult) Marshal(out []byte) ([]byte, error) {
|
||||
if !p.IsSetSuccess() {
|
||||
return out, nil
|
||||
}
|
||||
return proto.Marshal(p.Success)
|
||||
}
|
||||
|
||||
func (p *RegisterResult) Unmarshal(in []byte) error {
|
||||
msg := new(user.RegisterResp)
|
||||
if err := proto.Unmarshal(in, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Success = msg
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *RegisterResult) GetSuccess() *user.RegisterResp {
|
||||
if !p.IsSetSuccess() {
|
||||
return RegisterResult_Success_DEFAULT
|
||||
}
|
||||
return p.Success
|
||||
}
|
||||
|
||||
func (p *RegisterResult) SetSuccess(x interface{}) {
|
||||
p.Success = x.(*user.RegisterResp)
|
||||
}
|
||||
|
||||
func (p *RegisterResult) IsSetSuccess() bool {
|
||||
return p.Success != nil
|
||||
}
|
||||
|
||||
func (p *RegisterResult) GetResult() interface{} {
|
||||
return p.Success
|
||||
}
|
||||
|
||||
func loginHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
||||
switch s := arg.(type) {
|
||||
case *streaming.Args:
|
||||
st := s.Stream
|
||||
req := new(user.LoginReq)
|
||||
if err := st.RecvMsg(req); err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := handler.(user.UserService).Login(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return st.SendMsg(resp)
|
||||
case *LoginArgs:
|
||||
success, err := handler.(user.UserService).Login(ctx, s.Req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
realResult := result.(*LoginResult)
|
||||
realResult.Success = success
|
||||
return nil
|
||||
default:
|
||||
return errInvalidMessageType
|
||||
}
|
||||
}
|
||||
func newLoginArgs() interface{} {
|
||||
return &LoginArgs{}
|
||||
}
|
||||
|
||||
func newLoginResult() interface{} {
|
||||
return &LoginResult{}
|
||||
}
|
||||
|
||||
type LoginArgs struct {
|
||||
Req *user.LoginReq
|
||||
}
|
||||
|
||||
func (p *LoginArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) {
|
||||
if !p.IsSetReq() {
|
||||
p.Req = new(user.LoginReq)
|
||||
}
|
||||
return p.Req.FastRead(buf, _type, number)
|
||||
}
|
||||
|
||||
func (p *LoginArgs) FastWrite(buf []byte) (n int) {
|
||||
if !p.IsSetReq() {
|
||||
return 0
|
||||
}
|
||||
return p.Req.FastWrite(buf)
|
||||
}
|
||||
|
||||
func (p *LoginArgs) Size() (n int) {
|
||||
if !p.IsSetReq() {
|
||||
return 0
|
||||
}
|
||||
return p.Req.Size()
|
||||
}
|
||||
|
||||
func (p *LoginArgs) Marshal(out []byte) ([]byte, error) {
|
||||
if !p.IsSetReq() {
|
||||
return out, nil
|
||||
}
|
||||
return proto.Marshal(p.Req)
|
||||
}
|
||||
|
||||
func (p *LoginArgs) Unmarshal(in []byte) error {
|
||||
msg := new(user.LoginReq)
|
||||
if err := proto.Unmarshal(in, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Req = msg
|
||||
return nil
|
||||
}
|
||||
|
||||
var LoginArgs_Req_DEFAULT *user.LoginReq
|
||||
|
||||
func (p *LoginArgs) GetReq() *user.LoginReq {
|
||||
if !p.IsSetReq() {
|
||||
return LoginArgs_Req_DEFAULT
|
||||
}
|
||||
return p.Req
|
||||
}
|
||||
|
||||
func (p *LoginArgs) IsSetReq() bool {
|
||||
return p.Req != nil
|
||||
}
|
||||
|
||||
func (p *LoginArgs) GetFirstArgument() interface{} {
|
||||
return p.Req
|
||||
}
|
||||
|
||||
type LoginResult struct {
|
||||
Success *user.LoginResp
|
||||
}
|
||||
|
||||
var LoginResult_Success_DEFAULT *user.LoginResp
|
||||
|
||||
func (p *LoginResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) {
|
||||
if !p.IsSetSuccess() {
|
||||
p.Success = new(user.LoginResp)
|
||||
}
|
||||
return p.Success.FastRead(buf, _type, number)
|
||||
}
|
||||
|
||||
func (p *LoginResult) FastWrite(buf []byte) (n int) {
|
||||
if !p.IsSetSuccess() {
|
||||
return 0
|
||||
}
|
||||
return p.Success.FastWrite(buf)
|
||||
}
|
||||
|
||||
func (p *LoginResult) Size() (n int) {
|
||||
if !p.IsSetSuccess() {
|
||||
return 0
|
||||
}
|
||||
return p.Success.Size()
|
||||
}
|
||||
|
||||
func (p *LoginResult) Marshal(out []byte) ([]byte, error) {
|
||||
if !p.IsSetSuccess() {
|
||||
return out, nil
|
||||
}
|
||||
return proto.Marshal(p.Success)
|
||||
}
|
||||
|
||||
func (p *LoginResult) Unmarshal(in []byte) error {
|
||||
msg := new(user.LoginResp)
|
||||
if err := proto.Unmarshal(in, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Success = msg
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *LoginResult) GetSuccess() *user.LoginResp {
|
||||
if !p.IsSetSuccess() {
|
||||
return LoginResult_Success_DEFAULT
|
||||
}
|
||||
return p.Success
|
||||
}
|
||||
|
||||
func (p *LoginResult) SetSuccess(x interface{}) {
|
||||
p.Success = x.(*user.LoginResp)
|
||||
}
|
||||
|
||||
func (p *LoginResult) IsSetSuccess() bool {
|
||||
return p.Success != nil
|
||||
}
|
||||
|
||||
func (p *LoginResult) GetResult() interface{} {
|
||||
return p.Success
|
||||
}
|
||||
|
||||
type kClient struct {
|
||||
c client.Client
|
||||
}
|
||||
|
||||
func newServiceClient(c client.Client) *kClient {
|
||||
return &kClient{
|
||||
c: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *kClient) Register(ctx context.Context, Req *user.RegisterResp) (r *user.RegisterResp, err error) {
|
||||
var _args RegisterArgs
|
||||
_args.Req = Req
|
||||
var _result RegisterResult
|
||||
if err = p.c.Call(ctx, "Register", &_args, &_result); err != nil {
|
||||
return
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
|
||||
func (p *kClient) Login(ctx context.Context, Req *user.LoginReq) (r *user.LoginResp, err error) {
|
||||
var _args LoginArgs
|
||||
_args.Req = Req
|
||||
var _result LoginResult
|
||||
if err = p.c.Call(ctx, "Login", &_args, &_result); err != nil {
|
||||
return
|
||||
}
|
||||
return _result.GetSuccess(), nil
|
||||
}
|
||||
Reference in New Issue
Block a user