package utils

import (
	"github.com/zjxpcyc/wechat/wx"
)

var wxClients map[string]*wx.Client

// WxClientSingleton 初始化
func WxClientSingleton(org string, cert map[string]string) {
	if wxClients == nil {
		wxClients = map[string]*wx.Client{
			org: wx.NewClient(cert),
		}
	} else {
		if _, ok := wxClients[org]; !ok {
			wxClients[org] = wx.NewClient(cert)
		}
	}
}

// WxClientFor 微信客户端
func WxClientFor(org string) *wx.Client {
	return wxClients[org]
}

func init() {
	wx.SetLogInst(defaultLogger)
}
