From 51f087589a9af22e1ce89bfab7aa9aae9977d7b5 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Fri, 21 Feb 2025 13:54:12 +0800 Subject: [PATCH] up --- model/candle.go | 22 +++++++++++++++------- service/service_context.go | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/model/candle.go b/model/candle.go index b85a019..61e27f3 100644 --- a/model/candle.go +++ b/model/candle.go @@ -15,16 +15,24 @@ import ( simple "github.com/bitly/go-simplejson" "github.com/go-redis/redis" - "github.com/phyer/core/core" "github.com/phyer/texus/utils" logrus "github.com/sirupsen/logrus" ) +// 定义核心服务接口 +type CoreService interface { + GetCfg() *simple.Json + GetRedisLocalCli() *redis.Client + AddToGeneralCandleChnl(candle *Candle, channels []string) + PeriodToMinutes(period string) (int64, error) + // 其他需要的方法... +} + type Candle struct { - Id string `json:"_id"` - core *core.Core - InstID string `json:"instID"` - Period string `json:"period"` + Id string `json:"_id"` + Core CoreService // 改为接口类型 + InstID string `json:"instID"` + Period string `json:"period"` Data []interface{} From string `json:"from"` Timestamp time.Time `json:"timeStamp"` @@ -37,7 +45,7 @@ type Candle struct { Confirm bool `json:"confirm"` } type Sample interface { - SetToKey(cr *Core) ([]interface{}, error) + SetToKey(cr *CoreService) ([]interface{}, error) } type SampleList interface { @@ -63,7 +71,7 @@ type MatchCheck struct { Matched bool } -func (cd *Candle) Filter(cr *Core) bool { +func (cd *Candle) Filter(cr *CoreService) bool { myFocusList := cr.Cfg.Config.Get("focusList").MustArray() founded := false for _, v := range myFocusList { diff --git a/service/service_context.go b/service/service_context.go index 8340f6a..143293d 100644 --- a/service/service_context.go +++ b/service/service_context.go @@ -1,4 +1,4 @@ -package core +package service import ( "context" @@ -632,7 +632,7 @@ func (cr *Core) ProcessOrder(od *private.Order) error { // return res.V5Response, nil // } -func (cr *Core) AddToGeneralCandleChnl(candle *Candle, channels []string) { +func (cr *Core) AddToGeneralCandleChnl(candle *model.Candle, channels []string) { redisCli := cr.RedisLocalCli ab, err := json.Marshal(candle) if err != nil {