Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master' into master

lhs před 4 roky
rodič
revize
2d3b5d2f64

+ 10 - 1
api/grpc/base.go

@@ -41,7 +41,16 @@ func (Api) getToken(ctx context.Context) (token string) {
 
 func (a Api) SignIn(ctx context.Context, q *pb.SignInRequest) (*pb.SignInReply, error) {
 	token := service.User{}.SignInUserCodePassword(
-		q.Name, q.Password, a.getRemoteIp(ctx), a.getUserAgent(ctx))
+		q.Name, q.Password, a.getRemoteIp(ctx), a.getUserAgent(ctx), q.CodeID, q.VerifyCode)
 
 	return &pb.SignInReply{Token: token}, nil
 }
+
+func (a Api) GenVerifyImage(ctx context.Context, q *pb.GenVerifyImageRequest) (*pb.GenVerifyImageReply, error) {
+	codeId, imageBase64 := service.User{}.GenVerifyImage(q.Height, q.Width)
+	return &pb.GenVerifyImageReply{ImageBase64: imageBase64, CodeId: codeId}, nil
+}
+
+//func (a Api) SignUpInWithPhone()  {
+//
+//}

+ 197 - 25
api/grpc/base/base.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.23.0
-// 	protoc        v3.11.3
+// 	protoc-gen-go v1.25.0
+// 	protoc        v3.14.0
 // source: base.proto
 
 package base
@@ -251,8 +251,10 @@ type SignInRequest struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	Name     string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
-	Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
+	Name       string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
+	Password   string `protobuf:"bytes,2,opt,name=Password,proto3" json:"Password,omitempty"`
+	CodeID     string `protobuf:"bytes,3,opt,name=CodeID,proto3" json:"CodeID,omitempty"`
+	VerifyCode string `protobuf:"bytes,4,opt,name=VerifyCode,proto3" json:"VerifyCode,omitempty"`
 }
 
 func (x *SignInRequest) Reset() {
@@ -301,6 +303,130 @@ func (x *SignInRequest) GetPassword() string {
 	return ""
 }
 
+func (x *SignInRequest) GetCodeID() string {
+	if x != nil {
+		return x.CodeID
+	}
+	return ""
+}
+
+func (x *SignInRequest) GetVerifyCode() string {
+	if x != nil {
+		return x.VerifyCode
+	}
+	return ""
+}
+
+type GenVerifyImageRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Height int32 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
+	Width  int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"`
+}
+
+func (x *GenVerifyImageRequest) Reset() {
+	*x = GenVerifyImageRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_base_proto_msgTypes[5]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *GenVerifyImageRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GenVerifyImageRequest) ProtoMessage() {}
+
+func (x *GenVerifyImageRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_base_proto_msgTypes[5]
+	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 GenVerifyImageRequest.ProtoReflect.Descriptor instead.
+func (*GenVerifyImageRequest) Descriptor() ([]byte, []int) {
+	return file_base_proto_rawDescGZIP(), []int{5}
+}
+
+func (x *GenVerifyImageRequest) GetHeight() int32 {
+	if x != nil {
+		return x.Height
+	}
+	return 0
+}
+
+func (x *GenVerifyImageRequest) GetWidth() int32 {
+	if x != nil {
+		return x.Width
+	}
+	return 0
+}
+
+type GenVerifyImageReply struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	CodeId      string `protobuf:"bytes,1,opt,name=codeId,proto3" json:"codeId,omitempty"`
+	ImageBase64 string `protobuf:"bytes,2,opt,name=imageBase64,proto3" json:"imageBase64,omitempty"`
+}
+
+func (x *GenVerifyImageReply) Reset() {
+	*x = GenVerifyImageReply{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_base_proto_msgTypes[6]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *GenVerifyImageReply) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GenVerifyImageReply) ProtoMessage() {}
+
+func (x *GenVerifyImageReply) ProtoReflect() protoreflect.Message {
+	mi := &file_base_proto_msgTypes[6]
+	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 GenVerifyImageReply.ProtoReflect.Descriptor instead.
+func (*GenVerifyImageReply) Descriptor() ([]byte, []int) {
+	return file_base_proto_rawDescGZIP(), []int{6}
+}
+
+func (x *GenVerifyImageReply) GetCodeId() string {
+	if x != nil {
+		return x.CodeId
+	}
+	return ""
+}
+
+func (x *GenVerifyImageReply) GetImageBase64() string {
+	if x != nil {
+		return x.ImageBase64
+	}
+	return ""
+}
+
 var File_base_proto protoreflect.FileDescriptor
 
 var file_base_proto_rawDesc = []byte{
@@ -313,13 +439,26 @@ var file_base_proto_rawDesc = []byte{
 	0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73,
 	0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x23, 0x0a, 0x0b, 0x53, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x52,
 	0x65, 0x70, 0x6c, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20,
-	0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x3f, 0x0a, 0x0d, 0x53, 0x69,
-	0x67, 0x6e, 0x49, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e,
-	0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 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, 0x2a, 0x13, 0x0a, 0x09, 0x45,
+	0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x77, 0x0a, 0x0d, 0x53, 0x69,
+	0x67, 0x6e, 0x49, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x4e,
+	0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12,
+	0x1a, 0x0a, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x43,
+	0x6f, 0x64, 0x65, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x64,
+	0x65, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64,
+	0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43,
+	0x6f, 0x64, 0x65, 0x22, 0x45, 0x0a, 0x15, 0x47, 0x65, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79,
+	0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06,
+	0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x68, 0x65,
+	0x69, 0x67, 0x68, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x02, 0x20,
+	0x01, 0x28, 0x05, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x22, 0x4f, 0x0a, 0x13, 0x47, 0x65,
+	0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c,
+	0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x6d, 0x61,
+	0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x36, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
+	0x69, 0x6d, 0x61, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x36, 0x34, 0x2a, 0x13, 0x0a, 0x09, 0x45,
 	0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0x00,
-	0x32, 0xa5, 0x01, 0x0a, 0x03, 0x41, 0x70, 0x69, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e,
+	0x32, 0xf1, 0x01, 0x0a, 0x03, 0x41, 0x70, 0x69, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e,
 	0x55, 0x70, 0x12, 0x13, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x55, 0x70,
 	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x44,
 	0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x32, 0x0a,
@@ -329,8 +468,13 @@ var file_base_proto_rawDesc = []byte{
 	0x00, 0x12, 0x35, 0x0a, 0x07, 0x53, 0x69, 0x67, 0x6e, 0x4f, 0x75, 0x74, 0x12, 0x14, 0x2e, 0x62,
 	0x61, 0x73, 0x65, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
 	0x73, 0x74, 0x1a, 0x12, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c,
-	0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b, 0x62, 0x61,
-	0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0e, 0x47, 0x65, 0x6e, 0x56,
+	0x65, 0x72, 0x69, 0x66, 0x79, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x2e, 0x62, 0x61, 0x73,
+	0x65, 0x2e, 0x47, 0x65, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x49, 0x6d, 0x61, 0x67, 0x65,
+	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x47,
+	0x65, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70,
+	0x6c, 0x79, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b, 0x62, 0x61, 0x73, 0x65, 0x62, 0x06,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -346,24 +490,28 @@ func file_base_proto_rawDescGZIP() []byte {
 }
 
 var file_base_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_base_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
+var file_base_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
 var file_base_proto_goTypes = []interface{}{
-	(ErrorCode)(0),         // 0: base.ErrorCode
-	(*DefaultRequest)(nil), // 1: base.DefaultRequest
-	(*DefaultReply)(nil),   // 2: base.DefaultReply
-	(*SignUpRequest)(nil),  // 3: base.SignUpRequest
-	(*SignInReply)(nil),    // 4: base.SignInReply
-	(*SignInRequest)(nil),  // 5: base.SignInRequest
+	(ErrorCode)(0),                // 0: base.ErrorCode
+	(*DefaultRequest)(nil),        // 1: base.DefaultRequest
+	(*DefaultReply)(nil),          // 2: base.DefaultReply
+	(*SignUpRequest)(nil),         // 3: base.SignUpRequest
+	(*SignInReply)(nil),           // 4: base.SignInReply
+	(*SignInRequest)(nil),         // 5: base.SignInRequest
+	(*GenVerifyImageRequest)(nil), // 6: base.GenVerifyImageRequest
+	(*GenVerifyImageReply)(nil),   // 7: base.GenVerifyImageReply
 }
 var file_base_proto_depIdxs = []int32{
 	3, // 0: base.Api.SignUp:input_type -> base.SignUpRequest
 	5, // 1: base.Api.SignIn:input_type -> base.SignInRequest
 	1, // 2: base.Api.SignOut:input_type -> base.DefaultRequest
-	2, // 3: base.Api.SignUp:output_type -> base.DefaultReply
-	4, // 4: base.Api.SignIn:output_type -> base.SignInReply
-	2, // 5: base.Api.SignOut:output_type -> base.DefaultReply
-	3, // [3:6] is the sub-list for method output_type
-	0, // [0:3] is the sub-list for method input_type
+	6, // 3: base.Api.GenVerifyImage:input_type -> base.GenVerifyImageRequest
+	2, // 4: base.Api.SignUp:output_type -> base.DefaultReply
+	4, // 5: base.Api.SignIn:output_type -> base.SignInReply
+	2, // 6: base.Api.SignOut:output_type -> base.DefaultReply
+	7, // 7: base.Api.GenVerifyImage:output_type -> base.GenVerifyImageReply
+	4, // [4:8] is the sub-list for method output_type
+	0, // [0:4] 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
@@ -435,6 +583,30 @@ func file_base_proto_init() {
 				return nil
 			}
 		}
+		file_base_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*GenVerifyImageRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_base_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*GenVerifyImageReply); 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{
@@ -442,7 +614,7 @@ func file_base_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_base_proto_rawDesc,
 			NumEnums:      1,
-			NumMessages:   5,
+			NumMessages:   7,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 42 - 2
api/grpc/base/base_grpc.pb.go

@@ -11,6 +11,7 @@ import (
 
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the grpc package it is being compiled against.
+// Requires gRPC-Go v1.32.0 or later.
 const _ = grpc.SupportPackageIsVersion7
 
 // ApiClient is the client API for Api service.
@@ -20,6 +21,7 @@ type ApiClient interface {
 	SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*DefaultReply, error)
 	SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*SignInReply, error)
 	SignOut(ctx context.Context, in *DefaultRequest, opts ...grpc.CallOption) (*DefaultReply, error)
+	GenVerifyImage(ctx context.Context, in *GenVerifyImageRequest, opts ...grpc.CallOption) (*GenVerifyImageReply, error)
 }
 
 type apiClient struct {
@@ -57,6 +59,15 @@ func (c *apiClient) SignOut(ctx context.Context, in *DefaultRequest, opts ...grp
 	return out, nil
 }
 
+func (c *apiClient) GenVerifyImage(ctx context.Context, in *GenVerifyImageRequest, opts ...grpc.CallOption) (*GenVerifyImageReply, error) {
+	out := new(GenVerifyImageReply)
+	err := c.cc.Invoke(ctx, "/base.Api/GenVerifyImage", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // ApiServer is the server API for Api service.
 // All implementations must embed UnimplementedApiServer
 // for forward compatibility
@@ -64,6 +75,7 @@ type ApiServer interface {
 	SignUp(context.Context, *SignUpRequest) (*DefaultReply, error)
 	SignIn(context.Context, *SignInRequest) (*SignInReply, error)
 	SignOut(context.Context, *DefaultRequest) (*DefaultReply, error)
+	GenVerifyImage(context.Context, *GenVerifyImageRequest) (*GenVerifyImageReply, error)
 	mustEmbedUnimplementedApiServer()
 }
 
@@ -80,6 +92,9 @@ func (UnimplementedApiServer) SignIn(context.Context, *SignInRequest) (*SignInRe
 func (UnimplementedApiServer) SignOut(context.Context, *DefaultRequest) (*DefaultReply, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method SignOut not implemented")
 }
+func (UnimplementedApiServer) GenVerifyImage(context.Context, *GenVerifyImageRequest) (*GenVerifyImageReply, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GenVerifyImage not implemented")
+}
 func (UnimplementedApiServer) mustEmbedUnimplementedApiServer() {}
 
 // UnsafeApiServer may be embedded to opt out of forward compatibility for this service.
@@ -90,7 +105,7 @@ type UnsafeApiServer interface {
 }
 
 func RegisterApiServer(s grpc.ServiceRegistrar, srv ApiServer) {
-	s.RegisterService(&_Api_serviceDesc, srv)
+	s.RegisterService(&Api_ServiceDesc, srv)
 }
 
 func _Api_SignUp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
@@ -147,7 +162,28 @@ func _Api_SignOut_Handler(srv interface{}, ctx context.Context, dec func(interfa
 	return interceptor(ctx, in, info, handler)
 }
 
-var _Api_serviceDesc = grpc.ServiceDesc{
+func _Api_GenVerifyImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GenVerifyImageRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ApiServer).GenVerifyImage(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/base.Api/GenVerifyImage",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ApiServer).GenVerifyImage(ctx, req.(*GenVerifyImageRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+// Api_ServiceDesc is the grpc.ServiceDesc for Api service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var Api_ServiceDesc = grpc.ServiceDesc{
 	ServiceName: "base.Api",
 	HandlerType: (*ApiServer)(nil),
 	Methods: []grpc.MethodDesc{
@@ -163,6 +199,10 @@ var _Api_serviceDesc = grpc.ServiceDesc{
 			MethodName: "SignOut",
 			Handler:    _Api_SignOut_Handler,
 		},
+		{
+			MethodName: "GenVerifyImage",
+			Handler:    _Api_GenVerifyImage_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "base.proto",

+ 5 - 1
assembly/base/init.go

@@ -5,14 +5,18 @@ import (
 	"sportfitness/base/assembly/base/repository"
 	"sportfitness/base/assembly/base/repository/postgre"
 	"sportfitness/base/assembly/base/repository/redis"
+	"sportfitness/base/assembly/base/service"
 )
 
-func Init(){
+func Init() {
 	logrus.Info("基础库初始化")
 	repository.Init()
 	postgre.Init()
 	redis.Init()
 
+	//TODO 添加开关
+	service.RegisterServices()
+
 	logrus.Info("基础库初始化成功")
 	return
 }

+ 20 - 0
assembly/base/service/base.go

@@ -1,4 +1,24 @@
 package service
 
+import (
+	"git.beswell.com/gframe/application"
+	"github.com/sirupsen/logrus"
+	"sportfitness/base/repository/grpc/bsw/im"
+)
+
 type base struct {
 }
+
+func RegisterServices() {
+	application.GetApp().SetServiceRegisterHandler(func(servicePathList []string) {
+		logrus.Info("同步服务权限")
+
+		im.RegisterServiceList(servicePathList)
+	})
+
+	err := application.GetApp().RegisterService("",
+		User{})
+	if err != nil {
+		logrus.Fatalf("服务保存失败: \n%s", err)
+	}
+}

+ 10 - 2
assembly/base/service/user.go

@@ -6,11 +6,19 @@ type User struct {
 	base
 }
 
-func (User) SignInUserCodePassword(userCode, password, ip, ClientInfo string) (token string) {
+func (User) SignInUserCodePassword(userCode, password, ip, ClientInfo,
+	codeId, verifyCode string) (token string) {
 
-	token, userId := im.SignInUserCodePassword(userCode, password, ip, ClientInfo)
+	token, userId := im.SignInUserCodePassword(userCode, password, ip, ClientInfo,
+		codeId, verifyCode)
 
 	println(token, userId)
 
 	return token
 }
+
+func (User) GenVerifyImage(height, width int32) (string, string) {
+	codeId, imageBase64 := im.GenVerifyImage(height, width)
+
+	return codeId, imageBase64
+}

+ 22 - 6
proto/client/bsw/im/im.proto

@@ -10,10 +10,13 @@ enum ErrorCode{
   PARAM = 4001;
   Exist = 4002;
   Token = 4003;
+  PasswordWrongTooMuch = 4004;
+  VerifyCode = 4005;
 }
 
 // metadata: 综合管理系统前端调用需要字段 token 用作登录验证;子系统调用需要字段 sys_token 用作系统验证
 service Api {
+  rpc GenVerifyImage(GenVerifyImageRequest)returns(GenVerifyImageReply){}
   rpc SignUpUserCode (SignUpRequest) returns (CreateReply) {}
   rpc SignUpPhone (SignUpRequest) returns (CreateReply) {}
 
@@ -95,6 +98,17 @@ service Api {
 }
 message DefaultRequest{
 }
+
+message GenVerifyImageRequest{
+  int32 height = 1;
+  int32 width = 2;
+}
+message GenVerifyImageReply{
+  string codeId = 1;
+  string imageBase64 = 2;
+}
+
+
 message TokenParam{
   string token = 1;
 }
@@ -109,15 +123,17 @@ message CreateReply{
 }
 
 message SignInPasswordRequest {
+  string codeId = 1;
+  string verifyCode = 2;
   //登录凭据,用户名、手机号等
-  string credential = 1;
-  string password = 2;
+  string credential = 3;
+  string password = 4;
   //仅综合管理后台有效
-  int64 sysId = 3;
+  int64 sysId = 5;
   //session有效期,单位:秒
-  int64 expirationSec = 4;
-  string ip = 5;
-  string clientInfo = 6;
+  int64 expirationSec = 6;
+  string ip = 7;
+  string clientInfo = 8;
 }
 
 enum Status{

+ 60 - 2
proto/server/base.proto

@@ -13,11 +13,57 @@ service Api {
   rpc SignUp (SignUpRequest) returns (DefaultReply) {}
   rpc SignIn (SignInRequest) returns (SignInReply)  {}
   rpc SignOut (DefaultRequest) returns (DefaultReply)  {}
+  rpc GenVerifyImage (GenVerifyImageRequest) returns (GenVerifyImageReply)  {}
+
+  // 商家信息管理
+  rpc ManageableShopList (StandardRequest) returns (StandardReply) {}
+  rpc GetShopNavi (StandardRequest) returns (StandardReply) {}
+  rpc ShopGroupQuery (StandardRequest) returns (StandardReply) {}
+  rpc ShopGroupAdd (StandardRequest) returns (StandardReply) {}
+  rpc ShopGroupEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopGroupStatusEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopGroupDetailsQuery (StandardRequest) returns (StandardReply) {}
+  rpc ShopGroupDetailsAdd (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueQuery (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueAdd (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueStatusEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueEquipQuery (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueEquipAdd (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueEquipEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueEquipStatusEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopVenueEquipStatusDel (StandardRequest) returns (StandardReply) {}
+  rpc ShopManagerQuery (StandardRequest) returns (StandardReply) {}
+  rpc ShopManagerAdd (StandardRequest) returns (StandardReply) {}
+  rpc ShopManagerEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopManagerStatusEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopConfigQuery (StandardRequest) returns (StandardReply) {}
+  rpc ShopConfigEdit (StandardRequest) returns (StandardReply) {}
+  // 商家会员管理
+  rpc ShopVipUserQuery (StandardRequest) returns (StandardReply) {}
+  rpc ShopVipUserAdd (StandardRequest) returns (StandardReply) {}
+  rpc ShopVipUserEdit (StandardRequest) returns (StandardReply) {}
+  rpc ShopVipUserStatusEdit (StandardRequest) returns (StandardReply) {}
+  rpc AcrossVipUserQuery (StandardRequest) returns (StandardReply) {}
+  rpc AcrossVipUserAdd (StandardRequest) returns (StandardReply) {}
+  rpc AcrossVipUserDel (StandardRequest) returns (StandardReply) {}
+  // 心率
+  rpc SelectHrSensors (StandardRequest) returns (StandardReply)  {}
 }
 message DefaultRequest{
 }
 message DefaultReply{}
 
+message StandardRequest{
+  string Token = 1;
+  string JsonStr = 2;
+  string Sign = 3;
+}
+
+message StandardReply{
+  string JsonRst = 1;
+}
+
 message SignUpRequest {
   string name = 1;
   string password = 2;
@@ -28,6 +74,18 @@ message SignInReply {
 }
 
 message SignInRequest {
-  string name = 1;
-  string password = 2;
+  string Name = 1;
+  string Password = 2;
+  string CodeID = 3;
+  string VerifyCode = 4;
 }
+
+message GenVerifyImageRequest{
+  int32 height = 1;
+  int32 width = 2;
+}
+
+message GenVerifyImageReply{
+  string codeId = 1;
+  string imageBase64 = 2;
+}

+ 34 - 1
repository/grpc/bsw/im/api.go

@@ -32,13 +32,30 @@ func SignUpUserCode(params *pb.SignUpRequest) (userId int64) {
 	userId = r.GetId()
 	return
 }
-func SignInUserCodePassword(userCode, password, ip, ClientInfo string) (token string, userId int) {
+
+func GenVerifyImage(height, width int32) (id, imageBase64 string) {
+	r, err := getClient().GenVerifyImage(ctx(), &pb.GenVerifyImageRequest{
+		Height: int32(height),
+		Width:  int32(width),
+	})
+	if err != nil {
+		panic(err)
+	}
+
+	id = r.CodeId
+	imageBase64 = r.ImageBase64
+	return
+}
+
+func SignInUserCodePassword(userCode, password, ip, ClientInfo, codeId, verifyCode string) (token string, userId int) {
 	r, err := getClient().SignInUserCode(ctx(), &pb.SignInPasswordRequest{
 		Credential:    userCode,
 		Password:      password,
 		ExpirationSec: global.TokenExpireSec,
 		Ip:            ip,
 		ClientInfo:    ClientInfo,
+		CodeId:        codeId,
+		VerifyCode:    verifyCode,
 	})
 	if err != nil {
 		panic(err)
@@ -48,3 +65,19 @@ func SignInUserCodePassword(userCode, password, ip, ClientInfo string) (token st
 
 	return
 }
+
+func RegisterServiceList(servicePathList []string) {
+	request := &pb.SaveServiceListRequest{}
+
+	for _, p := range servicePathList {
+		request.List = append(request.List, &pb.Service{
+			Path: p,
+			Memo: "自动添加",
+		})
+	}
+
+	_, err := getClient().SubServiceSaveList(ctx(), request)
+	if err != nil {
+		panic(err)
+	}
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 237 - 105
repository/grpc/bsw/im/im/im.pb.go


+ 43 - 3
repository/grpc/bsw/im/im/im_grpc.pb.go

@@ -11,12 +11,14 @@ import (
 
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the grpc package it is being compiled against.
+// Requires gRPC-Go v1.32.0 or later.
 const _ = grpc.SupportPackageIsVersion7
 
 // ApiClient is the client API for Api service.
 //
 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
 type ApiClient interface {
+	GenVerifyImage(ctx context.Context, in *GenVerifyImageRequest, opts ...grpc.CallOption) (*GenVerifyImageReply, error)
 	SignUpUserCode(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*CreateReply, error)
 	SignUpPhone(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*CreateReply, error)
 	SignInUserCode(ctx context.Context, in *SignInPasswordRequest, opts ...grpc.CallOption) (*SignInReply, error)
@@ -85,6 +87,15 @@ func NewApiClient(cc grpc.ClientConnInterface) ApiClient {
 	return &apiClient{cc}
 }
 
+func (c *apiClient) GenVerifyImage(ctx context.Context, in *GenVerifyImageRequest, opts ...grpc.CallOption) (*GenVerifyImageReply, error) {
+	out := new(GenVerifyImageReply)
+	err := c.cc.Invoke(ctx, "/im.Api/GenVerifyImage", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 func (c *apiClient) SignUpUserCode(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*CreateReply, error) {
 	out := new(CreateReply)
 	err := c.cc.Invoke(ctx, "/im.Api/SignUpUserCode", in, out, opts...)
@@ -374,7 +385,7 @@ func (c *apiClient) IMSelfInfo(ctx context.Context, in *DefaultRequest, opts ...
 }
 
 func (c *apiClient) IMMessageRcv(ctx context.Context, in *DefaultRequest, opts ...grpc.CallOption) (Api_IMMessageRcvClient, error) {
-	stream, err := c.cc.NewStream(ctx, &_Api_serviceDesc.Streams[0], "/im.Api/IMMessageRcv", opts...)
+	stream, err := c.cc.NewStream(ctx, &Api_ServiceDesc.Streams[0], "/im.Api/IMMessageRcv", opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -409,6 +420,7 @@ func (x *apiIMMessageRcvClient) Recv() (*Message, error) {
 // All implementations must embed UnimplementedApiServer
 // for forward compatibility
 type ApiServer interface {
+	GenVerifyImage(context.Context, *GenVerifyImageRequest) (*GenVerifyImageReply, error)
 	SignUpUserCode(context.Context, *SignUpRequest) (*CreateReply, error)
 	SignUpPhone(context.Context, *SignUpRequest) (*CreateReply, error)
 	SignInUserCode(context.Context, *SignInPasswordRequest) (*SignInReply, error)
@@ -474,6 +486,9 @@ type ApiServer interface {
 type UnimplementedApiServer struct {
 }
 
+func (UnimplementedApiServer) GenVerifyImage(context.Context, *GenVerifyImageRequest) (*GenVerifyImageReply, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GenVerifyImage not implemented")
+}
 func (UnimplementedApiServer) SignUpUserCode(context.Context, *SignUpRequest) (*CreateReply, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method SignUpUserCode not implemented")
 }
@@ -583,7 +598,25 @@ type UnsafeApiServer interface {
 }
 
 func RegisterApiServer(s grpc.ServiceRegistrar, srv ApiServer) {
-	s.RegisterService(&_Api_serviceDesc, srv)
+	s.RegisterService(&Api_ServiceDesc, srv)
+}
+
+func _Api_GenVerifyImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GenVerifyImageRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ApiServer).GenVerifyImage(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/im.Api/GenVerifyImage",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ApiServer).GenVerifyImage(ctx, req.(*GenVerifyImageRequest))
+	}
+	return interceptor(ctx, in, info, handler)
 }
 
 func _Api_SignUpUserCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
@@ -1183,10 +1216,17 @@ func (x *apiIMMessageRcvServer) Send(m *Message) error {
 	return x.ServerStream.SendMsg(m)
 }
 
-var _Api_serviceDesc = grpc.ServiceDesc{
+// Api_ServiceDesc is the grpc.ServiceDesc for Api service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var Api_ServiceDesc = grpc.ServiceDesc{
 	ServiceName: "im.Api",
 	HandlerType: (*ApiServer)(nil),
 	Methods: []grpc.MethodDesc{
+		{
+			MethodName: "GenVerifyImage",
+			Handler:    _Api_GenVerifyImage_Handler,
+		},
 		{
 			MethodName: "SignUpUserCode",
 			Handler:    _Api_SignUpUserCode_Handler,

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů