Browse Source

刷新地址改成可配置

xyxie 1 year ago
parent
commit
8ee8cf3acd
2 changed files with 7 additions and 2 deletions
  1. 1 0
      config/config.go
  2. 6 2
      services/api_tool.go

+ 1 - 0
config/config.go

@@ -24,6 +24,7 @@ type Serve struct {
 	EdbLibMd5Key    string `mapstructure:"edb_lib_md5_key" json:"edb_lib_md5_key" yaml:"edb_lib_md5_key" description:"指标库服务秘钥"`
 	TerminalCode    string `mapstructure:"terminal_code" json:"terminal_code" yaml:"terminal_code" description:"终端编码"`
 	RefreshTime     string `mapstructure:"refresh_time" json:"refresh_time" yaml:"refresh_time" description:"刷新服务任务更新时间"`
+	RefreshUrl      string `mapstructure:"refresh_url" json:"refresh_url" yaml:"refresh_url" description:"刷新服务任务更新地址"`
 }
 
 // Log 日志配置

+ 6 - 2
services/api_tool.go

@@ -3,19 +3,23 @@ package services
 import (
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/http"
+	"hongze/hongtao3_watch/global"
 	"net/url"
 )
 
 const (
 	// RefreshUrl 值示例:http://127.0.0.1:7007/hongtao/refresh?FilePath=E:\hz\hongtao3_data\excel\Oneline\%E7%83%A7%E7%A2%B1.xlsx
-	RefreshUrl = "http://127.0.0.1:7007/hongtao/refresh"
+	DefaultRefreshUrl = "http://127.0.0.1:7007/"
 )
 
 // InvokeRefreshServer 调用红桃3刷新数据的服务(目前是python)
 func InvokeRefreshServer(filePath string) {
 	var refreshUrl string
+	if global.CONFIG.Serve.RefreshUrl == "" {
+		refreshUrl = DefaultRefreshUrl
+	}
 	//filePathStr:=url.PathEscape(filePath)
-	refreshUrl = RefreshUrl + "?FilePath=" + url.QueryEscape(filePath)
+	refreshUrl = refreshUrl + "hongtao/refresh?FilePath=" + url.QueryEscape(filePath)
 	fmt.Println("红桃3刷新,文件路径:", filePath, ";刷新URL:"+refreshUrl)
 	body, err := http.Get(refreshUrl)
 	if err != nil {