Jelajahi Sumber

非ABCD开头不插入

曹鹤洋 2 tahun lalu
induk
melakukan
7487431c1d
1 mengubah file dengan 16 tambahan dan 0 penghapusan
  1. 16 0
      application/api/controller/Index.php

+ 16 - 0
application/api/controller/Index.php

@@ -44,6 +44,22 @@ class Index extends Api
                     break;
                 }
             }
+            //判断数据是否是ABCD开头
+            preg_match('/^[A,B,C,D]/', $res['data_txt_name'], $matches);
+            if(!count($matches)){
+                Log::init([
+                    // 日志记录方式,支持 file socket
+                    'type'  =>  'File',//type的值为test时临时关闭日志写入
+                    //日志保存目录
+                    'path'  =>  APP_PATH.'../runtime/log/notABCD/',
+                    //单个日志文件的大小限制,超过后会自动记录到第二个文件
+                    'file_size'     =>2097152,
+                    //日志的时间格式,默认是` c `
+                    'time_format'   =>'c'
+                ]);
+                Log::record($req);
+                return $this->success('数据文件不以A、B、C、D开头,已记录日志',$req,0);
+            }
             foreach($rows as $k=>$v){
                 preg_match('/样品名称/', $v, $matches);
                 if(count($matches)){