refactor: simplify config and remove unused database tables

- Remove system_config, beta_codes, signal_source tables and related code
- Simplify config.go to only read from .env (APIServerPort, JWTSecret, RegistrationEnabled)
- Remove GetCustomCoins, use all USDT perpetual contracts for WSMonitor
- Add trader_equity_snapshots table for equity tracking
- Remove signal source modal from frontend AITradersPage
- Fix WSMonitor nil panic by restoring initialization in main.go
This commit is contained in:
tinkle-community
2025-12-07 20:17:03 +08:00
parent 07ac8e4ecd
commit 2334d78e4a
15 changed files with 490 additions and 1493 deletions

View File

@@ -2,11 +2,6 @@ package store
import (
"database/sql"
"encoding/json"
"nofx/logger"
"nofx/market"
"slices"
"strings"
"time"
)
@@ -341,43 +336,6 @@ func (s *TraderStore) getActiveOrDefaultStrategy(userID string) (*Strategy, erro
return &strategy, nil
}
// GetCustomCoins 获取所有交易员自定义币种
func (s *TraderStore) GetCustomCoins() []string {
var symbol string
var symbols []string
_ = s.db.QueryRow(`
SELECT GROUP_CONCAT(trading_symbols, ',') as symbol
FROM traders WHERE trading_symbols != ''
`).Scan(&symbol)
// 如果没有自定义币种,返回默认币种
if symbol == "" {
var symbolJSON string
_ = s.db.QueryRow(`SELECT value FROM system_config WHERE key = 'default_coins'`).Scan(&symbolJSON)
if symbolJSON != "" {
if err := json.Unmarshal([]byte(symbolJSON), &symbols); err != nil {
logger.Warnf("⚠️ 解析default_coins配置失败: %v使用硬编码默认值", err)
symbols = []string{"BTCUSDT", "ETHUSDT", "SOLUSDT", "BNBUSDT"}
}
} else {
symbols = []string{"BTCUSDT", "ETHUSDT", "SOLUSDT", "BNBUSDT"}
}
return symbols
}
// 处理并去重币种列表
for _, s := range strings.Split(symbol, ",") {
if s == "" {
continue
}
coin := market.Normalize(s)
if !slices.Contains(symbols, coin) {
symbols = append(symbols, coin)
}
}
return symbols
}
// ListAll 获取所有用户的交易员列表
func (s *TraderStore) ListAll() ([]*Trader, error) {
rows, err := s.db.Query(`