浏览代码

重构 OracleJy 函数并注释代码

- 移除了 OracleJy 函数中的数据库连接逻辑
- 注释掉了 connOracle函数的实现
- 在 GDError 模型中添加了 SourceName 字段
Roc 5 月之前
父节点
当前提交
b2986cf7bc
共有 2 个文件被更改,包括 15 次插入18 次删除
  1. 12 9
      config/config.go
  2. 3 9
      services/index_data/gn_base_data_platform.go

+ 12 - 9
config/config.go

@@ -123,13 +123,16 @@ type PCSG struct {
 
 // Gn 国能的的配置
 type Gn struct {
-	IndexSyncMinute    int    `mapstructure:"index-sync-minute" json:"index-sync-minute" yaml:"index-sync-minute" description:"国能同步N分钟前至现在的指标(负数)"`
-	DataHost           string `mapstructure:"data-host" json:"data-host" yaml:"data-host" description:"数据节点地址"`
-	DataAccessKey      string `mapstructure:"data-access-key" json:"data-access-key" yaml:"data-access-key" description:"数据节点的access_key"`
-	DataAccessSecret   string `mapstructure:"data-access-secret" json:"data-access-secret" yaml:"data-access-secret" description:"数据节点的access_secret"`
-	AuthClientId       string `mapstructure:"auth-client-id" json:"auth-client-id" yaml:"auth-client-id" description:"统一认证-ClientID"`
-	AuthClientSecret   string `mapstructure:"auth-client-secret" json:"auth-client-secret" yaml:"auth-client-secret" description:"统一认证-密钥"`
-	AuthSSOCallbackUrl string `mapstructure:"auth-sso-callback-url" json:"auth-sso-callback-url" yaml:"auth-sso-callback-url" description:"统一认证-回调地址"`
-	AuthTokenApiUrl    string `mapstructure:"auth-token-api-url" json:"auth-token-api-url" yaml:"auth-token-api-url" description:"统一认证-获取Token地址"`
-	AuthUserApiUrl     string `mapstructure:"auth-user-api-url" json:"auth-user-api-url" yaml:"auth-user-api-url" description:"统一认证-获取UserInfo地址"`
+	IndexSyncMinute     int    `mapstructure:"index-sync-minute" json:"index-sync-minute" yaml:"index-sync-minute" description:"国能同步N分钟前至现在的指标(负数)"`
+	DataHost            string `mapstructure:"data-host" json:"data-host" yaml:"data-host" description:"数据节点地址"`
+	DataAccessTokenUrl  string `mapstructure:"data-access-token-url" json:"data-access-token-url" yaml:"data-access-token-url" description:"获取数据节点的access_token地址"`
+	DataEdbListUrl      string `mapstructure:"data-edb-list-url" json:"data-edb-list-url" yaml:"data-edb-list-url" description:"获取数据节点的指标列表地址"`
+	DataEdbValueListUrl string `mapstructure:"data-edb-value-list-url" json:"data-edb-value-list-url" yaml:"data-edb-value-list-url" description:"获取数据节点的指标明细数据地址"`
+	DataAccessKey       string `mapstructure:"data-access-key" json:"data-access-key" yaml:"data-access-key" description:"数据节点的access_key"`
+	DataAccessSecret    string `mapstructure:"data-access-secret" json:"data-access-secret" yaml:"data-access-secret" description:"数据节点的access_secret"`
+	AuthClientId        string `mapstructure:"auth-client-id" json:"auth-client-id" yaml:"auth-client-id" description:"统一认证-ClientID"`
+	AuthClientSecret    string `mapstructure:"auth-client-secret" json:"auth-client-secret" yaml:"auth-client-secret" description:"统一认证-密钥"`
+	AuthSSOCallbackUrl  string `mapstructure:"auth-sso-callback-url" json:"auth-sso-callback-url" yaml:"auth-sso-callback-url" description:"统一认证-回调地址"`
+	AuthTokenApiUrl     string `mapstructure:"auth-token-api-url" json:"auth-token-api-url" yaml:"auth-token-api-url" description:"统一认证-获取Token地址"`
+	AuthUserApiUrl      string `mapstructure:"auth-user-api-url" json:"auth-user-api-url" yaml:"auth-user-api-url" description:"统一认证-获取UserInfo地址"`
 }

+ 3 - 9
services/index_data/gn_base_data_platform.go

@@ -16,12 +16,6 @@ import (
 	"time"
 )
 
-const (
-	DataAuthUrl         = "auth/v1/api/accessToken"                           // 获取token的地址
-	DataEdbListUrl      = "server/v1/openApi/apiServer/zbjbxxb_1728544380514" // 获取指标列表
-	DataEdbValueListUrl = "server/v1/openApi/apiServer/zbszb_1728544456707"   // 获取指标明细列表
-)
-
 // GnBaseDataResp
 // @Description: 基础返回
 type GnBaseDataResp struct {
@@ -100,7 +94,7 @@ func GetIndexInfoList(param IndexInfoReq) (resp GnEdbIndexListResp, err error) {
 		}
 	}()
 
-	urlStr := DataEdbListUrl
+	urlStr := global.CONFIG.Gn.DataEdbListUrl
 
 	// 获取token
 	token, err := GetGnAccessToken(false)
@@ -175,7 +169,7 @@ func GetIndexValueList(param IndexValueReq) (resp GnEdbIndexValueListResp, err e
 		}
 	}()
 
-	urlStr := DataEdbValueListUrl
+	urlStr := global.CONFIG.Gn.DataEdbValueListUrl
 
 	// 获取token
 	token, err := GetGnAccessToken(false)
@@ -263,7 +257,7 @@ func getGnAccessToken() (resp GnDataAccessResp, err error) {
 
 	timestamp, sign := GetSign()
 	// 请求地址
-	urlPath := fmt.Sprintf(`%s?accessKey=%s&timestamp=%d&sign=%s`, DataAuthUrl, global.CONFIG.Gn.DataAccessKey, timestamp, sign)
+	urlPath := fmt.Sprintf(`%s?accessKey=%s&timestamp=%d&sign=%s`, global.CONFIG.Gn.DataAccessTokenUrl, global.CONFIG.Gn.DataAccessKey, timestamp, sign)
 	result, err := HttpGetGn(urlPath)
 	if err != nil {
 		return