Просмотр исходного кода

过滤所有资产名保存时的左右两侧异常符号

lh 1 месяц назад
Родитель
Сommit
2b20272047
2 измененных файлов с 4 добавлено и 2 удалено
  1. 3 1
      app/Services/Anime/AnimeService.php
  2. 1 1
      app/Services/DeepSeek/DeepSeekService.php

+ 3 - 1
app/Services/Anime/AnimeService.php

@@ -6155,6 +6155,7 @@ class AnimeService
         $cpid = Site::getCpid();
         $product_name = trim(getProp($data, 'product_name'));
         if (!$product_name) Utils::throwError('20003:名称不能为空');
+        $product_name = preg_replace('/^[\s*\[\]【】[]{}{}\x{3000}]+|[\s*\[\]【】[]{}{}\x{3000}]+$/u', '', $product_name);
         // $exists_id = DB::table('mp_products')->where('cpid', $cpid)->where('type', 1)->where('product_name', $product_name)->where('is_deleted', 0)->value('id');
         // if ($exists_id) Utils::throwError('20003:名称不能重复,请修改');
         $url = trim(getProp($data, 'url'));
@@ -6247,6 +6248,7 @@ class AnimeService
         // 名称
         $product_name = trim(getProp($data, 'product_name'));
         if ($product_name) {
+            $product_name = preg_replace('/^[\s*\[\]【】[]{}{}\x{3000}]+|[\s*\[\]【】[]{}{}\x{3000}]+$/u', '', $product_name);
             $updateData['product_name'] = $product_name;
         }
 
@@ -7015,7 +7017,7 @@ class AnimeService
                     }
 
                     // 处理product_name两边的符号
-                    $product_name = preg_replace('/^[\s*()()\[\]【】[]{}{}\x{3000}]+|[\s*()()\[\]【】[]{}{}\x{3000}]+$/u', '', $product_name);
+                    $product_name = preg_replace('/^[\s*\[\]【】[]{}{}\x{3000}]+|[\s*\[\]【】[]{}{}\x{3000}]+$/u', '', $product_name);
                     
                     // 直接插入新资产到 mp_products 表(parent_id 指向对应类型的根文件夹)
                     $product_id = DB::table('mp_products')->insertGetId([

+ 1 - 1
app/Services/DeepSeek/DeepSeekService.php

@@ -7530,7 +7530,7 @@ Q版卡通风格,头大身小,造型圆润可爱,线条简单,色彩明
                 $product_id = $item->product_id;
                 $product_name = $item->product_name;
                 // 处理product_name两边的符号
-                $product_name = preg_replace('/^[\s*()()\[\]【】[]{}{}\x{3000}]+|[\s*()()\[\]【】[]{}{}\x{3000}]+$/u', '', $product_name);
+                $product_name = preg_replace('/^[\s*\[\]【】[]{}{}\x{3000}]+|[\s*\[\]【】[]{}{}\x{3000}]+$/u', '', $product_name);
                 
                 if (!isset($productMap[$product_id])) {
                     $productMap[$product_id] = [