feat 协议

This commit is contained in:
2026-01-12 20:32:58 +08:00
parent d502d615fe
commit b678307d61
3 changed files with 255 additions and 30 deletions

View File

@@ -28,6 +28,8 @@ type QgdzsClient interface {
GetQuestion(ctx context.Context, in *GetQuestionReq, opts ...grpc.CallOption) (*GetQuestionResp, error)
// 回答题目
AnswerQuestion(ctx context.Context, in *AnswerQuestionReq, opts ...grpc.CallOption) (*AnswerQuestionResp, error)
// 获取所有类目
GetAllCategory(ctx context.Context, in *GetAllCategoryReq, opts ...grpc.CallOption) (*GetAllCategoryResp, error)
}
type qgdzsClient struct {
@@ -65,6 +67,15 @@ func (c *qgdzsClient) AnswerQuestion(ctx context.Context, in *AnswerQuestionReq,
return out, nil
}
func (c *qgdzsClient) GetAllCategory(ctx context.Context, in *GetAllCategoryReq, opts ...grpc.CallOption) (*GetAllCategoryResp, error) {
out := new(GetAllCategoryResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetAllCategory", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// QgdzsServer is the server API for Qgdzs service.
// All implementations must embed UnimplementedQgdzsServer
// for forward compatibility
@@ -75,6 +86,8 @@ type QgdzsServer interface {
GetQuestion(context.Context, *GetQuestionReq) (*GetQuestionResp, error)
// 回答题目
AnswerQuestion(context.Context, *AnswerQuestionReq) (*AnswerQuestionResp, error)
// 获取所有类目
GetAllCategory(context.Context, *GetAllCategoryReq) (*GetAllCategoryResp, error)
mustEmbedUnimplementedQgdzsServer()
}
@@ -91,6 +104,9 @@ func (UnimplementedQgdzsServer) GetQuestion(context.Context, *GetQuestionReq) (*
func (UnimplementedQgdzsServer) AnswerQuestion(context.Context, *AnswerQuestionReq) (*AnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method AnswerQuestion not implemented")
}
func (UnimplementedQgdzsServer) GetAllCategory(context.Context, *GetAllCategoryReq) (*GetAllCategoryResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAllCategory not implemented")
}
func (UnimplementedQgdzsServer) mustEmbedUnimplementedQgdzsServer() {}
// UnsafeQgdzsServer may be embedded to opt out of forward compatibility for this service.
@@ -158,6 +174,24 @@ func _Qgdzs_AnswerQuestion_Handler(srv interface{}, ctx context.Context, dec fun
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetAllCategory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetAllCategoryReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetAllCategory(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetAllCategory",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetAllCategory(ctx, req.(*GetAllCategoryReq))
}
return interceptor(ctx, in, info, handler)
}
// Qgdzs_ServiceDesc is the grpc.ServiceDesc for Qgdzs service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -177,6 +211,10 @@ var Qgdzs_ServiceDesc = grpc.ServiceDesc{
MethodName: "AnswerQuestion",
Handler: _Qgdzs_AnswerQuestion_Handler,
},
{
MethodName: "GetAllCategory",
Handler: _Qgdzs_GetAllCategory_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_qgdzs.proto",