refactor: localize protobuf definitions
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
package cms
|
||||
|
||||
import (
|
||||
protobuf "bsm/full/protobuf"
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
@@ -34,15 +33,15 @@ const (
|
||||
// CMS - 站点
|
||||
type SiteClient interface {
|
||||
// 站点列表
|
||||
Fetch(ctx context.Context, in *protobuf.Empty, opts ...grpc.CallOption) (*SiteListReply, error)
|
||||
Fetch(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*SiteListReply, error)
|
||||
// 站点详情
|
||||
Get(ctx context.Context, in *protobuf.IdentRequest, opts ...grpc.CallOption) (*SiteItem, error)
|
||||
Get(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*SiteItem, error)
|
||||
// 添加站点
|
||||
Create(ctx context.Context, in *SiteItem, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
|
||||
Create(ctx context.Context, in *SiteItem, opts ...grpc.CallOption) (*StatusReply, error)
|
||||
// 修改站点
|
||||
Modify(ctx context.Context, in *SiteItem, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
|
||||
Modify(ctx context.Context, in *SiteItem, opts ...grpc.CallOption) (*StatusReply, error)
|
||||
// 删除站点
|
||||
Delete(ctx context.Context, in *protobuf.IdentRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
|
||||
Delete(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error)
|
||||
}
|
||||
|
||||
type siteClient struct {
|
||||
@@ -53,7 +52,7 @@ func NewSiteClient(cc grpc.ClientConnInterface) SiteClient {
|
||||
return &siteClient{cc}
|
||||
}
|
||||
|
||||
func (c *siteClient) Fetch(ctx context.Context, in *protobuf.Empty, opts ...grpc.CallOption) (*SiteListReply, error) {
|
||||
func (c *siteClient) Fetch(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*SiteListReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SiteListReply)
|
||||
err := c.cc.Invoke(ctx, Site_Fetch_FullMethodName, in, out, cOpts...)
|
||||
@@ -63,7 +62,7 @@ func (c *siteClient) Fetch(ctx context.Context, in *protobuf.Empty, opts ...grpc
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *siteClient) Get(ctx context.Context, in *protobuf.IdentRequest, opts ...grpc.CallOption) (*SiteItem, error) {
|
||||
func (c *siteClient) Get(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*SiteItem, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SiteItem)
|
||||
err := c.cc.Invoke(ctx, Site_Get_FullMethodName, in, out, cOpts...)
|
||||
@@ -73,9 +72,9 @@ func (c *siteClient) Get(ctx context.Context, in *protobuf.IdentRequest, opts ..
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *siteClient) Create(ctx context.Context, in *SiteItem, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
|
||||
func (c *siteClient) Create(ctx context.Context, in *SiteItem, opts ...grpc.CallOption) (*StatusReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(protobuf.StatusReply)
|
||||
out := new(StatusReply)
|
||||
err := c.cc.Invoke(ctx, Site_Create_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -83,9 +82,9 @@ func (c *siteClient) Create(ctx context.Context, in *SiteItem, opts ...grpc.Call
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *siteClient) Modify(ctx context.Context, in *SiteItem, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
|
||||
func (c *siteClient) Modify(ctx context.Context, in *SiteItem, opts ...grpc.CallOption) (*StatusReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(protobuf.StatusReply)
|
||||
out := new(StatusReply)
|
||||
err := c.cc.Invoke(ctx, Site_Modify_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -93,9 +92,9 @@ func (c *siteClient) Modify(ctx context.Context, in *SiteItem, opts ...grpc.Call
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *siteClient) Delete(ctx context.Context, in *protobuf.IdentRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
|
||||
func (c *siteClient) Delete(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(protobuf.StatusReply)
|
||||
out := new(StatusReply)
|
||||
err := c.cc.Invoke(ctx, Site_Delete_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -110,15 +109,15 @@ func (c *siteClient) Delete(ctx context.Context, in *protobuf.IdentRequest, opts
|
||||
// CMS - 站点
|
||||
type SiteServer interface {
|
||||
// 站点列表
|
||||
Fetch(context.Context, *protobuf.Empty) (*SiteListReply, error)
|
||||
Fetch(context.Context, *Empty) (*SiteListReply, error)
|
||||
// 站点详情
|
||||
Get(context.Context, *protobuf.IdentRequest) (*SiteItem, error)
|
||||
Get(context.Context, *IdentRequest) (*SiteItem, error)
|
||||
// 添加站点
|
||||
Create(context.Context, *SiteItem) (*protobuf.StatusReply, error)
|
||||
Create(context.Context, *SiteItem) (*StatusReply, error)
|
||||
// 修改站点
|
||||
Modify(context.Context, *SiteItem) (*protobuf.StatusReply, error)
|
||||
Modify(context.Context, *SiteItem) (*StatusReply, error)
|
||||
// 删除站点
|
||||
Delete(context.Context, *protobuf.IdentRequest) (*protobuf.StatusReply, error)
|
||||
Delete(context.Context, *IdentRequest) (*StatusReply, error)
|
||||
}
|
||||
|
||||
// UnimplementedSiteServer should be embedded to have
|
||||
@@ -128,19 +127,19 @@ type SiteServer interface {
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedSiteServer struct{}
|
||||
|
||||
func (UnimplementedSiteServer) Fetch(context.Context, *protobuf.Empty) (*SiteListReply, error) {
|
||||
func (UnimplementedSiteServer) Fetch(context.Context, *Empty) (*SiteListReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Fetch not implemented")
|
||||
}
|
||||
func (UnimplementedSiteServer) Get(context.Context, *protobuf.IdentRequest) (*SiteItem, error) {
|
||||
func (UnimplementedSiteServer) Get(context.Context, *IdentRequest) (*SiteItem, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Get not implemented")
|
||||
}
|
||||
func (UnimplementedSiteServer) Create(context.Context, *SiteItem) (*protobuf.StatusReply, error) {
|
||||
func (UnimplementedSiteServer) Create(context.Context, *SiteItem) (*StatusReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Create not implemented")
|
||||
}
|
||||
func (UnimplementedSiteServer) Modify(context.Context, *SiteItem) (*protobuf.StatusReply, error) {
|
||||
func (UnimplementedSiteServer) Modify(context.Context, *SiteItem) (*StatusReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Modify not implemented")
|
||||
}
|
||||
func (UnimplementedSiteServer) Delete(context.Context, *protobuf.IdentRequest) (*protobuf.StatusReply, error) {
|
||||
func (UnimplementedSiteServer) Delete(context.Context, *IdentRequest) (*StatusReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Delete not implemented")
|
||||
}
|
||||
func (UnimplementedSiteServer) testEmbeddedByValue() {}
|
||||
@@ -164,7 +163,7 @@ func RegisterSiteServer(s grpc.ServiceRegistrar, srv SiteServer) {
|
||||
}
|
||||
|
||||
func _Site_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(protobuf.Empty)
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -176,13 +175,13 @@ func _Site_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interfac
|
||||
FullMethod: Site_Fetch_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SiteServer).Fetch(ctx, req.(*protobuf.Empty))
|
||||
return srv.(SiteServer).Fetch(ctx, req.(*Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Site_Get_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
|
||||
}
|
||||
@@ -194,7 +193,7 @@ func _Site_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{
|
||||
FullMethod: Site_Get_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SiteServer).Get(ctx, req.(*protobuf.IdentRequest))
|
||||
return srv.(SiteServer).Get(ctx, req.(*IdentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@@ -236,7 +235,7 @@ func _Site_Modify_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
}
|
||||
|
||||
func _Site_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 _Site_Delete_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
FullMethod: Site_Delete_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SiteServer).Delete(ctx, req.(*protobuf.IdentRequest))
|
||||
return srv.(SiteServer).Delete(ctx, req.(*IdentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user