重构项目结构,将 orm 和 rds 包迁移到 web/globals

This commit is contained in:
2025-05-10 16:59:41 +08:00
parent 37e6e58816
commit d256359681
60 changed files with 363 additions and 349 deletions

View File

@@ -10,7 +10,6 @@ import (
"net/http/httputil"
"net/url"
"platform/pkg/env"
"platform/pkg/rds"
"strconv"
"strings"
"time"
@@ -36,7 +35,7 @@ type cloud struct {
var Cloud CloudClient
func InitBaiyin() {
func initBaiyin() {
Cloud = &cloud{
url: env.BaiyinAddr,
}
@@ -304,7 +303,7 @@ func (c *cloud) requestCloud(method string, url string, data string) (*http.Resp
func (c *cloud) token(refresh bool) (string, error) {
// redis 获取令牌
if !refresh {
token, err := rds.Client.Get(context.Background(), "remote:token").Result()
token, err := Redis.Get(context.Background(), "remote:token").Result()
if err == nil && token != "" {
return token, nil
}
@@ -347,7 +346,7 @@ func (c *cloud) token(refresh bool) (string, error) {
// redis 设置令牌
token := result["token"].(string)
err = rds.Client.Set(context.Background(), "remote:token", token, 1*time.Hour).Err()
err = Redis.Set(context.Background(), "remote:token", token, 1*time.Hour).Err()
if err != nil {
return "", err
}
@@ -521,6 +520,7 @@ func (c *gateway) GatewayPortActive(param ...PortActiveReq) (map[string]PortData
// endregion
func (c *gateway) requestGateway(method string, url string, data string) (*http.Response, error) {
//goland:noinspection ALL
url = fmt.Sprintf("http://%s:%s@%s:9990%s", c.username, c.password, c.url, url)
req, err := http.NewRequest(method, url, strings.NewReader(data))
if err != nil {