// Code generated by Kitex v0.3.2. DO NOT EDIT.

package studentmanagement

import (
	"context"
	"github.com/cloudwego/kitex/client"
	kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
	"hertz-examples/hz_demo/hertz-server/kitex_gen/student/management"
)

func serviceInfo() *kitex.ServiceInfo {
	return studentManagementServiceInfo
}

var studentManagementServiceInfo = NewServiceInfo()

func NewServiceInfo() *kitex.ServiceInfo {
	serviceName := "StudentManagement"
	handlerType := (*management.StudentManagement)(nil)
	methods := map[string]kitex.MethodInfo{
		"queryStudent":  kitex.NewMethodInfo(queryStudentHandler, newStudentManagementQueryStudentArgs, newStudentManagementQueryStudentResult, false),
		"insertStudent": kitex.NewMethodInfo(insertStudentHandler, newStudentManagementInsertStudentArgs, newStudentManagementInsertStudentResult, false),
	}
	extra := map[string]interface{}{
		"PackageName": "management",
	}
	svcInfo := &kitex.ServiceInfo{
		ServiceName:     serviceName,
		HandlerType:     handlerType,
		Methods:         methods,
		PayloadCodec:    kitex.Thrift,
		KiteXGenVersion: "v0.3.2",
		Extra:           extra,
	}
	return svcInfo
}

func queryStudentHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*management.StudentManagementQueryStudentArgs)
	realResult := result.(*management.StudentManagementQueryStudentResult)
	success, err := handler.(management.StudentManagement).QueryStudent(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newStudentManagementQueryStudentArgs() interface{} {
	return management.NewStudentManagementQueryStudentArgs()
}

func newStudentManagementQueryStudentResult() interface{} {
	return management.NewStudentManagementQueryStudentResult()
}

func insertStudentHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*management.StudentManagementInsertStudentArgs)
	realResult := result.(*management.StudentManagementInsertStudentResult)
	success, err := handler.(management.StudentManagement).InsertStudent(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newStudentManagementInsertStudentArgs() interface{} {
	return management.NewStudentManagementInsertStudentArgs()
}

func newStudentManagementInsertStudentResult() interface{} {
	return management.NewStudentManagementInsertStudentResult()
}

type kClient struct {
	c client.Client
}

func newServiceClient(c client.Client) *kClient {
	return &kClient{
		c: c,
	}
}

func (p *kClient) QueryStudent(ctx context.Context, req *management.QueryStudentRequest) (r *management.QueryStudentResponse, err error) {
	var _args management.StudentManagementQueryStudentArgs
	_args.Req = req
	var _result management.StudentManagementQueryStudentResult
	if err = p.c.Call(ctx, "queryStudent", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) InsertStudent(ctx context.Context, req *management.InsertStudentRequest) (r *management.InsertStudentResponse, err error) {
	var _args management.StudentManagementInsertStudentArgs
	_args.Req = req
	var _result management.StudentManagementInsertStudentResult
	if err = p.c.Call(ctx, "insertStudent", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}
