From b61fbe6ea3823ba9a0cfdfb8a2b2d1300aae1484 Mon Sep 17 00:00:00 2001 From: ZhouYongyou <128128010+zhouyongyou@users.noreply.github.com> Date: Mon, 3 Nov 2025 23:18:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20GetTraderConfig=20missing=20critical=20f?= =?UTF-8?q?ields=20in=20SELECT/Scan=20**Problem**:=20-=20GetTraderConfig?= =?UTF-8?q?=20was=20missing=209=20critical=20fields=20in=20SELECT=20statem?= =?UTF-8?q?ent=20-=20Missing=20corresponding=20Scan=20variables=20-=20Caus?= =?UTF-8?q?ed=20trader=20edit=20UI=20to=20show=200=20for=20leverage=20and?= =?UTF-8?q?=20empty=20trading=5Fsymbols=20**Root=20Cause**:=20Database=20q?= =?UTF-8?q?uery=20only=20selected=20basic=20fields=20(id,=20name,=20balanc?= =?UTF-8?q?e,=20etc.)=20but=20missed=20leverage,=20trading=5Fsymbols,=20pr?= =?UTF-8?q?ompts,=20and=20all=20custom=20configs=20**Fix**:=20-=20Added=20?= =?UTF-8?q?missing=20fields=20to=20SELECT:=20=20=20*=20btc=5Feth=5Fleverag?= =?UTF-8?q?e,=20altcoin=5Fleverage=20=20=20*=20trading=5Fsymbols=20=20=20*?= =?UTF-8?q?=20use=5Fcoin=5Fpool,=20use=5Foi=5Ftop=20=20=20*=20custom=5Fpro?= =?UTF-8?q?mpt,=20override=5Fbase=5Fprompt=20=20=20*=20system=5Fprompt=5Ft?= =?UTF-8?q?emplate=20=20=20*=20is=5Fcross=5Fmargin=20=20=20*=20AI=20model?= =?UTF-8?q?=20custom=5Fapi=5Furl,=20custom=5Fmodel=5Fname=20-=20Added=20co?= =?UTF-8?q?rresponding=20Scan=20variables=20to=20match=20SELECT=20order=20?= =?UTF-8?q?**Impact**:=20=E2=9C=85=20Trader=20edit=20modal=20now=20display?= =?UTF-8?q?s=20correct=20leverage=20values=20=E2=9C=85=20Trading=20symbols?= =?UTF-8?q?=20list=20properly=20populated=20=E2=9C=85=20All=20custom=20con?= =?UTF-8?q?figurations=20preserved=20and=20displayed=20=E2=9C=85=20API=20e?= =?UTF-8?q?ndpoint=20/traders/:id/config=20returns=20complete=20data=20**T?= =?UTF-8?q?esting**:=20-=20=E2=9C=85=20Go=20compilation=20successful=20-?= =?UTF-8?q?=20=E2=9C=85=20All=20fields=20aligned=20(31=20SELECT=20=3D=2031?= =?UTF-8?q?=20Scan)=20-=20=E2=9C=85=20API=20layer=20verified=20(api/server?= =?UTF-8?q?.go:887-904)=20Reported=20by:=20=E5=AF=92=E6=B1=9F=E5=AD=A4?= =?UTF-8?q?=E5=BD=B1=20Issue:=20Trader=20config=20edit=20modal=20showing?= =?UTF-8?q?=200=20leverage=20and=20empty=20symbols=20Co-Authored-By:=20tin?= =?UTF-8?q?kle-community=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/database.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/config/database.go b/config/database.go index 1102c6fb..47d9bcbb 100644 --- a/config/database.go +++ b/config/database.go @@ -857,9 +857,22 @@ func (d *Database) GetTraderConfig(userID, traderID string) (*TraderRecord, *AIM var exchange ExchangeConfig err := d.db.QueryRow(` - SELECT - t.id, t.user_id, t.name, t.ai_model_id, t.exchange_id, t.initial_balance, t.scan_interval_minutes, t.is_running, t.created_at, t.updated_at, - a.id, a.user_id, a.name, a.provider, a.enabled, a.api_key, a.created_at, a.updated_at, + SELECT + t.id, t.user_id, t.name, t.ai_model_id, t.exchange_id, t.initial_balance, t.scan_interval_minutes, t.is_running, + COALESCE(t.btc_eth_leverage, 5) as btc_eth_leverage, + COALESCE(t.altcoin_leverage, 5) as altcoin_leverage, + COALESCE(t.trading_symbols, '') as trading_symbols, + COALESCE(t.use_coin_pool, 0) as use_coin_pool, + COALESCE(t.use_oi_top, 0) as use_oi_top, + COALESCE(t.custom_prompt, '') as custom_prompt, + COALESCE(t.override_base_prompt, 0) as override_base_prompt, + COALESCE(t.system_prompt_template, 'default') as system_prompt_template, + COALESCE(t.is_cross_margin, 1) as is_cross_margin, + t.created_at, t.updated_at, + a.id, a.user_id, a.name, a.provider, a.enabled, a.api_key, + COALESCE(a.custom_api_url, '') as custom_api_url, + COALESCE(a.custom_model_name, '') as custom_model_name, + a.created_at, a.updated_at, e.id, e.user_id, e.name, e.type, e.enabled, e.api_key, e.secret_key, e.testnet, COALESCE(e.hyperliquid_wallet_addr, '') as hyperliquid_wallet_addr, COALESCE(e.aster_user, '') as aster_user, @@ -873,8 +886,13 @@ func (d *Database) GetTraderConfig(userID, traderID string) (*TraderRecord, *AIM `, traderID, userID).Scan( &trader.ID, &trader.UserID, &trader.Name, &trader.AIModelID, &trader.ExchangeID, &trader.InitialBalance, &trader.ScanIntervalMinutes, &trader.IsRunning, + &trader.BTCETHLeverage, &trader.AltcoinLeverage, &trader.TradingSymbols, + &trader.UseCoinPool, &trader.UseOITop, + &trader.CustomPrompt, &trader.OverrideBasePrompt, &trader.SystemPromptTemplate, + &trader.IsCrossMargin, &trader.CreatedAt, &trader.UpdatedAt, &aiModel.ID, &aiModel.UserID, &aiModel.Name, &aiModel.Provider, &aiModel.Enabled, &aiModel.APIKey, + &aiModel.CustomAPIURL, &aiModel.CustomModelName, &aiModel.CreatedAt, &aiModel.UpdatedAt, &exchange.ID, &exchange.UserID, &exchange.Name, &exchange.Type, &exchange.Enabled, &exchange.APIKey, &exchange.SecretKey, &exchange.Testnet,