feat: analysis gen qrcode
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/wechat/qrcode"
|
||||
)
|
||||
|
||||
type WechatQrcodeConfig struct {
|
||||
AppID string
|
||||
Secret string
|
||||
Page string
|
||||
Width int
|
||||
EnvVersion string
|
||||
}
|
||||
|
||||
func LoadWechatQrcodeConfig() (*WechatQrcodeConfig, error) {
|
||||
|
||||
appID := utils.GetConfigString("wechat.appid")
|
||||
secret := utils.GetConfigString("wechat.secret")
|
||||
if appID == utils.StringEmpty || secret == utils.StringEmpty {
|
||||
return nil, fmt.Errorf("wechat config missing")
|
||||
}
|
||||
|
||||
page := utils.GetConfigString("wechat.page")
|
||||
|
||||
width := utils.GetConfigInt("wechat.width")
|
||||
envVersion := utils.GetConfigString("wechat.env_version")
|
||||
if envVersion == utils.StringEmpty {
|
||||
envVersion = "trial"
|
||||
}
|
||||
|
||||
return &WechatQrcodeConfig{
|
||||
AppID: appID,
|
||||
Secret: secret,
|
||||
Page: page,
|
||||
Width: width,
|
||||
EnvVersion: envVersion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *WechatQrcodeConfig) NewQrcodeClient() *qrcode.Client {
|
||||
return qrcode.NewClient(c.AppID, c.Secret)
|
||||
}
|
||||
Reference in New Issue
Block a user