This commit is contained in:
zhangkun9038@dingtalk.com 2025-02-21 13:54:12 +08:00
parent 9a83607b2c
commit 51f087589a
2 changed files with 17 additions and 9 deletions

View File

@ -15,16 +15,24 @@ import (
simple "github.com/bitly/go-simplejson" simple "github.com/bitly/go-simplejson"
"github.com/go-redis/redis" "github.com/go-redis/redis"
"github.com/phyer/core/core"
"github.com/phyer/texus/utils" "github.com/phyer/texus/utils"
logrus "github.com/sirupsen/logrus" 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 { type Candle struct {
Id string `json:"_id"` Id string `json:"_id"`
core *core.Core Core CoreService // 改为接口类型
InstID string `json:"instID"` InstID string `json:"instID"`
Period string `json:"period"` Period string `json:"period"`
Data []interface{} Data []interface{}
From string `json:"from"` From string `json:"from"`
Timestamp time.Time `json:"timeStamp"` Timestamp time.Time `json:"timeStamp"`
@ -37,7 +45,7 @@ type Candle struct {
Confirm bool `json:"confirm"` Confirm bool `json:"confirm"`
} }
type Sample interface { type Sample interface {
SetToKey(cr *Core) ([]interface{}, error) SetToKey(cr *CoreService) ([]interface{}, error)
} }
type SampleList interface { type SampleList interface {
@ -63,7 +71,7 @@ type MatchCheck struct {
Matched bool Matched bool
} }
func (cd *Candle) Filter(cr *Core) bool { func (cd *Candle) Filter(cr *CoreService) bool {
myFocusList := cr.Cfg.Config.Get("focusList").MustArray() myFocusList := cr.Cfg.Config.Get("focusList").MustArray()
founded := false founded := false
for _, v := range myFocusList { for _, v := range myFocusList {

View File

@ -1,4 +1,4 @@
package core package service
import ( import (
"context" "context"
@ -632,7 +632,7 @@ func (cr *Core) ProcessOrder(od *private.Order) error {
// return res.V5Response, nil // return res.V5Response, nil
// } // }
func (cr *Core) AddToGeneralCandleChnl(candle *Candle, channels []string) { func (cr *Core) AddToGeneralCandleChnl(candle *model.Candle, channels []string) {
redisCli := cr.RedisLocalCli redisCli := cr.RedisLocalCli
ab, err := json.Marshal(candle) ab, err := json.Marshal(candle)
if err != nil { if err != nil {