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

package itemservice

import (
	"context"
	item "github.com/cloudwego/biz-demo/book-shop/kitex_gen/cwg/bookshop/item"
	client "github.com/cloudwego/kitex/client"
	kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
)

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

var itemServiceServiceInfo = NewServiceInfo()

func NewServiceInfo() *kitex.ServiceInfo {
	serviceName := "ItemService"
	handlerType := (*item.ItemService)(nil)
	methods := map[string]kitex.MethodInfo{
		"Add":             kitex.NewMethodInfo(addHandler, newItemServiceAddArgs, newItemServiceAddResult, false),
		"Edit":            kitex.NewMethodInfo(editHandler, newItemServiceEditArgs, newItemServiceEditResult, false),
		"Delete":          kitex.NewMethodInfo(deleteHandler, newItemServiceDeleteArgs, newItemServiceDeleteResult, false),
		"Online":          kitex.NewMethodInfo(onlineHandler, newItemServiceOnlineArgs, newItemServiceOnlineResult, false),
		"Offline":         kitex.NewMethodInfo(offlineHandler, newItemServiceOfflineArgs, newItemServiceOfflineResult, false),
		"Get":             kitex.NewMethodInfo(getHandler, newItemServiceGetArgs, newItemServiceGetResult, false),
		"MGet2C":          kitex.NewMethodInfo(mGet2CHandler, newItemServiceMGet2CArgs, newItemServiceMGet2CResult, false),
		"Search":          kitex.NewMethodInfo(searchHandler, newItemServiceSearchArgs, newItemServiceSearchResult, false),
		"List":            kitex.NewMethodInfo(listHandler, newItemServiceListArgs, newItemServiceListResult, false),
		"DecrStock":       kitex.NewMethodInfo(decrStockHandler, newItemServiceDecrStockArgs, newItemServiceDecrStockResult, false),
		"DecrStockRevert": kitex.NewMethodInfo(decrStockRevertHandler, newItemServiceDecrStockRevertArgs, newItemServiceDecrStockRevertResult, false),
	}
	extra := map[string]interface{}{
		"PackageName": "item",
	}
	svcInfo := &kitex.ServiceInfo{
		ServiceName:     serviceName,
		HandlerType:     handlerType,
		Methods:         methods,
		PayloadCodec:    kitex.Thrift,
		KiteXGenVersion: "v0.4.3",
		Extra:           extra,
	}
	return svcInfo
}

func addHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceAddArgs)
	realResult := result.(*item.ItemServiceAddResult)
	success, err := handler.(item.ItemService).Add(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceAddArgs() interface{} {
	return item.NewItemServiceAddArgs()
}

func newItemServiceAddResult() interface{} {
	return item.NewItemServiceAddResult()
}

func editHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceEditArgs)
	realResult := result.(*item.ItemServiceEditResult)
	success, err := handler.(item.ItemService).Edit(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceEditArgs() interface{} {
	return item.NewItemServiceEditArgs()
}

func newItemServiceEditResult() interface{} {
	return item.NewItemServiceEditResult()
}

func deleteHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceDeleteArgs)
	realResult := result.(*item.ItemServiceDeleteResult)
	success, err := handler.(item.ItemService).Delete(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceDeleteArgs() interface{} {
	return item.NewItemServiceDeleteArgs()
}

func newItemServiceDeleteResult() interface{} {
	return item.NewItemServiceDeleteResult()
}

func onlineHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceOnlineArgs)
	realResult := result.(*item.ItemServiceOnlineResult)
	success, err := handler.(item.ItemService).Online(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceOnlineArgs() interface{} {
	return item.NewItemServiceOnlineArgs()
}

func newItemServiceOnlineResult() interface{} {
	return item.NewItemServiceOnlineResult()
}

func offlineHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceOfflineArgs)
	realResult := result.(*item.ItemServiceOfflineResult)
	success, err := handler.(item.ItemService).Offline(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceOfflineArgs() interface{} {
	return item.NewItemServiceOfflineArgs()
}

func newItemServiceOfflineResult() interface{} {
	return item.NewItemServiceOfflineResult()
}

func getHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceGetArgs)
	realResult := result.(*item.ItemServiceGetResult)
	success, err := handler.(item.ItemService).Get(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceGetArgs() interface{} {
	return item.NewItemServiceGetArgs()
}

func newItemServiceGetResult() interface{} {
	return item.NewItemServiceGetResult()
}

func mGet2CHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceMGet2CArgs)
	realResult := result.(*item.ItemServiceMGet2CResult)
	success, err := handler.(item.ItemService).MGet2C(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceMGet2CArgs() interface{} {
	return item.NewItemServiceMGet2CArgs()
}

func newItemServiceMGet2CResult() interface{} {
	return item.NewItemServiceMGet2CResult()
}

func searchHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceSearchArgs)
	realResult := result.(*item.ItemServiceSearchResult)
	success, err := handler.(item.ItemService).Search(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceSearchArgs() interface{} {
	return item.NewItemServiceSearchArgs()
}

func newItemServiceSearchResult() interface{} {
	return item.NewItemServiceSearchResult()
}

func listHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceListArgs)
	realResult := result.(*item.ItemServiceListResult)
	success, err := handler.(item.ItemService).List(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceListArgs() interface{} {
	return item.NewItemServiceListArgs()
}

func newItemServiceListResult() interface{} {
	return item.NewItemServiceListResult()
}

func decrStockHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceDecrStockArgs)
	realResult := result.(*item.ItemServiceDecrStockResult)
	success, err := handler.(item.ItemService).DecrStock(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceDecrStockArgs() interface{} {
	return item.NewItemServiceDecrStockArgs()
}

func newItemServiceDecrStockResult() interface{} {
	return item.NewItemServiceDecrStockResult()
}

func decrStockRevertHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
	realArg := arg.(*item.ItemServiceDecrStockRevertArgs)
	realResult := result.(*item.ItemServiceDecrStockRevertResult)
	success, err := handler.(item.ItemService).DecrStockRevert(ctx, realArg.Req)
	if err != nil {
		return err
	}
	realResult.Success = success
	return nil
}
func newItemServiceDecrStockRevertArgs() interface{} {
	return item.NewItemServiceDecrStockRevertArgs()
}

func newItemServiceDecrStockRevertResult() interface{} {
	return item.NewItemServiceDecrStockRevertResult()
}

type kClient struct {
	c client.Client
}

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

func (p *kClient) Add(ctx context.Context, req *item.AddReq) (r *item.AddResp, err error) {
	var _args item.ItemServiceAddArgs
	_args.Req = req
	var _result item.ItemServiceAddResult
	if err = p.c.Call(ctx, "Add", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) Edit(ctx context.Context, req *item.EditReq) (r *item.EditResp, err error) {
	var _args item.ItemServiceEditArgs
	_args.Req = req
	var _result item.ItemServiceEditResult
	if err = p.c.Call(ctx, "Edit", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) Delete(ctx context.Context, req *item.DeleteReq) (r *item.DeleteResp, err error) {
	var _args item.ItemServiceDeleteArgs
	_args.Req = req
	var _result item.ItemServiceDeleteResult
	if err = p.c.Call(ctx, "Delete", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) Online(ctx context.Context, req *item.OnlineReq) (r *item.OnlineResp, err error) {
	var _args item.ItemServiceOnlineArgs
	_args.Req = req
	var _result item.ItemServiceOnlineResult
	if err = p.c.Call(ctx, "Online", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) Offline(ctx context.Context, req *item.OfflineReq) (r *item.OfflineResp, err error) {
	var _args item.ItemServiceOfflineArgs
	_args.Req = req
	var _result item.ItemServiceOfflineResult
	if err = p.c.Call(ctx, "Offline", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) Get(ctx context.Context, req *item.GetReq) (r *item.GetResp, err error) {
	var _args item.ItemServiceGetArgs
	_args.Req = req
	var _result item.ItemServiceGetResult
	if err = p.c.Call(ctx, "Get", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) MGet2C(ctx context.Context, req *item.MGet2CReq) (r *item.MGet2CResp, err error) {
	var _args item.ItemServiceMGet2CArgs
	_args.Req = req
	var _result item.ItemServiceMGet2CResult
	if err = p.c.Call(ctx, "MGet2C", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) Search(ctx context.Context, req *item.SearchReq) (r *item.SearchResp, err error) {
	var _args item.ItemServiceSearchArgs
	_args.Req = req
	var _result item.ItemServiceSearchResult
	if err = p.c.Call(ctx, "Search", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) List(ctx context.Context, req *item.ListReq) (r *item.ListResp, err error) {
	var _args item.ItemServiceListArgs
	_args.Req = req
	var _result item.ItemServiceListResult
	if err = p.c.Call(ctx, "List", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) DecrStock(ctx context.Context, req *item.DecrStockReq) (r *item.DecrStockResp, err error) {
	var _args item.ItemServiceDecrStockArgs
	_args.Req = req
	var _result item.ItemServiceDecrStockResult
	if err = p.c.Call(ctx, "DecrStock", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}

func (p *kClient) DecrStockRevert(ctx context.Context, req *item.DecrStockReq) (r *item.DecrStockResp, err error) {
	var _args item.ItemServiceDecrStockRevertArgs
	_args.Req = req
	var _result item.ItemServiceDecrStockRevertResult
	if err = p.c.Call(ctx, "DecrStockRevert", &_args, &_result); err != nil {
		return
	}
	return _result.GetSuccess(), nil
}
