//go:build !ignore_autogenerated
// +build !ignore_autogenerated

// Code generated by iocli, run 'iocli gen' to re-generate

package service

import (
	autowire "github.com/alibaba/ioc-golang/autowire"
	normal "github.com/alibaba/ioc-golang/autowire/normal"
	singleton "github.com/alibaba/ioc-golang/autowire/singleton"
	util "github.com/alibaba/ioc-golang/autowire/util"
)

func init() {
	normal.RegisterStructDescriptor(&autowire.StructDescriptor{
		Factory: func() interface{} {
			return &bankService_{}
		},
	})
	bankServiceStructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &BankService{}
		},
		ConstructFunc: func(i interface{}, _ interface{}) (interface{}, error) {
			impl := i.(*BankService)
			var constructFunc BankServiceConstructFunc = InitBankService
			return constructFunc(impl)
		},
		Metadata: map[string]interface{}{
			"aop": map[string]interface{}{
				"transaction": map[string]string{
					"AddMoney":    "AddMoneyRollback",
					"RemoveMoney": "RemoveMoneyRollback",
				},
			},
			"autowire": map[string]interface{}{},
		},
	}
	singleton.RegisterStructDescriptor(bankServiceStructDescriptor)
	type bankServiceAddMoneyTxFunction func(id, num int, errMsg string)
	var _ bankServiceAddMoneyTxFunction = (&BankService{}).AddMoneyRollback
	type bankServiceRemoveMoneyTxFunction func(id, num int, errMsg string)
	var _ bankServiceRemoveMoneyTxFunction = (&BankService{}).RemoveMoneyRollback
	normal.RegisterStructDescriptor(&autowire.StructDescriptor{
		Factory: func() interface{} {
			return &tradeService_{}
		},
	})
	tradeServiceStructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &TradeService{}
		},
		Metadata: map[string]interface{}{
			"aop": map[string]interface{}{
				"transaction": map[string]string{
					"DoTradeWithTxAddMoneyFailed": "",
					"DoTradeWithTxFinallyFailed":  "",
					"DoTradeWithTxSuccess":        "",
				},
			},
			"autowire": map[string]interface{}{},
		},
	}
	singleton.RegisterStructDescriptor(tradeServiceStructDescriptor)
}

type BankServiceConstructFunc func(impl *BankService) (*BankService, error)
type bankService_ struct {
	GetMoney_            func(id int) int
	AddMoney_            func(id, num int) error
	AddMoneyRollback_    func(id, num int, errMsg string)
	RemoveMoney_         func(id, num int) error
	RemoveMoneyRollback_ func(id, num int, errMsg string)
}

func (b *bankService_) GetMoney(id int) int {
	return b.GetMoney_(id)
}

func (b *bankService_) AddMoney(id, num int) error {
	return b.AddMoney_(id, num)
}

func (b *bankService_) AddMoneyRollback(id, num int, errMsg string) {
	b.AddMoneyRollback_(id, num, errMsg)
}

func (b *bankService_) RemoveMoney(id, num int) error {
	return b.RemoveMoney_(id, num)
}

func (b *bankService_) RemoveMoneyRollback(id, num int, errMsg string) {
	b.RemoveMoneyRollback_(id, num, errMsg)
}

type tradeService_ struct {
	DoTradeWithTxAddMoneyFailed_ func(id1, id2, num int) error
	DoTradeWithTxFinallyFailed_  func(id1, id2, num int) error
	DoTradeWithTxSuccess_        func(id1, id2, num int) error
}

func (t *tradeService_) DoTradeWithTxAddMoneyFailed(id1, id2, num int) error {
	return t.DoTradeWithTxAddMoneyFailed_(id1, id2, num)
}

func (t *tradeService_) DoTradeWithTxFinallyFailed(id1, id2, num int) error {
	return t.DoTradeWithTxFinallyFailed_(id1, id2, num)
}

func (t *tradeService_) DoTradeWithTxSuccess(id1, id2, num int) error {
	return t.DoTradeWithTxSuccess_(id1, id2, num)
}

type BankServiceIOCInterface interface {
	GetMoney(id int) int
	AddMoney(id, num int) error
	AddMoneyRollback(id, num int, errMsg string)
	RemoveMoney(id, num int) error
	RemoveMoneyRollback(id, num int, errMsg string)
}

type TradeServiceIOCInterface interface {
	DoTradeWithTxAddMoneyFailed(id1, id2, num int) error
	DoTradeWithTxFinallyFailed(id1, id2, num int) error
	DoTradeWithTxSuccess(id1, id2, num int) error
}

var _bankServiceSDID string

func GetBankServiceSingleton() (*BankService, error) {
	if _bankServiceSDID == "" {
		_bankServiceSDID = util.GetSDIDByStructPtr(new(BankService))
	}
	i, err := singleton.GetImpl(_bankServiceSDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(*BankService)
	return impl, nil
}

func GetBankServiceIOCInterfaceSingleton() (BankServiceIOCInterface, error) {
	if _bankServiceSDID == "" {
		_bankServiceSDID = util.GetSDIDByStructPtr(new(BankService))
	}
	i, err := singleton.GetImplWithProxy(_bankServiceSDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(BankServiceIOCInterface)
	return impl, nil
}

type ThisBankService struct {
}

func (t *ThisBankService) This() BankServiceIOCInterface {
	thisPtr, _ := GetBankServiceIOCInterfaceSingleton()
	return thisPtr
}

var _tradeServiceSDID string

func GetTradeServiceSingleton() (*TradeService, error) {
	if _tradeServiceSDID == "" {
		_tradeServiceSDID = util.GetSDIDByStructPtr(new(TradeService))
	}
	i, err := singleton.GetImpl(_tradeServiceSDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(*TradeService)
	return impl, nil
}

func GetTradeServiceIOCInterfaceSingleton() (TradeServiceIOCInterface, error) {
	if _tradeServiceSDID == "" {
		_tradeServiceSDID = util.GetSDIDByStructPtr(new(TradeService))
	}
	i, err := singleton.GetImplWithProxy(_tradeServiceSDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(TradeServiceIOCInterface)
	return impl, nil
}

type ThisTradeService struct {
}

func (t *ThisTradeService) This() TradeServiceIOCInterface {
	thisPtr, _ := GetTradeServiceIOCInterfaceSingleton()
	return thisPtr
}
