feat: analysis user auth and ws
This commit is contained in:
@@ -4,19 +4,20 @@ import (
|
||||
"fmt"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/wechat/auth"
|
||||
"lone-services/pkg/wechat/qrcode"
|
||||
)
|
||||
|
||||
type WechatQrcodeConfig struct {
|
||||
type WechatConfig struct {
|
||||
AppID string
|
||||
Secret string
|
||||
Page string
|
||||
AuthPage string
|
||||
Width int
|
||||
EnvVersion string
|
||||
}
|
||||
|
||||
func LoadWechatQrcodeConfig() (*WechatQrcodeConfig, error) {
|
||||
|
||||
func LoadWechatConfig() (*WechatConfig, error) {
|
||||
appID := utils.GetConfigString("wechat.appid")
|
||||
secret := utils.GetConfigString("wechat.secret")
|
||||
if appID == utils.StringEmpty || secret == utils.StringEmpty {
|
||||
@@ -24,22 +25,36 @@ func LoadWechatQrcodeConfig() (*WechatQrcodeConfig, error) {
|
||||
}
|
||||
|
||||
page := utils.GetConfigString("wechat.page")
|
||||
|
||||
if page == utils.StringEmpty {
|
||||
page = "pages/index/index"
|
||||
}
|
||||
authPage := utils.GetConfigString("wechat.auth_page")
|
||||
if authPage == utils.StringEmpty {
|
||||
authPage = "pagesB/authorize/scan"
|
||||
}
|
||||
width := utils.GetConfigInt("wechat.width")
|
||||
if width <= 0 {
|
||||
width = 430
|
||||
}
|
||||
envVersion := utils.GetConfigString("wechat.env_version")
|
||||
if envVersion == utils.StringEmpty {
|
||||
envVersion = "trial"
|
||||
}
|
||||
|
||||
return &WechatQrcodeConfig{
|
||||
return &WechatConfig{
|
||||
AppID: appID,
|
||||
Secret: secret,
|
||||
Page: page,
|
||||
AuthPage: authPage,
|
||||
Width: width,
|
||||
EnvVersion: envVersion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *WechatQrcodeConfig) NewQrcodeClient() *qrcode.Client {
|
||||
return qrcode.NewClient(c.AppID, c.Secret)
|
||||
func (c *WechatConfig) NewAuthClient() *auth.Client {
|
||||
return auth.NewClient(c.AppID, c.Secret)
|
||||
}
|
||||
|
||||
func (c *WechatConfig) NewQrcodeClient() *qrcode.Client {
|
||||
return qrcode.NewClient(c.NewAuthClient())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user