Explorar o código

新增根据频度刷新指标

tuoling805 hai 1 ano
pai
achega
088d9c8d66
Modificáronse 4 ficheiros con 20 adicións e 5 borrados
  1. 1 0
      config/config.go
  2. 2 2
      go.mod
  3. 2 1
      services/index.go
  4. 15 2
      watch/edb_lib.go

+ 1 - 0
config/config.go

@@ -16,6 +16,7 @@ type Serve struct {
 	EdbLibUrl         string `mapstructure:"edb-lib-url" json:"edb-lib-url" yaml:"edb-lib-url" description:"公共指标库的地址"`
 	IndexSaveDir      string `mapstructure:"index-save-dir" json:"index-save-dir" yaml:"index-save-dir" description:"监听文件夹的路径"`
 	IndexMergeSaveDir string `mapstructure:"index-merge-save-dir" json:"index-merge-save-dir" yaml:"index-merge-save-dir" description:"监听合并文件夹的路径"`
+	Frequency         string `mapstructure:"frequency" json:"frequency" yaml:"frequency" description:"频度"`
 }
 
 // Log 日志配置

+ 2 - 2
go.mod

@@ -10,10 +10,11 @@ require (
 	github.com/go-playground/validator/v10 v10.10.0
 	github.com/go-redis/redis/v8 v8.11.5
 	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
+	github.com/jinzhu/now v1.1.5 // indirect
 	github.com/jonboulle/clockwork v0.3.0 // indirect
 	github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
 	github.com/lestrrat-go/strftime v1.0.6 // indirect
-	github.com/olivere/elastic/v7 v7.0.32
+	github.com/mailru/easyjson v0.7.7 // indirect
 	github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
 	github.com/rdlucklib/rdluck_tools v1.0.3
 	github.com/robfig/cron/v3 v3.0.1
@@ -21,6 +22,5 @@ require (
 	github.com/swaggo/swag v1.8.6
 	github.com/xuri/excelize/v2 v2.6.1
 	golang.org/x/image v0.0.0-20220902085622-e7cb96979f69
-	gorm.io/driver/mysql v1.3.6
 	gorm.io/gorm v1.23.10
 )

+ 2 - 1
services/index.go

@@ -184,7 +184,8 @@ func IndexRefreshAll() {
 	fmt.Println("IndexCreateCheck")
 	//indexObj := new(index.BaseFromMysteelChemicalIndex)
 	//list, err := indexObj.GetIndexRefreshAllByMergeFile()
-	list, err := watch.GetIndexRefreshAllByMergeFile()
+	frequency := global.CONFIG.Serve.Frequency
+	list, err := watch.GetIndexRefreshAllByMergeFile(frequency)
 	if err != nil {
 		fmt.Println("GetIndexRefreshAll Err:" + err.Error())
 		return

+ 15 - 2
watch/edb_lib.go

@@ -269,8 +269,12 @@ func GetIndexCreate() (items []index.BaseFromMysteelChemicalIndex, err error) {
 	return
 }
 
+type IndexRefreshReq struct {
+	Frequency string
+}
+
 // GetIndexRefreshAllByMergeFile 获取全部刷新所需文件
-func GetIndexRefreshAllByMergeFile() (items []index.BaseFromMysteelChemicalIndex, err error) {
+func GetIndexRefreshAllByMergeFile(frequency string) (items []index.BaseFromMysteelChemicalIndex, err error) {
 	if global.CONFIG.Serve.EdbLibUrl == `` {
 		err = errors.New("刷新未配置")
 		return
@@ -278,7 +282,16 @@ func GetIndexRefreshAllByMergeFile() (items []index.BaseFromMysteelChemicalIndex
 
 	baseUrl := "/mysteel_chemical/query/refresh"
 	url := fmt.Sprint(global.CONFIG.Serve.EdbLibUrl, baseUrl)
-	result, err := HttpPost(url, "", "application/json")
+
+	req := new(IndexRefreshReq)
+	req.Frequency = frequency
+
+	postData, err := json.Marshal(req)
+	if err != nil {
+		return
+	}
+
+	result, err := HttpPost(url, string(postData), "application/json")
 	if err != nil {
 		return
 	}