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

package operateservice

import (
	"context"
	client "github.com/cloudwego/kitex/client"
	kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
	operate "github.com/cqqqq777/go-kitex-mall/shared/kitex_gen/operate"
)

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

var operateServiceServiceInfo = NewServiceInfo()

func NewServiceInfo() *kitex.ServiceInfo {
	serviceName := "OperateService"
	handlerType := (*operate.OperateService)(nil)
	methods := map[string]kitex.MethodInfo{
		"FavoriteProduct":       kitex.NewMethodInfo(favoriteProductHandler, newOperateServiceFavoriteProductArgs, newOperateServiceFavoriteProductResult, false),
		"GetProductOperateInfo": kitex.NewMethodInfo(getProductOperateInfoHandler, newOperateServiceGetProductOperateInfoArgs, newOperateServiceGetProductOperateInfoResult, false),
	}
	extra := map[string]interface{}{
		"PackageName": "operate",
	}
	svcInfo := &kitex.ServiceInfo{
		ServiceName:     serviceName,
		HandlerType:     handlerType,
		Methods:         methods,
		PayloadCodec:    kitex.Thrift,
		KiteXGenVersion: "v0.5.1",
		Extra:           extra,
	}
	return svcInfo
}

func favoriteProductHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*operate.OperateServiceFavoriteProductArgs)
	realResult := result.(*operate.OperateServiceFavoriteProductResult)
	success, err := handler.(operate.OperateService).FavoriteProduct(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newOperateServiceFavoriteProductArgs() interface{} {
	return operate.NewOperateServiceFavoriteProductArgs()
}

func newOperateServiceFavoriteProductResult() interface{} {
	return operate.NewOperateServiceFavoriteProductResult()
}

func getProductOperateInfoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*operate.OperateServiceGetProductOperateInfoArgs)
	realResult := result.(*operate.OperateServiceGetProductOperateInfoResult)
	success, err := handler.(operate.OperateService).GetProductOperateInfo(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newOperateServiceGetProductOperateInfoArgs() interface{} {
	return operate.NewOperateServiceGetProductOperateInfoArgs()
}

func newOperateServiceGetProductOperateInfoResult() interface{} {
	return operate.NewOperateServiceGetProductOperateInfoResult()
}

type kClient struct {
	c client.Client
}

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

func (p *kClient) FavoriteProduct(ctx context.Context, req *operate.MallFavoriteProductRequest) (r *operate.MallFavoriteProductResponse, err error) {
	var _args operate.OperateServiceFavoriteProductArgs
	_args.Req = req
	var _result operate.OperateServiceFavoriteProductResult
	if err = p.c.Call(ctx, "FavoriteProduct", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) GetProductOperateInfo(ctx context.Context, req *operate.MallGetProductOperateInfoRequest) (r *operate.MallGetProductOperateInfoResponse, err error) {
	var _args operate.OperateServiceGetProductOperateInfoArgs
	_args.Req = req
	var _result operate.OperateServiceGetProductOperateInfoResult
	if err = p.c.Call(ctx, "GetProductOperateInfo", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}
