refactor: localize protobuf definitions
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
package mall
|
||||
|
||||
import (
|
||||
protobuf "bsm/full/protobuf"
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
@@ -36,13 +35,13 @@ type AdsClient interface {
|
||||
// 通过广告位获取广告信息
|
||||
ByPos(ctx context.Context, in *ByPosRequest, opts ...grpc.CallOption) (*AdsListReply, error)
|
||||
// 广告列表
|
||||
Fetch(ctx context.Context, in *protobuf.MallFetchRequest, opts ...grpc.CallOption) (*AdsListReply, error)
|
||||
Fetch(ctx context.Context, in *MallFetchRequest, opts ...grpc.CallOption) (*AdsListReply, error)
|
||||
// 新建广告
|
||||
Create(ctx context.Context, in *AdsItem, opts ...grpc.CallOption) (*protobuf.IdentityStatusReply, error)
|
||||
Create(ctx context.Context, in *AdsItem, opts ...grpc.CallOption) (*IdentityStatusReply, error)
|
||||
// 修改广告
|
||||
Modify(ctx context.Context, in *AdsItem, opts ...grpc.CallOption) (*protobuf.IdentityStatusReply, error)
|
||||
Modify(ctx context.Context, in *AdsItem, opts ...grpc.CallOption) (*IdentityStatusReply, error)
|
||||
// 删除广告
|
||||
Delete(ctx context.Context, in *protobuf.IdentRequest, opts ...grpc.CallOption) (*protobuf.IdentityStatusReply, error)
|
||||
Delete(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*IdentityStatusReply, error)
|
||||
}
|
||||
|
||||
type adsClient struct {
|
||||
@@ -63,7 +62,7 @@ func (c *adsClient) ByPos(ctx context.Context, in *ByPosRequest, opts ...grpc.Ca
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *adsClient) Fetch(ctx context.Context, in *protobuf.MallFetchRequest, opts ...grpc.CallOption) (*AdsListReply, error) {
|
||||
func (c *adsClient) Fetch(ctx context.Context, in *MallFetchRequest, opts ...grpc.CallOption) (*AdsListReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AdsListReply)
|
||||
err := c.cc.Invoke(ctx, Ads_Fetch_FullMethodName, in, out, cOpts...)
|
||||
@@ -73,9 +72,9 @@ func (c *adsClient) Fetch(ctx context.Context, in *protobuf.MallFetchRequest, op
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *adsClient) Create(ctx context.Context, in *AdsItem, opts ...grpc.CallOption) (*protobuf.IdentityStatusReply, error) {
|
||||
func (c *adsClient) Create(ctx context.Context, in *AdsItem, opts ...grpc.CallOption) (*IdentityStatusReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(protobuf.IdentityStatusReply)
|
||||
out := new(IdentityStatusReply)
|
||||
err := c.cc.Invoke(ctx, Ads_Create_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -83,9 +82,9 @@ func (c *adsClient) Create(ctx context.Context, in *AdsItem, opts ...grpc.CallOp
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *adsClient) Modify(ctx context.Context, in *AdsItem, opts ...grpc.CallOption) (*protobuf.IdentityStatusReply, error) {
|
||||
func (c *adsClient) Modify(ctx context.Context, in *AdsItem, opts ...grpc.CallOption) (*IdentityStatusReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(protobuf.IdentityStatusReply)
|
||||
out := new(IdentityStatusReply)
|
||||
err := c.cc.Invoke(ctx, Ads_Modify_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -93,9 +92,9 @@ func (c *adsClient) Modify(ctx context.Context, in *AdsItem, opts ...grpc.CallOp
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *adsClient) Delete(ctx context.Context, in *protobuf.IdentRequest, opts ...grpc.CallOption) (*protobuf.IdentityStatusReply, error) {
|
||||
func (c *adsClient) Delete(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*IdentityStatusReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(protobuf.IdentityStatusReply)
|
||||
out := new(IdentityStatusReply)
|
||||
err := c.cc.Invoke(ctx, Ads_Delete_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -112,13 +111,13 @@ type AdsServer interface {
|
||||
// 通过广告位获取广告信息
|
||||
ByPos(context.Context, *ByPosRequest) (*AdsListReply, error)
|
||||
// 广告列表
|
||||
Fetch(context.Context, *protobuf.MallFetchRequest) (*AdsListReply, error)
|
||||
Fetch(context.Context, *MallFetchRequest) (*AdsListReply, error)
|
||||
// 新建广告
|
||||
Create(context.Context, *AdsItem) (*protobuf.IdentityStatusReply, error)
|
||||
Create(context.Context, *AdsItem) (*IdentityStatusReply, error)
|
||||
// 修改广告
|
||||
Modify(context.Context, *AdsItem) (*protobuf.IdentityStatusReply, error)
|
||||
Modify(context.Context, *AdsItem) (*IdentityStatusReply, error)
|
||||
// 删除广告
|
||||
Delete(context.Context, *protobuf.IdentRequest) (*protobuf.IdentityStatusReply, error)
|
||||
Delete(context.Context, *IdentRequest) (*IdentityStatusReply, error)
|
||||
}
|
||||
|
||||
// UnimplementedAdsServer should be embedded to have
|
||||
@@ -131,16 +130,16 @@ type UnimplementedAdsServer struct{}
|
||||
func (UnimplementedAdsServer) ByPos(context.Context, *ByPosRequest) (*AdsListReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ByPos not implemented")
|
||||
}
|
||||
func (UnimplementedAdsServer) Fetch(context.Context, *protobuf.MallFetchRequest) (*AdsListReply, error) {
|
||||
func (UnimplementedAdsServer) Fetch(context.Context, *MallFetchRequest) (*AdsListReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Fetch not implemented")
|
||||
}
|
||||
func (UnimplementedAdsServer) Create(context.Context, *AdsItem) (*protobuf.IdentityStatusReply, error) {
|
||||
func (UnimplementedAdsServer) Create(context.Context, *AdsItem) (*IdentityStatusReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Create not implemented")
|
||||
}
|
||||
func (UnimplementedAdsServer) Modify(context.Context, *AdsItem) (*protobuf.IdentityStatusReply, error) {
|
||||
func (UnimplementedAdsServer) Modify(context.Context, *AdsItem) (*IdentityStatusReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Modify not implemented")
|
||||
}
|
||||
func (UnimplementedAdsServer) Delete(context.Context, *protobuf.IdentRequest) (*protobuf.IdentityStatusReply, error) {
|
||||
func (UnimplementedAdsServer) Delete(context.Context, *IdentRequest) (*IdentityStatusReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Delete not implemented")
|
||||
}
|
||||
func (UnimplementedAdsServer) testEmbeddedByValue() {}
|
||||
@@ -182,7 +181,7 @@ func _Ads_ByPos_Handler(srv interface{}, ctx context.Context, dec func(interface
|
||||
}
|
||||
|
||||
func _Ads_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(protobuf.MallFetchRequest)
|
||||
in := new(MallFetchRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -194,7 +193,7 @@ func _Ads_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interface
|
||||
FullMethod: Ads_Fetch_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AdsServer).Fetch(ctx, req.(*protobuf.MallFetchRequest))
|
||||
return srv.(AdsServer).Fetch(ctx, req.(*MallFetchRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@@ -236,7 +235,7 @@ func _Ads_Modify_Handler(srv interface{}, ctx context.Context, dec func(interfac
|
||||
}
|
||||
|
||||
func _Ads_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(protobuf.IdentRequest)
|
||||
in := new(IdentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -248,7 +247,7 @@ func _Ads_Delete_Handler(srv interface{}, ctx context.Context, dec func(interfac
|
||||
FullMethod: Ads_Delete_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AdsServer).Delete(ctx, req.(*protobuf.IdentRequest))
|
||||
return srv.(AdsServer).Delete(ctx, req.(*IdentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user