15313670163 2 месяцев назад
Родитель
Сommit
c4e7cae174
3 измененных файлов с 19 добавлено и 19 удалено
  1. 6 18
      app/JsonRpc/WebsiteService.php
  2. 1 1
      runtime/hyperf.pid
  3. 12 0
      runtime/logs/hyperf.log

+ 6 - 18
app/JsonRpc/WebsiteService.php

@@ -1200,14 +1200,8 @@ class WebsiteService implements WebsiteServiceInterface
                         $result = WebsiteTemplateInfo::insertGetId($data);
                     } catch (\Exception $e) {
                         if ($e->getCode() == 22001) {
-                            $errorMessage = $e->getMessage();
-                            $fieldName = '';
-                    
-                            // 假设错误消息格式为 "Data too long for column 'column_name' at row 1"
-                            if (preg_match("/Data too long for column '([^']+)'/", $errorMessage, $matches)) {
-                                $fieldName = $matches[1];
-                            }
-                            return Result::error("字段 '$fieldName' 超出了长度限制");
+                            $errorMessage = $e->getMessage();                    
+                            return Result::error("请检查表单,某个字段超出了长度限制!");
                         } else {
                             // 处理其他类型的数据库错误
                             return Result::error("插入操作失败: " . $e->getMessage());
@@ -1284,19 +1278,13 @@ class WebsiteService implements WebsiteServiceInterface
                     $result = WebsiteTemplateInfo::where($where)->update($data);
                 } catch (\Exception $e) {
                     if ($e->getCode() == 22001) {
-                        $errorMessage = $e->getMessage();
-                        $fieldName = '';
-                
-                        // 假设错误消息格式为 "Data too long for column 'column_name' at row 1"
-                        if (preg_match("/Data too long for column '([^']+)'/", $errorMessage, $matches)) {
-                            $fieldName = $matches[1];
-                        }
-                        return Result::error("字段 '$fieldName' 超出了长度限制");
+                        $errorMessage = $e->getMessage();                    
+                        return Result::error("请检查表单,某个字段超出了长度限制!");
                     } else {
                         // 处理其他类型的数据库错误
-                        return Result::error("插入操作失败: " . $e->getMessage());
+                        return Result::error("修改操作失败: " . $e->getMessage());
                     }
-                    return Result::error("添加失败!", 0);
+                    return Result::error("修改失败!", 0);
                 }
             }else{
                 return Result::error("请先选择首页和底部导航详情页!",0);

+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-5128
+8851

+ 12 - 0
runtime/logs/hyperf.log

@@ -3555,3 +3555,15 @@
 [2025-02-07T13:45:31.126817+08:00] sql.INFO: [16.24] select `type` from `link` where `website_id` = '1' [] []
 [2025-02-07T13:45:31.144671+08:00] sql.INFO: [17.3] select * from `website_template_info` where `website_id` = '1' limit 1 [] []
 [2025-02-07T13:45:31.162857+08:00] sql.INFO: [17.47] insert into `website_template_info` (`website_id`, `page_type`, `statement`, `organizer`, `copyright_information`, `contact_number`, `company_address`, `project_logo`, `project_name`, `project_url`, `company_logo`, `company_name`, `company_url`, `record_number`, `record_number_url`, `icp_number`, `icp_number_url`, `customer_service_qq`, `communications`, `action_id`) values ('1', '["1","7","2","5","6"]', '不是一个人的王者,而是团队的荣耀!', '王者荣耀', '敌方还有五秒到达战场!全军出击!', '', '王者峡谷上半野区的蓝心草(在蓝buff旁边的新出的草丛中)', 'Timi', '排位赛;站至巅峰!', '请选择你要去往的分路!', '匹配赛', '召集模式;我很急!', '我跟你说这成吉思汗优化的不行啊!', '666', '请文明发言', '您已被举报!您已被举报!您已被举报!您已被举报!您已被举报!您已被举报!您已被举报!您已被举报!您已', '您已被禁言!', '这人机队友也太坑了吧!真的无语住了!', '为什么不去推塔呀?家都不要了?高地不守就算了还去送人头?是嫌输的不够快吗?!!!', '1') [] []
+[2025-02-07T14:23:17.109780+08:00] sql.INFO: [69.63] select * from `website` where `website`.`id` = '1' limit 1 [] []
+[2025-02-07T14:23:17.143133+08:00] sql.INFO: [15.68] select `type` from `footer_category` where `website_id` = '1' [] []
+[2025-02-07T14:23:17.163818+08:00] sql.INFO: [15.59] select `type` from `link` where `website_id` = '1' [] []
+[2025-02-07T14:23:17.185311+08:00] sql.INFO: [17.3] select * from `website_template_info` where `website_id` = '1' limit 1 [] []
+[2025-02-07T14:23:23.549334+08:00] sql.INFO: [17.55] select * from `website` where `website`.`id` = '2' limit 1 [] []
+[2025-02-07T14:23:23.567120+08:00] sql.INFO: [16.86] select `type` from `footer_category` where `website_id` = '2' [] []
+[2025-02-07T14:23:23.583311+08:00] sql.INFO: [15.6] select `type` from `link` where `website_id` = '2' [] []
+[2025-02-07T14:23:23.601266+08:00] sql.INFO: [17.42] select * from `website_template_info` where `website_id` = '2' limit 1 [] []
+[2025-02-07T14:25:43.132172+08:00] sql.INFO: [63.47] select * from `website` where `website`.`id` = '2' limit 1 [] []
+[2025-02-07T14:25:43.166315+08:00] sql.INFO: [14.89] select `type` from `footer_category` where `website_id` = '2' [] []
+[2025-02-07T14:25:43.183881+08:00] sql.INFO: [13.35] select `type` from `link` where `website_id` = '2' [] []
+[2025-02-07T14:25:43.204491+08:00] sql.INFO: [17.05] select * from `website_template_info` where `website_id` = '2' limit 1 [] []