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

@@ -345,6 +345,92 @@ func (x *AnswerQuestionResp) GetExplanation() string {
return "" return ""
} }
// ---------- GetAllCategory ----------
type GetAllCategoryReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GetAllCategoryReq) Reset() {
*x = GetAllCategoryReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_qgdzs_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAllCategoryReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAllCategoryReq) ProtoMessage() {}
func (x *GetAllCategoryReq) ProtoReflect() protoreflect.Message {
mi := &file_service_qgdzs_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 GetAllCategoryReq.ProtoReflect.Descriptor instead.
func (*GetAllCategoryReq) Descriptor() ([]byte, []int) {
return file_service_qgdzs_proto_rawDescGZIP(), []int{6}
}
type GetAllCategoryResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Categories []string `protobuf:"bytes,1,rep,name=Categories,json=categories,proto3" json:"Categories,omitempty"` // 类目
}
func (x *GetAllCategoryResp) Reset() {
*x = GetAllCategoryResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_qgdzs_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAllCategoryResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAllCategoryResp) ProtoMessage() {}
func (x *GetAllCategoryResp) ProtoReflect() protoreflect.Message {
mi := &file_service_qgdzs_proto_msgTypes[7]
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 GetAllCategoryResp.ProtoReflect.Descriptor instead.
func (*GetAllCategoryResp) Descriptor() ([]byte, []int) {
return file_service_qgdzs_proto_rawDescGZIP(), []int{7}
}
func (x *GetAllCategoryResp) GetCategories() []string {
if x != nil {
return x.Categories
}
return nil
}
var File_service_qgdzs_proto protoreflect.FileDescriptor var File_service_qgdzs_proto protoreflect.FileDescriptor
var file_service_qgdzs_proto_rawDesc = []byte{ var file_service_qgdzs_proto_rawDesc = []byte{
@@ -377,29 +463,39 @@ var file_service_qgdzs_proto_rawDesc = []byte{
0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6e, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6e,
0x73, 0x77, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x45, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61, 0x74, 0x73, 0x77, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x45, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x70, 0x6c, 0x61, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x70, 0x6c, 0x61,
0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x9d, 0x02, 0x0a, 0x05, 0x51, 0x67, 0x64, 0x7a, 0x73, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x13, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c,
0x12, 0x64, 0x0a, 0x10, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x73, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x22, 0x34, 0x0a, 0x12, 0x47,
0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73,
0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x47, 0x65, 0x6e, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18,
0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65,
0x70, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x3a, 0x01, 0x2a, 0x22, 0x18, 0x2f, 0x71, 0x73, 0x32, 0xfc, 0x02, 0x0a, 0x05, 0x51, 0x67, 0x64, 0x7a, 0x73, 0x12, 0x64, 0x0a, 0x10, 0x47,
0x67, 0x64, 0x7a, 0x73, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x71, 0x75, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12,
0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x50, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x14, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69,
0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x73, 0x74, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x73, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x23, 0x82, 0xd3,
0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0xe4, 0x93, 0x02, 0x1d, 0x3a, 0x01, 0x2a, 0x22, 0x18, 0x2f, 0x71, 0x67, 0x64, 0x7a, 0x73, 0x2f,
0x3a, 0x01, 0x2a, 0x22, 0x13, 0x2f, 0x71, 0x67, 0x64, 0x7a, 0x73, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f,
0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5c, 0x0a, 0x0e, 0x41, 0x6e, 0x73, 0x77, 0x6e, 0x12, 0x50, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e,
0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x2e, 0x41, 0x6e, 0x73, 0x12, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
0x77, 0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x71, 0x1a, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x2e, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x3a, 0x01, 0x2a, 0x22, 0x13,
0x65, 0x73, 0x70, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x3a, 0x01, 0x2a, 0x22, 0x16, 0x2f, 0x71, 0x67, 0x64, 0x7a, 0x73, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x71, 0x75, 0x65, 0x73, 0x74,
0x2f, 0x71, 0x67, 0x64, 0x7a, 0x73, 0x2f, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x5f, 0x71, 0x75, 0x69, 0x6f, 0x6e, 0x12, 0x5c, 0x0a, 0x0e, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x51, 0x75, 0x65,
0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x2e, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x51, 0x75,
0x73, 0x71, 0x2e, 0x61, 0x73, 0x69, 0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x41, 0x6e, 0x73, 0x77,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x21,
0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x3a, 0x01, 0x2a, 0x22, 0x16, 0x2f, 0x71, 0x67, 0x64, 0x7a,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x73, 0x2f, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x5f, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f,
0x6e, 0x12, 0x5d, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x43, 0x61, 0x74, 0x65, 0x67,
0x6f, 0x72, 0x79, 0x12, 0x12, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x43, 0x61, 0x74, 0x65,
0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c,
0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x22, 0x82, 0xd3,
0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x01, 0x2a, 0x22, 0x17, 0x2f, 0x71, 0x67, 0x64, 0x7a, 0x73, 0x2f,
0x67, 0x65, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73, 0x71, 0x2e, 0x61, 0x73, 0x69,
0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x73,
0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -414,7 +510,7 @@ func file_service_qgdzs_proto_rawDescGZIP() []byte {
return file_service_qgdzs_proto_rawDescData return file_service_qgdzs_proto_rawDescData
} }
var file_service_qgdzs_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_service_qgdzs_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_service_qgdzs_proto_goTypes = []interface{}{ var file_service_qgdzs_proto_goTypes = []interface{}{
(*GenerateQuestionReq)(nil), // 0: GenerateQuestionReq (*GenerateQuestionReq)(nil), // 0: GenerateQuestionReq
(*GenerateQuestionResp)(nil), // 1: GenerateQuestionResp (*GenerateQuestionResp)(nil), // 1: GenerateQuestionResp
@@ -422,16 +518,20 @@ var file_service_qgdzs_proto_goTypes = []interface{}{
(*GetQuestionResp)(nil), // 3: GetQuestionResp (*GetQuestionResp)(nil), // 3: GetQuestionResp
(*AnswerQuestionReq)(nil), // 4: AnswerQuestionReq (*AnswerQuestionReq)(nil), // 4: AnswerQuestionReq
(*AnswerQuestionResp)(nil), // 5: AnswerQuestionResp (*AnswerQuestionResp)(nil), // 5: AnswerQuestionResp
(*GetAllCategoryReq)(nil), // 6: GetAllCategoryReq
(*GetAllCategoryResp)(nil), // 7: GetAllCategoryResp
} }
var file_service_qgdzs_proto_depIdxs = []int32{ var file_service_qgdzs_proto_depIdxs = []int32{
0, // 0: Qgdzs.GenerateQuestion:input_type -> GenerateQuestionReq 0, // 0: Qgdzs.GenerateQuestion:input_type -> GenerateQuestionReq
2, // 1: Qgdzs.GetQuestion:input_type -> GetQuestionReq 2, // 1: Qgdzs.GetQuestion:input_type -> GetQuestionReq
4, // 2: Qgdzs.AnswerQuestion:input_type -> AnswerQuestionReq 4, // 2: Qgdzs.AnswerQuestion:input_type -> AnswerQuestionReq
1, // 3: Qgdzs.GenerateQuestion:output_type -> GenerateQuestionResp 6, // 3: Qgdzs.GetAllCategory:input_type -> GetAllCategoryReq
3, // 4: Qgdzs.GetQuestion:output_type -> GetQuestionResp 1, // 4: Qgdzs.GenerateQuestion:output_type -> GenerateQuestionResp
5, // 5: Qgdzs.AnswerQuestion:output_type -> AnswerQuestionResp 3, // 5: Qgdzs.GetQuestion:output_type -> GetQuestionResp
3, // [3:6] is the sub-list for method output_type 5, // 6: Qgdzs.AnswerQuestion:output_type -> AnswerQuestionResp
0, // [0:3] is the sub-list for method input_type 7, // 7: Qgdzs.GetAllCategory:output_type -> GetAllCategoryResp
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 type_name
0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name 0, // [0:0] is the sub-list for field type_name
@@ -515,6 +615,30 @@ func file_service_qgdzs_proto_init() {
return nil return nil
} }
} }
file_service_qgdzs_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAllCategoryReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_qgdzs_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAllCategoryResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@@ -522,7 +646,7 @@ func file_service_qgdzs_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_qgdzs_proto_rawDesc, RawDescriptor: file_service_qgdzs_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 6, NumMessages: 8,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@@ -107,6 +107,30 @@ func local_request_Qgdzs_AnswerQuestion_0(ctx context.Context, marshaler runtime
return msg, metadata, err return msg, metadata, err
} }
func request_Qgdzs_GetAllCategory_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetAllCategoryReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetAllCategory(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetAllCategory_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetAllCategoryReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetAllCategory(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQgdzsHandlerServer registers the http handlers for service Qgdzs to "mux". // RegisterQgdzsHandlerServer registers the http handlers for service Qgdzs to "mux".
// UnaryRPC :call QgdzsServer directly. // UnaryRPC :call QgdzsServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -173,6 +197,26 @@ func RegisterQgdzsHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
} }
forward_Qgdzs_AnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_Qgdzs_AnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
mux.Handle(http.MethodPost, pattern_Qgdzs_GetAllCategory_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/GetAllCategory", runtime.WithHTTPPathPattern("/qgdzs/get_all_category"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetAllCategory_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetAllCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
@@ -264,6 +308,23 @@ func RegisterQgdzsHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
} }
forward_Qgdzs_AnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_Qgdzs_AnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
mux.Handle(http.MethodPost, pattern_Qgdzs_GetAllCategory_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/GetAllCategory", runtime.WithHTTPPathPattern("/qgdzs/get_all_category"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetAllCategory_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetAllCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil return nil
} }
@@ -271,10 +332,12 @@ var (
pattern_Qgdzs_GenerateQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"qgdzs", "generate_question"}, "")) pattern_Qgdzs_GenerateQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"qgdzs", "generate_question"}, ""))
pattern_Qgdzs_GetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"qgdzs", "get_question"}, "")) pattern_Qgdzs_GetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"qgdzs", "get_question"}, ""))
pattern_Qgdzs_AnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"qgdzs", "answer_question"}, "")) pattern_Qgdzs_AnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"qgdzs", "answer_question"}, ""))
pattern_Qgdzs_GetAllCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"qgdzs", "get_all_category"}, ""))
) )
var ( var (
forward_Qgdzs_GenerateQuestion_0 = runtime.ForwardResponseMessage forward_Qgdzs_GenerateQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetQuestion_0 = runtime.ForwardResponseMessage forward_Qgdzs_GetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_AnswerQuestion_0 = runtime.ForwardResponseMessage forward_Qgdzs_AnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetAllCategory_0 = runtime.ForwardResponseMessage
) )

View File

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