Kaynağa Gözat

fix(bos): 批量导入列表类型对齐,instance_id 路径可环境覆盖

避免 UDS bigint=text 导致 import_batch 列表 13001;本机 instance_id 落盘改由 KLT_BOS_INSTANCE_ID_PATH 配置,云端默认路径不变。

Co-authored-by: Cursor <cursoragent@cursor.com>
cg 3 gün önce
ebeveyn
işleme
a10cc2a300

+ 11 - 2
src/bin/klt-bos/src/main.rs

@@ -429,6 +429,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
         } else {
             Some(internal_token.clone())
         };
+        // 持久化路径可被 `KLT_BOS_INSTANCE_ID_PATH` 覆盖(本机联调写 temp/runtime;
+        // 云端/容器未设时仍落 `/var/lib/seoh/...`,⛔ 在源码里写死本机路径)。
+        let instance_id_path = std::env::var("KLT_BOS_INSTANCE_ID_PATH").unwrap_or_else(|_| {
+            "/var/lib/seoh/klt-bos-instance-id.json".to_string()
+        });
         let mut reg_config = seoh_service_sdk::build_registry_registration_config_from_env(
             &cfg.registry.url,
             &cfg.registry.service_name,
@@ -438,7 +443,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
             adv_port,
             cfg.server.tls_enabled,
             cfg.registry.signature_secret.as_deref(),
-            "/var/lib/seoh/klt-bos-instance-id.json",
+            &instance_id_path,
             runtime_token_for_registry,
         );
         // ⚠️ `build_registry_registration_config_from_env` 固定产出 `tls_config: None`,
@@ -548,7 +553,11 @@ async fn deregister_from_registry(
         .instance_id_persistence
         .as_ref()
         .map(|p| p.file_path.clone())
-        .unwrap_or_else(|| "/var/lib/seoh/klt-bos-instance-id.json".to_string());
+        .unwrap_or_else(|| {
+            std::env::var("KLT_BOS_INSTANCE_ID_PATH").unwrap_or_else(|_| {
+                "/var/lib/seoh/klt-bos-instance-id.json".to_string()
+            })
+        });
     let instance_id = match std::fs::read_to_string(&persist_path) {
         Ok(s) => match serde_json::from_str::<serde_json::Value>(&s) {
             Ok(v) => v

+ 2 - 1
src/modules/account/src/handlers/import_batch.rs

@@ -947,11 +947,12 @@ async fn list_batch_customer_names(
     for r in rows {
         phs.push(p.push(Value::String(r.batch_id.clone())));
     }
+    // batch_id 库列为 BIGINT,UDS 入参按字符串占位 ⇒ 两侧统一 ::text,避免 `bigint = text`(13001)。
     let sql = format!(
         "SELECT r.batch_id::text AS batch_id, r.raw_json, c.customer_name \
          FROM import_batch_row r \
          LEFT JOIN customer c ON c.customer_id = r.business_id \
-         WHERE r.batch_id IN ({})",
+         WHERE r.batch_id::text IN ({})",
         phs.join(", ")
     );
     #[derive(Deserialize)]