From d766d1220964890e95a93f3008f306a019bd2c78 Mon Sep 17 00:00:00 2001 From: xiaodong Date: Tue, 8 Sep 2026 16:50:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E6=96=87=E6=A0=8F=E7=9B=AE=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E8=8B=B1=E6=96=87=E6=A0=8F=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/CategoryService.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/service/CategoryService.php b/app/service/CategoryService.php index fec021f..9af0270 100644 --- a/app/service/CategoryService.php +++ b/app/service/CategoryService.php @@ -328,6 +328,7 @@ class CategoryService $Category = new Category(); $prefix = env('database.prefix'); $cateTable = $prefix . 'category'; + $res = Db::query("SHOW TABLE STATUS WHERE NAME = '$cateTable'"); $maxId = $res[0]['Auto_increment']; $targetIds = range($maxId, $maxId + $cateCount - 1); @@ -339,16 +340,22 @@ class CategoryService unset($val['update_time']); $val['website_id'] = $site; $val['category_map'] = $val['id']; - $val['lang_map'] = $map[$val['lang']]; + $val['lang_map'] = $val['lang']; $val['lang'] = $lang; if ($val['parent_id'] != 0) { $pathArr = explode('-', $val['path']); $tmpPath = ''; array_pop($pathArr); foreach ($pathArr as $path) { + if (!isset($map[$path])) { + throw new \Exception("栏目路径映射失败: 找不到源ID {$path} 的映射"); + } $tmpPath .= $map[$path] . '-'; } $val['path'] = $tmpPath; + if (!isset($map[$val['parent_id']])) { + throw new \Exception("栏目父级映射失败: 找不到源ID {$val['parent_id']} 的映射"); + } $val['parent_id'] = $map[$val['parent_id']]; } // 美化url