Files
lone-services/services/analysis/internal/config/wechat.go
T
zzw c4eede1114
CI / changes (push) Successful in 1m32s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / analysis (push) Successful in 3m45s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 0s
CI / order (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / percutaneous (push) Successful in 1s
CI / product (push) Successful in 0s
CI / sale (push) Successful in 0s
CI / record (push) Successful in 0s
CI / store (push) Successful in 0s
CI / support (push) Successful in 0s
CI / user (push) Successful in 1s
CI / task (push) Successful in 0s
CI / water (push) Successful in 0s
CI / wecom (push) Successful in 0s
CI / ws (push) Successful in 0s
feat: analysis user status
2026-10-27 09:01:36 +08:00

67 lines
1.5 KiB
Go

package config
import (
"fmt"
"lone-services/pkg/utils"
"lone-services/pkg/wechat/auth"
"lone-services/pkg/wechat/qrcode"
)
type WechatConfig struct {
AppID string
Secret string
Page string
AuthPage string
ReportPage string
Width int
EnvVersion string
}
func LoadWechatConfig() (*WechatConfig, 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")
if page == utils.StringEmpty {
page = "pages/index/index"
}
authPage := utils.GetConfigString("wechat.auth_page")
if authPage == utils.StringEmpty {
authPage = "pagesB/authorize/scan"
}
reportPage := utils.GetConfigString("wechat.report_page")
if reportPage == utils.StringEmpty {
reportPage = "pagesB/details/index"
}
width := utils.GetConfigInt("wechat.width")
if width <= 0 {
width = 430
}
envVersion := utils.GetConfigString("wechat.env_version")
if envVersion == utils.StringEmpty {
envVersion = "trial"
}
return &WechatConfig{
AppID: appID,
Secret: secret,
Page: page,
AuthPage: authPage,
ReportPage: reportPage,
Width: width,
EnvVersion: envVersion,
}, nil
}
func (c *WechatConfig) NewAuthClient() *auth.Client {
return auth.NewClient(c.AppID, c.Secret)
}
func (c *WechatConfig) NewQrcodeClient() *qrcode.Client {
return qrcode.NewClient(c.NewAuthClient())
}