重构代码结构,迁移Baiyin SDK相关逻辑至globals包,并添加支付宝客户端初始化
This commit is contained in:
@@ -24,6 +24,10 @@
|
|||||||
- [ ] Limiter
|
- [ ] Limiter
|
||||||
- [ ] Compress
|
- [ ] Compress
|
||||||
|
|
||||||
|
统一简化包导入别名
|
||||||
|
|
||||||
|
迁移 pkg 包下的代码,尽量放置在 web/globals 下,env 和 log 作为全局公共配置保留
|
||||||
|
|
||||||
更新数据库填充
|
更新数据库填充
|
||||||
|
|
||||||
检查数据库枚举字段,0 值只作为空值使用
|
检查数据库枚举字段,0 值只作为空值使用
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"platform/pkg/logs"
|
"platform/pkg/logs"
|
||||||
"platform/pkg/orm"
|
"platform/pkg/orm"
|
||||||
"platform/pkg/rds"
|
"platform/pkg/rds"
|
||||||
"platform/pkg/sdks/baiyin"
|
|
||||||
"platform/web"
|
"platform/web"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
@@ -24,7 +23,6 @@ func main() {
|
|||||||
logs.Init()
|
logs.Init()
|
||||||
orm.Init()
|
orm.Init()
|
||||||
rds.Init()
|
rds.Init()
|
||||||
baiyin.Init()
|
|
||||||
|
|
||||||
// web 服务
|
// web 服务
|
||||||
app, err := web.New(&web.Config{
|
app, err := web.New(&web.Config{
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -42,6 +42,10 @@ require (
|
|||||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
|
github.com/smartwalle/alipay/v3 v3.2.25 // indirect
|
||||||
|
github.com/smartwalle/ncrypto v1.0.4 // indirect
|
||||||
|
github.com/smartwalle/ngx v1.0.9 // indirect
|
||||||
|
github.com/smartwalle/nsign v1.0.9 // indirect
|
||||||
github.com/stretchr/testify v1.8.2 // indirect
|
github.com/stretchr/testify v1.8.2 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasthttp v1.59.0 // indirect
|
github.com/valyala/fasthttp v1.59.0 // indirect
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -84,6 +84,14 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qq
|
|||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
|
github.com/smartwalle/alipay/v3 v3.2.25 h1:cRDN+fpDWTVHnuHIF/vsJETskRXS/S+fDOdAkzXmV/Q=
|
||||||
|
github.com/smartwalle/alipay/v3 v3.2.25/go.mod h1:lVqFiupPf8YsAXaq5JXcwqnOUC2MCF+2/5vub+RlagE=
|
||||||
|
github.com/smartwalle/ncrypto v1.0.4 h1:P2rqQxDepJwgeO5ShoC+wGcK2wNJDmcdBOWAksuIgx8=
|
||||||
|
github.com/smartwalle/ncrypto v1.0.4/go.mod h1:Dwlp6sfeNaPMnOxMNayMTacvC5JGEVln3CVdiVDgbBk=
|
||||||
|
github.com/smartwalle/ngx v1.0.9 h1:pUXDvWRZJIHVrCKA1uZ15YwNti+5P4GuJGbpJ4WvpMw=
|
||||||
|
github.com/smartwalle/ngx v1.0.9/go.mod h1:mx/nz2Pk5j+RBs7t6u6k22MPiBG/8CtOMpCnALIG8Y0=
|
||||||
|
github.com/smartwalle/nsign v1.0.9 h1:8poAgG7zBd8HkZy9RQDwasC6XZvJpDGQWSjzL2FZL6E=
|
||||||
|
github.com/smartwalle/nsign v1.0.9/go.mod h1:eY6I4CJlyNdVMP+t6z1H6Jpd4m5/V+8xi44ufSTxXgc=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
|||||||
43
pkg/env/env.go
vendored
43
pkg/env/env.go
vendored
@@ -182,6 +182,48 @@ func loadRemote() {
|
|||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
// region alipay
|
||||||
|
|
||||||
|
var (
|
||||||
|
AlipayAppId string
|
||||||
|
AlipayAppPrivateKey string
|
||||||
|
AlipayPublicKey string
|
||||||
|
AlipayEncryptKey string
|
||||||
|
AlipayProduction = false
|
||||||
|
)
|
||||||
|
|
||||||
|
func loadAlipay() {
|
||||||
|
AlipayAppId := os.Getenv("ALIPAY_APP_ID")
|
||||||
|
if AlipayAppId == "" {
|
||||||
|
panic("环境变量 ALIPAY_APP_ID 的值不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
AlipayAppPrivateKey := os.Getenv("ALIPAY_APP_PRIVATE_KEY")
|
||||||
|
if AlipayAppPrivateKey == "" {
|
||||||
|
panic("环境变量 ALIPAY_APP_PRIVATE_KEY 的值不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
AlipayPublicKey := os.Getenv("ALIPAY_PUBLIC_KEY")
|
||||||
|
if AlipayPublicKey == "" {
|
||||||
|
panic("环境变量 ALIPAY_PUBLIC_KEY 的值不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
AlipayEncryptKey := os.Getenv("ALIPAY_ENCRYPT_KEY")
|
||||||
|
if AlipayEncryptKey == "" {
|
||||||
|
panic("环境变量 ALIPAY_ENCRYPT_KEY 的值不能为空")
|
||||||
|
}
|
||||||
|
_AlipayProduction := os.Getenv("ALIPAY_PRODUCTION")
|
||||||
|
if _AlipayProduction != "" {
|
||||||
|
value, err := strconv.ParseBool(_AlipayProduction)
|
||||||
|
if err != nil {
|
||||||
|
panic("环境变量 ALIPAY_PRODUCTION 的值不是布尔值")
|
||||||
|
}
|
||||||
|
AlipayProduction = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
// region debug
|
// region debug
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -228,4 +270,5 @@ func Init() {
|
|||||||
loadLog()
|
loadLog()
|
||||||
loadDebug()
|
loadDebug()
|
||||||
loadRemote()
|
loadRemote()
|
||||||
|
loadAlipay()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package testutil
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"platform/pkg/sdks/baiyin"
|
g "platform/web/globals"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -9,15 +9,15 @@ import (
|
|||||||
// MockCloudClient 是CloudClient接口的测试实现
|
// MockCloudClient 是CloudClient接口的测试实现
|
||||||
type MockCloudClient struct {
|
type MockCloudClient struct {
|
||||||
// 存储预期结果的字段
|
// 存储预期结果的字段
|
||||||
EdgesMock func(param baiyin.CloudEdgesReq) (*baiyin.CloudEdgesResp, error)
|
EdgesMock func(param g.CloudEdgesReq) (*g.CloudEdgesResp, error)
|
||||||
ConnectMock func(param baiyin.CloudConnectReq) error
|
ConnectMock func(param g.CloudConnectReq) error
|
||||||
DisconnectMock func(param baiyin.CloudDisconnectReq) (int, error)
|
DisconnectMock func(param g.CloudDisconnectReq) (int, error)
|
||||||
AutoQueryMock func() (baiyin.CloudConnectResp, error)
|
AutoQueryMock func() (g.CloudConnectResp, error)
|
||||||
|
|
||||||
// 记录调用历史
|
// 记录调用历史
|
||||||
EdgesCalls []baiyin.CloudEdgesReq
|
EdgesCalls []g.CloudEdgesReq
|
||||||
ConnectCalls []baiyin.CloudConnectReq
|
ConnectCalls []g.CloudConnectReq
|
||||||
DisconnectCalls []baiyin.CloudDisconnectReq
|
DisconnectCalls []g.CloudDisconnectReq
|
||||||
AutoQueryCalls int
|
AutoQueryCalls int
|
||||||
|
|
||||||
// 用于并发安全
|
// 用于并发安全
|
||||||
@@ -25,19 +25,19 @@ type MockCloudClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确保MockCloudClient实现了CloudClient接口
|
// 确保MockCloudClient实现了CloudClient接口
|
||||||
var _ baiyin.CloudClient = (*MockCloudClient)(nil)
|
var _ g.CloudClient = (*MockCloudClient)(nil)
|
||||||
|
|
||||||
func (m *MockCloudClient) CloudEdges(param baiyin.CloudEdgesReq) (*baiyin.CloudEdgesResp, error) {
|
func (m *MockCloudClient) CloudEdges(param g.CloudEdgesReq) (*g.CloudEdgesResp, error) {
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
m.EdgesCalls = append(m.EdgesCalls, param)
|
m.EdgesCalls = append(m.EdgesCalls, param)
|
||||||
if m.EdgesMock != nil {
|
if m.EdgesMock != nil {
|
||||||
return m.EdgesMock(param)
|
return m.EdgesMock(param)
|
||||||
}
|
}
|
||||||
return &baiyin.CloudEdgesResp{}, nil
|
return &g.CloudEdgesResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockCloudClient) CloudConnect(param baiyin.CloudConnectReq) error {
|
func (m *MockCloudClient) CloudConnect(param g.CloudConnectReq) error {
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
m.ConnectCalls = append(m.ConnectCalls, param)
|
m.ConnectCalls = append(m.ConnectCalls, param)
|
||||||
@@ -47,7 +47,7 @@ func (m *MockCloudClient) CloudConnect(param baiyin.CloudConnectReq) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockCloudClient) CloudDisconnect(param baiyin.CloudDisconnectReq) (int, error) {
|
func (m *MockCloudClient) CloudDisconnect(param g.CloudDisconnectReq) (int, error) {
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
m.DisconnectCalls = append(m.DisconnectCalls, param)
|
m.DisconnectCalls = append(m.DisconnectCalls, param)
|
||||||
@@ -57,33 +57,33 @@ func (m *MockCloudClient) CloudDisconnect(param baiyin.CloudDisconnectReq) (int,
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockCloudClient) CloudAutoQuery() (baiyin.CloudConnectResp, error) {
|
func (m *MockCloudClient) CloudAutoQuery() (g.CloudConnectResp, error) {
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
m.AutoQueryCalls++
|
m.AutoQueryCalls++
|
||||||
if m.AutoQueryMock != nil {
|
if m.AutoQueryMock != nil {
|
||||||
return m.AutoQueryMock()
|
return m.AutoQueryMock()
|
||||||
}
|
}
|
||||||
return baiyin.CloudConnectResp{}, nil
|
return g.CloudConnectResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetupCloudClientMock 替换全局CloudClient为测试实现并在测试完成后恢复
|
// SetupCloudClientMock 替换全局CloudClient为测试实现并在测试完成后恢复
|
||||||
func SetupCloudClientMock(t *testing.T) *MockCloudClient {
|
func SetupCloudClientMock(t *testing.T) *MockCloudClient {
|
||||||
mock := &MockCloudClient{
|
mock := &MockCloudClient{
|
||||||
EdgesMock: func(param baiyin.CloudEdgesReq) (*baiyin.CloudEdgesResp, error) {
|
EdgesMock: func(param g.CloudEdgesReq) (*g.CloudEdgesResp, error) {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
},
|
},
|
||||||
ConnectMock: func(param baiyin.CloudConnectReq) error {
|
ConnectMock: func(param g.CloudConnectReq) error {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
},
|
},
|
||||||
DisconnectMock: func(param baiyin.CloudDisconnectReq) (int, error) {
|
DisconnectMock: func(param g.CloudDisconnectReq) (int, error) {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
},
|
},
|
||||||
AutoQueryMock: func() (baiyin.CloudConnectResp, error) {
|
AutoQueryMock: func() (g.CloudConnectResp, error) {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
baiyin.Cloud = mock
|
g.Cloud = mock
|
||||||
|
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
@@ -94,9 +94,9 @@ type MockGatewayClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确保MockGatewayClient实现了GatewayClient接口
|
// 确保MockGatewayClient实现了GatewayClient接口
|
||||||
var _ baiyin.GatewayClient = (*MockGatewayClient)(nil)
|
var _ g.GatewayClient = (*MockGatewayClient)(nil)
|
||||||
|
|
||||||
func (m *MockGatewayClient) GatewayPortConfigs(params []baiyin.PortConfigsReq) error {
|
func (m *MockGatewayClient) GatewayPortConfigs(params []g.PortConfigsReq) error {
|
||||||
testGatewayBase.mu.Lock()
|
testGatewayBase.mu.Lock()
|
||||||
defer testGatewayBase.mu.Unlock()
|
defer testGatewayBase.mu.Unlock()
|
||||||
testGatewayBase.PortConfigsCalls = append(testGatewayBase.PortConfigsCalls, params)
|
testGatewayBase.PortConfigsCalls = append(testGatewayBase.PortConfigsCalls, params)
|
||||||
@@ -106,42 +106,42 @@ func (m *MockGatewayClient) GatewayPortConfigs(params []baiyin.PortConfigsReq) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockGatewayClient) GatewayPortActive(param ...baiyin.PortActiveReq) (map[string]baiyin.PortData, error) {
|
func (m *MockGatewayClient) GatewayPortActive(param ...g.PortActiveReq) (map[string]g.PortData, error) {
|
||||||
testGatewayBase.mu.Lock()
|
testGatewayBase.mu.Lock()
|
||||||
defer testGatewayBase.mu.Unlock()
|
defer testGatewayBase.mu.Unlock()
|
||||||
testGatewayBase.PortActiveCalls = append(testGatewayBase.PortActiveCalls, param)
|
testGatewayBase.PortActiveCalls = append(testGatewayBase.PortActiveCalls, param)
|
||||||
if testGatewayBase.PortActiveMock != nil {
|
if testGatewayBase.PortActiveMock != nil {
|
||||||
return testGatewayBase.PortActiveMock(m, param...)
|
return testGatewayBase.PortActiveMock(m, param...)
|
||||||
}
|
}
|
||||||
return map[string]baiyin.PortData{}, nil
|
return map[string]g.PortData{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type GatewayClientIns struct {
|
type GatewayClientIns struct {
|
||||||
|
|
||||||
// 存储预期结果的字段
|
// 存储预期结果的字段
|
||||||
PortConfigsMock func(c *MockGatewayClient, params []baiyin.PortConfigsReq) error
|
PortConfigsMock func(c *MockGatewayClient, params []g.PortConfigsReq) error
|
||||||
PortActiveMock func(c *MockGatewayClient, param ...baiyin.PortActiveReq) (map[string]baiyin.PortData, error)
|
PortActiveMock func(c *MockGatewayClient, param ...g.PortActiveReq) (map[string]g.PortData, error)
|
||||||
|
|
||||||
// 记录调用历史
|
// 记录调用历史
|
||||||
PortConfigsCalls [][]baiyin.PortConfigsReq
|
PortConfigsCalls [][]g.PortConfigsReq
|
||||||
PortActiveCalls [][]baiyin.PortActiveReq
|
PortActiveCalls [][]g.PortActiveReq
|
||||||
|
|
||||||
// 用于并发安全
|
// 用于并发安全
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
var testGatewayBase = &GatewayClientIns{
|
var testGatewayBase = &GatewayClientIns{
|
||||||
PortConfigsMock: func(c *MockGatewayClient, params []baiyin.PortConfigsReq) error {
|
PortConfigsMock: func(c *MockGatewayClient, params []g.PortConfigsReq) error {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
},
|
},
|
||||||
PortActiveMock: func(c *MockGatewayClient, param ...baiyin.PortActiveReq) (map[string]baiyin.PortData, error) {
|
PortActiveMock: func(c *MockGatewayClient, param ...g.PortActiveReq) (map[string]g.PortData, error) {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetupGatewayClientMock 创建一个MockGatewayClient并提供替换函数
|
// SetupGatewayClientMock 创建一个MockGatewayClient并提供替换函数
|
||||||
func SetupGatewayClientMock(t *testing.T) *GatewayClientIns {
|
func SetupGatewayClientMock(t *testing.T) *GatewayClientIns {
|
||||||
baiyin.GatewayInitializer = func(url, username, password string) baiyin.GatewayClient {
|
g.GatewayInitializer = func(url, username, password string) g.GatewayClient {
|
||||||
return &MockGatewayClient{
|
return &MockGatewayClient{
|
||||||
Host: url,
|
Host: url,
|
||||||
}
|
}
|
||||||
|
|||||||
32
web/globals/alipay.go
Normal file
32
web/globals/alipay.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package globals
|
||||||
|
|
||||||
|
import (
|
||||||
|
"platform/pkg/env"
|
||||||
|
|
||||||
|
"github.com/smartwalle/alipay/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Alipay *alipay.Client
|
||||||
|
|
||||||
|
func InitAlipay() {
|
||||||
|
var client, err = alipay.New(
|
||||||
|
env.AlipayAppId,
|
||||||
|
env.AlipayAppPrivateKey,
|
||||||
|
env.AlipayProduction,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic("初始化支付宝客户端失败: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = client.LoadAliPayPublicKey(env.AlipayPublicKey)
|
||||||
|
if err != nil {
|
||||||
|
panic("加载支付宝公钥失败: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = client.SetEncryptKey(env.AlipayEncryptKey)
|
||||||
|
if err != nil {
|
||||||
|
panic("设置支付宝加密密钥失败: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
Alipay = client
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package baiyin
|
package globals
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -36,7 +36,7 @@ type cloud struct {
|
|||||||
|
|
||||||
var Cloud CloudClient
|
var Cloud CloudClient
|
||||||
|
|
||||||
func Init() {
|
func InitBaiyin() {
|
||||||
Cloud = &cloud{
|
Cloud = &cloud{
|
||||||
url: env.BaiyinAddr,
|
url: env.BaiyinAddr,
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/url"
|
||||||
"platform/web/auth"
|
"platform/web/auth"
|
||||||
|
g "platform/web/globals"
|
||||||
m "platform/web/models"
|
m "platform/web/models"
|
||||||
q "platform/web/queries"
|
q "platform/web/queries"
|
||||||
"platform/web/services"
|
"platform/web/services"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/smartwalle/alipay/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// region CreateTrade
|
// region CreateTrade
|
||||||
@@ -83,4 +86,31 @@ func CreateTrade(c *fiber.Ctx) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createTradeByAlipay() (*url.URL, error) {
|
||||||
|
|
||||||
|
target, err := g.Alipay.TradePagePay(alipay.TradePagePay{
|
||||||
|
Trade: alipay.Trade{},
|
||||||
|
AuthToken: "",
|
||||||
|
QRPayMode: "",
|
||||||
|
QRCodeWidth: "",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return target, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTradeByWechat() error {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region TradeCallbackAlipay
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region TradeCallbackWechat
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
"platform/pkg/env"
|
"platform/pkg/env"
|
||||||
"platform/pkg/orm"
|
"platform/pkg/orm"
|
||||||
"platform/pkg/rds"
|
"platform/pkg/rds"
|
||||||
"platform/pkg/sdks/baiyin"
|
|
||||||
"platform/pkg/u"
|
"platform/pkg/u"
|
||||||
"platform/web/common"
|
"platform/web/common"
|
||||||
|
g "platform/web/globals"
|
||||||
"platform/web/models"
|
"platform/web/models"
|
||||||
q "platform/web/queries"
|
q "platform/web/queries"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -132,18 +132,18 @@ func (s *channelService) RemoveChannels(ctx context.Context, auth *AuthContext,
|
|||||||
step = time.Now()
|
step = time.Now()
|
||||||
|
|
||||||
// 组织数据
|
// 组织数据
|
||||||
var configMap = make(map[int32][]baiyin.PortConfigsReq, len(proxies))
|
var configMap = make(map[int32][]g.PortConfigsReq, len(proxies))
|
||||||
var proxyMap = make(map[int32]*models.Proxy, len(proxies))
|
var proxyMap = make(map[int32]*models.Proxy, len(proxies))
|
||||||
for _, proxy := range proxies {
|
for _, proxy := range proxies {
|
||||||
configMap[proxy.ID] = make([]baiyin.PortConfigsReq, 0)
|
configMap[proxy.ID] = make([]g.PortConfigsReq, 0)
|
||||||
proxyMap[proxy.ID] = proxy
|
proxyMap[proxy.ID] = proxy
|
||||||
}
|
}
|
||||||
var portMap = make(map[uint64]struct{})
|
var portMap = make(map[uint64]struct{})
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
var config = baiyin.PortConfigsReq{
|
var config = g.PortConfigsReq{
|
||||||
Port: int(channel.ProxyPort),
|
Port: int(channel.ProxyPort),
|
||||||
Edge: &[]string{},
|
Edge: &[]string{},
|
||||||
AutoEdgeConfig: &baiyin.AutoEdgeConfig{
|
AutoEdgeConfig: &g.AutoEdgeConfig{
|
||||||
Count: u.P(0),
|
Count: u.P(0),
|
||||||
},
|
},
|
||||||
Status: false,
|
Status: false,
|
||||||
@@ -167,7 +167,7 @@ func (s *channelService) RemoveChannels(ctx context.Context, auth *AuthContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var secret = strings.Split(proxy.Secret, ":")
|
var secret = strings.Split(proxy.Secret, ":")
|
||||||
gateway := baiyin.NewGateway(
|
gateway := g.NewGateway(
|
||||||
proxy.Host,
|
proxy.Host,
|
||||||
secret[0],
|
secret[0],
|
||||||
secret[1],
|
secret[1],
|
||||||
@@ -208,7 +208,7 @@ func (s *channelService) RemoveChannels(ctx context.Context, auth *AuthContext,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(edges) > 0 {
|
if len(edges) > 0 {
|
||||||
_, err := baiyin.Cloud.CloudDisconnect(baiyin.CloudDisconnectReq{
|
_, err := g.Cloud.CloudDisconnect(g.CloudDisconnectReq{
|
||||||
Uuid: proxy.Name,
|
Uuid: proxy.Name,
|
||||||
Edge: edges,
|
Edge: edges,
|
||||||
})
|
})
|
||||||
@@ -406,7 +406,7 @@ func assignEdge(q *q.Query, count int, filter NodeFilterConfig) (*AssignEdgeResu
|
|||||||
// 查询已配置的节点
|
// 查询已配置的节点
|
||||||
step = time.Now()
|
step = time.Now()
|
||||||
|
|
||||||
rProxyConfigs, err := baiyin.Cloud.CloudAutoQuery()
|
rProxyConfigs, err := g.Cloud.CloudAutoQuery()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -480,13 +480,13 @@ func assignEdge(q *q.Query, count int, filter NodeFilterConfig) (*AssignEdgeResu
|
|||||||
|
|
||||||
rConfigs := rProxyConfigs[info.proxy.Name]
|
rConfigs := rProxyConfigs[info.proxy.Name]
|
||||||
|
|
||||||
var newConfig = baiyin.AutoConfig{
|
var newConfig = g.AutoConfig{
|
||||||
Province: filter.Prov,
|
Province: filter.Prov,
|
||||||
City: filter.City,
|
City: filter.City,
|
||||||
Isp: filter.Isp,
|
Isp: filter.Isp,
|
||||||
Count: int(math.Ceil(float64(info.used) * 2)),
|
Count: int(math.Ceil(float64(info.used) * 2)),
|
||||||
}
|
}
|
||||||
var newConfigs []baiyin.AutoConfig
|
var newConfigs []g.AutoConfig
|
||||||
var update = false
|
var update = false
|
||||||
for _, rConfig := range rConfigs {
|
for _, rConfig := range rConfigs {
|
||||||
if rConfig.Isp == filter.Isp && rConfig.City == filter.City && rConfig.Province == filter.Prov {
|
if rConfig.Isp == filter.Isp && rConfig.City == filter.City && rConfig.Province == filter.Prov {
|
||||||
@@ -500,7 +500,7 @@ func assignEdge(q *q.Query, count int, filter NodeFilterConfig) (*AssignEdgeResu
|
|||||||
newConfigs = append(newConfigs, newConfig)
|
newConfigs = append(newConfigs, newConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := baiyin.Cloud.CloudConnect(baiyin.CloudConnectReq{
|
err := g.Cloud.CloudConnect(g.CloudConnectReq{
|
||||||
Uuid: info.proxy.Name,
|
Uuid: info.proxy.Name,
|
||||||
Edge: nil,
|
Edge: nil,
|
||||||
AutoConfig: newConfigs,
|
AutoConfig: newConfigs,
|
||||||
@@ -587,7 +587,7 @@ func assignPort(
|
|||||||
var count = config.count
|
var count = config.count
|
||||||
|
|
||||||
// 筛选可用端口
|
// 筛选可用端口
|
||||||
var configs = make([]baiyin.PortConfigsReq, 0, count)
|
var configs = make([]g.PortConfigsReq, 0, count)
|
||||||
for port := 10000; port < 20000 && len(configs) < count; port++ {
|
for port := 10000; port < 20000 && len(configs) < count; port++ {
|
||||||
// 跳过存在的端口
|
// 跳过存在的端口
|
||||||
key := uint64(proxy.ID)<<32 | uint64(port)
|
key := uint64(proxy.ID)<<32 | uint64(port)
|
||||||
@@ -598,11 +598,11 @@ func assignPort(
|
|||||||
|
|
||||||
// 配置新端口
|
// 配置新端口
|
||||||
var i = len(configs)
|
var i = len(configs)
|
||||||
configs = append(configs, baiyin.PortConfigsReq{
|
configs = append(configs, g.PortConfigsReq{
|
||||||
Port: port,
|
Port: port,
|
||||||
Edge: nil,
|
Edge: nil,
|
||||||
Status: true,
|
Status: true,
|
||||||
AutoEdgeConfig: &baiyin.AutoEdgeConfig{
|
AutoEdgeConfig: &g.AutoEdgeConfig{
|
||||||
Province: filter.Prov,
|
Province: filter.Prov,
|
||||||
City: filter.City,
|
City: filter.City,
|
||||||
Isp: filter.Isp,
|
Isp: filter.Isp,
|
||||||
@@ -682,7 +682,7 @@ func assignPort(
|
|||||||
step = time.Now()
|
step = time.Now()
|
||||||
|
|
||||||
var secret = strings.Split(proxy.Secret, ":")
|
var secret = strings.Split(proxy.Secret, ":")
|
||||||
gateway := baiyin.NewGateway(
|
gateway := g.NewGateway(
|
||||||
proxy.Host,
|
proxy.Host,
|
||||||
secret[0],
|
secret[0],
|
||||||
secret[1],
|
secret[1],
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"platform/pkg/sdks/baiyin"
|
|
||||||
"platform/pkg/testutil"
|
"platform/pkg/testutil"
|
||||||
"platform/web/common"
|
"platform/web/common"
|
||||||
|
g "platform/web/globals"
|
||||||
"platform/web/models"
|
"platform/web/models"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -288,9 +288,9 @@ func Test_channelService_CreateChannel(t *testing.T) {
|
|||||||
ctx := context.WithValue(context.Background(), requestid.ConfigDefault.ContextKey, "test-request-id")
|
ctx := context.WithValue(context.Background(), requestid.ConfigDefault.ContextKey, "test-request-id")
|
||||||
var adminAuth = &AuthContext{Payload: Payload{Id: 100, Type: PayloadAdmin}}
|
var adminAuth = &AuthContext{Payload: Payload{Id: 100, Type: PayloadAdmin}}
|
||||||
var userAuth = &AuthContext{Payload: Payload{Id: 101, Type: PayloadUser}}
|
var userAuth = &AuthContext{Payload: Payload{Id: 101, Type: PayloadUser}}
|
||||||
mc.AutoQueryMock = func() (baiyin.CloudConnectResp, error) {
|
mc.AutoQueryMock = func() (g.CloudConnectResp, error) {
|
||||||
return baiyin.CloudConnectResp{
|
return g.CloudConnectResp{
|
||||||
"test-proxy": []baiyin.AutoConfig{
|
"test-proxy": []g.AutoConfig{
|
||||||
{Province: "河南省", Count: 10},
|
{Province: "河南省", Count: 10},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -373,14 +373,14 @@ func Test_channelService_CreateChannel(t *testing.T) {
|
|||||||
mr.FlushAll()
|
mr.FlushAll()
|
||||||
resetDb()
|
resetDb()
|
||||||
|
|
||||||
mc.ConnectMock = func(param baiyin.CloudConnectReq) error {
|
mc.ConnectMock = func(param g.CloudConnectReq) error {
|
||||||
if param.Uuid != proxy.Name {
|
if param.Uuid != proxy.Name {
|
||||||
return fmt.Errorf("代理名称不符合预期: %s", param.Uuid)
|
return fmt.Errorf("代理名称不符合预期: %s", param.Uuid)
|
||||||
}
|
}
|
||||||
if len(param.Edge) != 0 {
|
if len(param.Edge) != 0 {
|
||||||
return fmt.Errorf("边缘节点不符合预期: %v", param.Edge)
|
return fmt.Errorf("边缘节点不符合预期: %v", param.Edge)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(param.AutoConfig, []baiyin.AutoConfig{
|
if !reflect.DeepEqual(param.AutoConfig, []g.AutoConfig{
|
||||||
{Province: "河南省", Count: 10},
|
{Province: "河南省", Count: 10},
|
||||||
{Province: "北京市", Count: 6},
|
{Province: "北京市", Count: 6},
|
||||||
}) {
|
}) {
|
||||||
@@ -389,7 +389,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
mg.PortConfigsMock = func(c *testutil.MockGatewayClient, params []baiyin.PortConfigsReq) error {
|
mg.PortConfigsMock = func(c *testutil.MockGatewayClient, params []g.PortConfigsReq) error {
|
||||||
if c.Host != proxy.Host {
|
if c.Host != proxy.Host {
|
||||||
return fmt.Errorf("代理主机不符合预期: %s", c.Host)
|
return fmt.Errorf("代理主机不符合预期: %s", c.Host)
|
||||||
}
|
}
|
||||||
@@ -523,14 +523,14 @@ func Test_channelService_CreateChannel(t *testing.T) {
|
|||||||
mr.FlushAll()
|
mr.FlushAll()
|
||||||
resetDb()
|
resetDb()
|
||||||
|
|
||||||
mc.ConnectMock = func(param baiyin.CloudConnectReq) error {
|
mc.ConnectMock = func(param g.CloudConnectReq) error {
|
||||||
if param.Uuid != proxy.Name {
|
if param.Uuid != proxy.Name {
|
||||||
return fmt.Errorf("代理名称不符合预期: %s", param.Uuid)
|
return fmt.Errorf("代理名称不符合预期: %s", param.Uuid)
|
||||||
}
|
}
|
||||||
if len(param.Edge) != 0 {
|
if len(param.Edge) != 0 {
|
||||||
return fmt.Errorf("边缘节点不符合预期: %v", param.Edge)
|
return fmt.Errorf("边缘节点不符合预期: %v", param.Edge)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(param.AutoConfig, []baiyin.AutoConfig{
|
if !reflect.DeepEqual(param.AutoConfig, []g.AutoConfig{
|
||||||
{Province: "河南省", Count: 10},
|
{Province: "河南省", Count: 10},
|
||||||
{Province: "北京市", Count: 6},
|
{Province: "北京市", Count: 6},
|
||||||
}) {
|
}) {
|
||||||
@@ -539,7 +539,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
mg.PortConfigsMock = func(c *testutil.MockGatewayClient, params []baiyin.PortConfigsReq) error {
|
mg.PortConfigsMock = func(c *testutil.MockGatewayClient, params []g.PortConfigsReq) error {
|
||||||
if c.Host != proxy.Host {
|
if c.Host != proxy.Host {
|
||||||
return fmt.Errorf("代理主机不符合预期: %s", c.Host)
|
return fmt.Errorf("代理主机不符合预期: %s", c.Host)
|
||||||
}
|
}
|
||||||
@@ -667,14 +667,14 @@ func Test_channelService_CreateChannel(t *testing.T) {
|
|||||||
mr.FlushAll()
|
mr.FlushAll()
|
||||||
resetDb()
|
resetDb()
|
||||||
|
|
||||||
mc.ConnectMock = func(param baiyin.CloudConnectReq) error {
|
mc.ConnectMock = func(param g.CloudConnectReq) error {
|
||||||
if param.Uuid != proxy.Name {
|
if param.Uuid != proxy.Name {
|
||||||
return fmt.Errorf("代理名称不符合预期: %s", param.Uuid)
|
return fmt.Errorf("代理名称不符合预期: %s", param.Uuid)
|
||||||
}
|
}
|
||||||
if len(param.Edge) != 0 {
|
if len(param.Edge) != 0 {
|
||||||
return fmt.Errorf("边缘节点不符合预期: %v", param.Edge)
|
return fmt.Errorf("边缘节点不符合预期: %v", param.Edge)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(param.AutoConfig, []baiyin.AutoConfig{
|
if !reflect.DeepEqual(param.AutoConfig, []g.AutoConfig{
|
||||||
{Province: "河南省", Count: 10},
|
{Province: "河南省", Count: 10},
|
||||||
{Province: "北京市", Count: 6},
|
{Province: "北京市", Count: 6},
|
||||||
}) {
|
}) {
|
||||||
@@ -683,7 +683,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
mg.PortConfigsMock = func(c *testutil.MockGatewayClient, params []baiyin.PortConfigsReq) error {
|
mg.PortConfigsMock = func(c *testutil.MockGatewayClient, params []g.PortConfigsReq) error {
|
||||||
if c.Host != proxy.Host {
|
if c.Host != proxy.Host {
|
||||||
return fmt.Errorf("代理主机不符合预期: %s", c.Host)
|
return fmt.Errorf("代理主机不符合预期: %s", c.Host)
|
||||||
}
|
}
|
||||||
@@ -899,9 +899,9 @@ func Test_channelService_CreateChannel(t *testing.T) {
|
|||||||
setup: func() {
|
setup: func() {
|
||||||
mr.FlushAll()
|
mr.FlushAll()
|
||||||
resetDb()
|
resetDb()
|
||||||
mc.AutoQueryMock = func() (baiyin.CloudConnectResp, error) {
|
mc.AutoQueryMock = func() (g.CloudConnectResp, error) {
|
||||||
return baiyin.CloudConnectResp{
|
return g.CloudConnectResp{
|
||||||
"test-proxy": []baiyin.AutoConfig{
|
"test-proxy": []g.AutoConfig{
|
||||||
{Count: 20000},
|
{Count: 20000},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -1054,21 +1054,21 @@ func Test_channelService_RemoveChannels(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 模拟网关客户端的响应
|
// 模拟网关客户端的响应
|
||||||
mg.PortActiveMock = func(m *testutil.MockGatewayClient, param ...baiyin.PortActiveReq) (map[string]baiyin.PortData, error) {
|
mg.PortActiveMock = func(m *testutil.MockGatewayClient, param ...g.PortActiveReq) (map[string]g.PortData, error) {
|
||||||
switch {
|
switch {
|
||||||
case m.Host == proxy.Host:
|
case m.Host == proxy.Host:
|
||||||
return map[string]baiyin.PortData{
|
return map[string]g.PortData{
|
||||||
"10001": {Edge: []string{"edge1", "edge4"}},
|
"10001": {Edge: []string{"edge1", "edge4"}},
|
||||||
"10002": {Edge: []string{"edge2"}},
|
"10002": {Edge: []string{"edge2"}},
|
||||||
}, nil
|
}, nil
|
||||||
case m.Host == proxy2.Host:
|
case m.Host == proxy2.Host:
|
||||||
return map[string]baiyin.PortData{
|
return map[string]g.PortData{
|
||||||
"10001": {Edge: []string{"edge3"}},
|
"10001": {Edge: []string{"edge3"}},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("代理主机不符合预期: %s", m.Host)
|
return nil, fmt.Errorf("代理主机不符合预期: %s", m.Host)
|
||||||
}
|
}
|
||||||
mg.PortConfigsMock = func(m *testutil.MockGatewayClient, params []baiyin.PortConfigsReq) error {
|
mg.PortConfigsMock = func(m *testutil.MockGatewayClient, params []g.PortConfigsReq) error {
|
||||||
switch {
|
switch {
|
||||||
case m.Host == proxy.Host:
|
case m.Host == proxy.Host:
|
||||||
for _, param := range params {
|
for _, param := range params {
|
||||||
@@ -1099,7 +1099,7 @@ func Test_channelService_RemoveChannels(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return fmt.Errorf("代理主机不符合预期: %s", m.Host)
|
return fmt.Errorf("代理主机不符合预期: %s", m.Host)
|
||||||
}
|
}
|
||||||
mc.DisconnectMock = func(param baiyin.CloudDisconnectReq) (int, error) {
|
mc.DisconnectMock = func(param g.CloudDisconnectReq) (int, error) {
|
||||||
switch {
|
switch {
|
||||||
case param.Uuid == proxy.Name:
|
case param.Uuid == proxy.Name:
|
||||||
var edges = []string{"edge1", "edge2", "edge4"}
|
var edges = []string{"edge1", "edge2", "edge4"}
|
||||||
@@ -1168,21 +1168,21 @@ func Test_channelService_RemoveChannels(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 模拟网关客户端的响应
|
// 模拟网关客户端的响应
|
||||||
mg.PortActiveMock = func(m *testutil.MockGatewayClient, param ...baiyin.PortActiveReq) (map[string]baiyin.PortData, error) {
|
mg.PortActiveMock = func(m *testutil.MockGatewayClient, param ...g.PortActiveReq) (map[string]g.PortData, error) {
|
||||||
switch {
|
switch {
|
||||||
case m.Host == proxy.Host:
|
case m.Host == proxy.Host:
|
||||||
return map[string]baiyin.PortData{
|
return map[string]g.PortData{
|
||||||
"10001": {Edge: []string{"edge1", "edge4"}},
|
"10001": {Edge: []string{"edge1", "edge4"}},
|
||||||
"10002": {Edge: []string{"edge2"}},
|
"10002": {Edge: []string{"edge2"}},
|
||||||
}, nil
|
}, nil
|
||||||
case m.Host == proxy2.Host:
|
case m.Host == proxy2.Host:
|
||||||
return map[string]baiyin.PortData{
|
return map[string]g.PortData{
|
||||||
"10001": {Edge: []string{"edge3"}},
|
"10001": {Edge: []string{"edge3"}},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("代理主机不符合预期: %s", m.Host)
|
return nil, fmt.Errorf("代理主机不符合预期: %s", m.Host)
|
||||||
}
|
}
|
||||||
mg.PortConfigsMock = func(m *testutil.MockGatewayClient, params []baiyin.PortConfigsReq) error {
|
mg.PortConfigsMock = func(m *testutil.MockGatewayClient, params []g.PortConfigsReq) error {
|
||||||
switch {
|
switch {
|
||||||
case m.Host == proxy.Host:
|
case m.Host == proxy.Host:
|
||||||
for _, param := range params {
|
for _, param := range params {
|
||||||
@@ -1213,7 +1213,7 @@ func Test_channelService_RemoveChannels(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return fmt.Errorf("代理主机不符合预期: %s", m.Host)
|
return fmt.Errorf("代理主机不符合预期: %s", m.Host)
|
||||||
}
|
}
|
||||||
mc.DisconnectMock = func(param baiyin.CloudDisconnectReq) (int, error) {
|
mc.DisconnectMock = func(param g.CloudDisconnectReq) (int, error) {
|
||||||
switch {
|
switch {
|
||||||
case param.Uuid == proxy.Name:
|
case param.Uuid == proxy.Name:
|
||||||
var edges = []string{"edge1", "edge2", "edge4"}
|
var edges = []string{"edge1", "edge2", "edge4"}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package web
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"platform/pkg/env"
|
"platform/pkg/env"
|
||||||
|
g "platform/web/globals"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"log/slog"
|
"log/slog"
|
||||||
@@ -38,6 +39,10 @@ func New(config *Config) (*Server, error) {
|
|||||||
|
|
||||||
func (s *Server) Run() error {
|
func (s *Server) Run() error {
|
||||||
|
|
||||||
|
// inits
|
||||||
|
g.InitBaiyin()
|
||||||
|
g.InitAlipay()
|
||||||
|
|
||||||
// config
|
// config
|
||||||
s.fiber = fiber.New(fiber.Config{
|
s.fiber = fiber.New(fiber.Config{
|
||||||
ErrorHandler: ErrorHandler,
|
ErrorHandler: ErrorHandler,
|
||||||
|
|||||||
Reference in New Issue
Block a user