From d0453c222dcefcdbae8d9979ebaf13624eb76050 Mon Sep 17 00:00:00 2001 From: daiyb <570956418@qq.com> Date: Fri, 23 May 2025 13:25:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0cast=E5=BE=AE=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/cast/cast.pb.go | 91 ++++++++++++++++++----------------- api/cast/cast.validator.pb.go | 4 +- api/cast/cast_triple.pb.go | 26 +++++----- pkg/router/media.go | 18 +++++++ pkg/router/router.go | 1 + pkg/service/cast/media.go | 22 +++++++++ pkg/service/init.go | 3 ++ 7 files changed, 105 insertions(+), 60 deletions(-) create mode 100644 pkg/router/media.go create mode 100644 pkg/service/cast/media.go diff --git a/api/cast/cast.pb.go b/api/cast/cast.pb.go index 16d23c9..5bd308e 100644 --- a/api/cast/cast.pb.go +++ b/api/cast/cast.pb.go @@ -23,29 +23,29 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type UpdateCastReq struct { +type UpdateMediaAccountReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SignImgFileData string `protobuf:"bytes,1,opt,name=signImgFileData,proto3" json:"signImgFileData,omitempty"` - UserID string `protobuf:"bytes,2,opt,name=userID,proto3" json:"userID,omitempty"` + Phone string `protobuf:"bytes,1,opt,name=phone,proto3" json:"phone,omitempty"` + BindUserID string `protobuf:"bytes,2,opt,name=bindUserID,proto3" json:"bindUserID,omitempty"` } -func (x *UpdateCastReq) Reset() { - *x = UpdateCastReq{} +func (x *UpdateMediaAccountReq) Reset() { + *x = UpdateMediaAccountReq{} mi := &file_pb_fiee_cast_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *UpdateCastReq) String() string { +func (x *UpdateMediaAccountReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateCastReq) ProtoMessage() {} +func (*UpdateMediaAccountReq) ProtoMessage() {} -func (x *UpdateCastReq) ProtoReflect() protoreflect.Message { +func (x *UpdateMediaAccountReq) ProtoReflect() protoreflect.Message { mi := &file_pb_fiee_cast_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -57,47 +57,47 @@ func (x *UpdateCastReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateCastReq.ProtoReflect.Descriptor instead. -func (*UpdateCastReq) Descriptor() ([]byte, []int) { +// Deprecated: Use UpdateMediaAccountReq.ProtoReflect.Descriptor instead. +func (*UpdateMediaAccountReq) Descriptor() ([]byte, []int) { return file_pb_fiee_cast_proto_rawDescGZIP(), []int{0} } -func (x *UpdateCastReq) GetSignImgFileData() string { +func (x *UpdateMediaAccountReq) GetPhone() string { if x != nil { - return x.SignImgFileData + return x.Phone } return "" } -func (x *UpdateCastReq) GetUserID() string { +func (x *UpdateMediaAccountReq) GetBindUserID() string { if x != nil { - return x.UserID + return x.BindUserID } return "" } -type UpdateCastResp struct { +type UpdateMediaAccountResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SignImgFileData string `protobuf:"bytes,1,opt,name=signImgFileData,proto3" json:"signImgFileData,omitempty"` + AccountUuid string `protobuf:"bytes,1,opt,name=accountUuid,proto3" json:"accountUuid,omitempty"` } -func (x *UpdateCastResp) Reset() { - *x = UpdateCastResp{} +func (x *UpdateMediaAccountResp) Reset() { + *x = UpdateMediaAccountResp{} mi := &file_pb_fiee_cast_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *UpdateCastResp) String() string { +func (x *UpdateMediaAccountResp) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateCastResp) ProtoMessage() {} +func (*UpdateMediaAccountResp) ProtoMessage() {} -func (x *UpdateCastResp) ProtoReflect() protoreflect.Message { +func (x *UpdateMediaAccountResp) ProtoReflect() protoreflect.Message { mi := &file_pb_fiee_cast_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -109,14 +109,14 @@ func (x *UpdateCastResp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateCastResp.ProtoReflect.Descriptor instead. -func (*UpdateCastResp) Descriptor() ([]byte, []int) { +// Deprecated: Use UpdateMediaAccountResp.ProtoReflect.Descriptor instead. +func (*UpdateMediaAccountResp) Descriptor() ([]byte, []int) { return file_pb_fiee_cast_proto_rawDescGZIP(), []int{1} } -func (x *UpdateCastResp) GetSignImgFileData() string { +func (x *UpdateMediaAccountResp) GetAccountUuid() string { if x != nil { - return x.SignImgFileData + return x.AccountUuid } return "" } @@ -131,22 +131,23 @@ var file_pb_fiee_cast_proto_rawDesc = []byte{ 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, - 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x0d, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x43, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x69, - 0x67, 0x6e, 0x49, 0x6d, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x69, 0x67, 0x6e, 0x49, 0x6d, 0x67, 0x46, 0x69, 0x6c, 0x65, - 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0x3a, 0x0a, 0x0e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x28, - 0x0a, 0x0f, 0x73, 0x69, 0x67, 0x6e, 0x49, 0x6d, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x69, 0x67, 0x6e, 0x49, 0x6d, 0x67, - 0x46, 0x69, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, 0x32, 0x41, 0x0a, 0x04, 0x43, 0x61, 0x73, 0x74, - 0x12, 0x39, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x73, 0x74, 0x12, 0x13, - 0x2e, 0x43, 0x61, 0x73, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x73, 0x74, - 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x43, 0x61, 0x73, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x43, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, - 0x2f, 0x63, 0x61, 0x73, 0x74, 0x3b, 0x63, 0x61, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4d, 0x0a, 0x15, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x69, 0x6e, 0x64, + 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x69, + 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0x3a, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x75, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x55, 0x75, 0x69, 0x64, 0x32, 0x59, 0x0a, 0x04, 0x43, 0x61, 0x73, 0x74, 0x12, 0x51, 0x0a, 0x12, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x43, 0x61, 0x73, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x4d, 0x65, 0x64, 0x69, 0x61, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, + 0x1c, 0x2e, 0x43, 0x61, 0x73, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x64, + 0x69, 0x61, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, + 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x63, 0x61, 0x73, 0x74, 0x3b, 0x63, 0x61, 0x73, 0x74, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -163,12 +164,12 @@ func file_pb_fiee_cast_proto_rawDescGZIP() []byte { var file_pb_fiee_cast_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_pb_fiee_cast_proto_goTypes = []any{ - (*UpdateCastReq)(nil), // 0: Cast.UpdateCastReq - (*UpdateCastResp)(nil), // 1: Cast.UpdateCastResp + (*UpdateMediaAccountReq)(nil), // 0: Cast.UpdateMediaAccountReq + (*UpdateMediaAccountResp)(nil), // 1: Cast.UpdateMediaAccountResp } var file_pb_fiee_cast_proto_depIdxs = []int32{ - 0, // 0: Cast.Cast.UpdateCast:input_type -> Cast.UpdateCastReq - 1, // 1: Cast.Cast.UpdateCast:output_type -> Cast.UpdateCastResp + 0, // 0: Cast.Cast.UpdateMediaAccount:input_type -> Cast.UpdateMediaAccountReq + 1, // 1: Cast.Cast.UpdateMediaAccount:output_type -> Cast.UpdateMediaAccountResp 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/api/cast/cast.validator.pb.go b/api/cast/cast.validator.pb.go index e431f2a..9ebe376 100644 --- a/api/cast/cast.validator.pb.go +++ b/api/cast/cast.validator.pb.go @@ -17,9 +17,9 @@ var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf -func (this *UpdateCastReq) Validate() error { +func (this *UpdateMediaAccountReq) Validate() error { return nil } -func (this *UpdateCastResp) Validate() error { +func (this *UpdateMediaAccountResp) Validate() error { return nil } diff --git a/api/cast/cast_triple.pb.go b/api/cast/cast_triple.pb.go index 7b0d2cf..280bf50 100644 --- a/api/cast/cast_triple.pb.go +++ b/api/cast/cast_triple.pb.go @@ -28,7 +28,7 @@ const _ = grpc_go.SupportPackageIsVersion7 // // 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 CastClient interface { - UpdateCast(ctx context.Context, in *UpdateCastReq, opts ...grpc_go.CallOption) (*UpdateCastResp, common.ErrorWithAttachment) + UpdateMediaAccount(ctx context.Context, in *UpdateMediaAccountReq, opts ...grpc_go.CallOption) (*UpdateMediaAccountResp, common.ErrorWithAttachment) } type castClient struct { @@ -36,7 +36,7 @@ type castClient struct { } type CastClientImpl struct { - UpdateCast func(ctx context.Context, in *UpdateCastReq) (*UpdateCastResp, error) + UpdateMediaAccount func(ctx context.Context, in *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error) } func (c *CastClientImpl) GetDubboStub(cc *triple.TripleConn) CastClient { @@ -51,17 +51,17 @@ func NewCastClient(cc *triple.TripleConn) CastClient { return &castClient{cc} } -func (c *castClient) UpdateCast(ctx context.Context, in *UpdateCastReq, opts ...grpc_go.CallOption) (*UpdateCastResp, common.ErrorWithAttachment) { - out := new(UpdateCastResp) +func (c *castClient) UpdateMediaAccount(ctx context.Context, in *UpdateMediaAccountReq, opts ...grpc_go.CallOption) (*UpdateMediaAccountResp, common.ErrorWithAttachment) { + out := new(UpdateMediaAccountResp) interfaceKey := ctx.Value(constant.InterfaceKey).(string) - return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateCast", in, out) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateMediaAccount", in, out) } // CastServer is the server API for Cast service. // All implementations must embed UnimplementedCastServer // for forward compatibility type CastServer interface { - UpdateCast(context.Context, *UpdateCastReq) (*UpdateCastResp, error) + UpdateMediaAccount(context.Context, *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error) mustEmbedUnimplementedCastServer() } @@ -70,8 +70,8 @@ type UnimplementedCastServer struct { proxyImpl protocol.Invoker } -func (UnimplementedCastServer) UpdateCast(context.Context, *UpdateCastReq) (*UpdateCastResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateCast not implemented") +func (UnimplementedCastServer) UpdateMediaAccount(context.Context, *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateMediaAccount not implemented") } func (s *UnimplementedCastServer) XXX_SetProxyImpl(impl protocol.Invoker) { s.proxyImpl = impl @@ -101,8 +101,8 @@ func RegisterCastServer(s grpc_go.ServiceRegistrar, srv CastServer) { s.RegisterService(&Cast_ServiceDesc, srv) } -func _Cast_UpdateCast_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateCastReq) +func _Cast_UpdateMediaAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateMediaAccountReq) if err := dec(in); err != nil { return nil, err } @@ -114,7 +114,7 @@ func _Cast_UpdateCast_Handler(srv interface{}, ctx context.Context, dec func(int for k, v := range md { invAttachment[k] = v } - invo := invocation.NewRPCInvocation("UpdateCast", args, invAttachment) + invo := invocation.NewRPCInvocation("UpdateMediaAccount", args, invAttachment) if interceptor == nil { result := base.XXX_GetProxyImpl().Invoke(ctx, invo) return result, result.Error() @@ -138,8 +138,8 @@ var Cast_ServiceDesc = grpc_go.ServiceDesc{ HandlerType: (*CastServer)(nil), Methods: []grpc_go.MethodDesc{ { - MethodName: "UpdateCast", - Handler: _Cast_UpdateCast_Handler, + MethodName: "UpdateMediaAccount", + Handler: _Cast_UpdateMediaAccount_Handler, }, }, Streams: []grpc_go.StreamDesc{}, diff --git a/pkg/router/media.go b/pkg/router/media.go new file mode 100644 index 0000000..8c8215b --- /dev/null +++ b/pkg/router/media.go @@ -0,0 +1,18 @@ +package router + +import ( + "fonchain-fiee/pkg/middleware" + "fonchain-fiee/pkg/service" + serviceCast "fonchain-fiee/pkg/service/cast" + "github.com/gin-gonic/gin" +) + +func MediaRouter(r *gin.RouterGroup) { + //noAuth := r.Group("") + auth := r.Group("") + auth.Use(middleware.CheckLogin(service.AccountProvider)) + media := auth.Group("media") + { + media.POST("update-account", serviceCast.UpdateMediaAccount) + } +} diff --git a/pkg/router/router.go b/pkg/router/router.go index 0e53fcb..da4d287 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -41,6 +41,7 @@ func NewRouter() *gin.Engine { BundleRouter(privateGroup) BundleOrderRouter(privateGroup) ValueAddBundleRouter(privateGroup) + MediaRouter(privateGroup) { v1.POST("version", version.Version) //版本号公共 diff --git a/pkg/service/cast/media.go b/pkg/service/cast/media.go new file mode 100644 index 0000000..648a3de --- /dev/null +++ b/pkg/service/cast/media.go @@ -0,0 +1,22 @@ +package cast + +import ( + "fonchain-fiee/api/cast" + "fonchain-fiee/pkg/service" + "github.com/gin-gonic/gin" +) + +func UpdateMediaAccount(ctx *gin.Context) { + var req *cast.UpdateMediaAccountReq + if err := ctx.ShouldBind(&req); err != nil { + service.Error(ctx, err) + return + } + resp, err := service.CastProvider.UpdateMediaAccount(ctx, req) + if err != nil { + service.Error(ctx, err) + return + } + service.Success(ctx, resp) + return +} diff --git a/pkg/service/init.go b/pkg/service/init.go index 0f80220..db31cfe 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -7,6 +7,7 @@ import ( "fmt" "fonchain-fiee/api/account" "fonchain-fiee/api/bundle" + "fonchain-fiee/api/cast" "fonchain-fiee/api/order" "fonchain-fiee/api/payment" pkConfig "fonchain-fiee/pkg/config" @@ -18,12 +19,14 @@ var AccountProvider = new(account.AccountClientImpl) var BundleProvider = new(bundle.BundleClientImpl) var OrderProvider = new(order.OrderClientImpl) var PaymentProvider = new(payment.PaymentCentClientImpl) +var CastProvider = new(cast.CastClientImpl) func init() { config.SetConsumerService(BundleProvider) config.SetConsumerService(OrderProvider) config.SetConsumerService(AccountProvider) config.SetConsumerService(PaymentProvider) + config.SetConsumerService(CastProvider) if err := config.Load(); err != nil { panic(err)