diff --git a/README.md b/README.md index 665bc61..b2ecc57 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ return [ 'title' => '$like', //可以不写 因为默认是like 'department_name' => '$like', '#department_name' => '#department|$like', - 'created_at' => '#department|preprocess|$halfOpenFilter' //不分顺序。 属于department表,同时进行预处理函数,最后执行左开右闭处理 + 'created_at' => '#department|HalfOpenDate|$halfOpen' //不分顺序。 属于department表,同时进行预处理函数,最后执行左开右闭处理 ] ]; @@ -118,7 +118,7 @@ class OrderModel extends Model | `$in` | whereIn('id', [1, 2, 3]) | | `$notIn` | whereNotIn('id', [1, 2, 3]) | | `$between` | whereBetween('id', [1, 10]) | -| `$halfOpenFilter`| where('id','>=',1)->where('id','<',10) | | +| `$halfOpen`| where('id','>=',1)->where('id','<',10) | | ### 前置处理器 diff --git a/config/filter.php b/config/filter.php index b3327b4..ce29268 100644 --- a/config/filter.php +++ b/config/filter.php @@ -4,6 +4,9 @@ 'default' => '$like', 'rule' => [ - + 'uuid' => 'uuid|$eq', + 'created_at' => 'HalfOpenDate|$halfOpen', + 'department_name' => '$like', + '#department_name' => '#department|$like' ] ]; diff --git a/src/Preprocess/HalfOpenDatePreprocess.php b/src/Preprocess/HalfOpenDatePreprocess.php index bcb5d2b..a5aa2c2 100644 --- a/src/Preprocess/HalfOpenDatePreprocess.php +++ b/src/Preprocess/HalfOpenDatePreprocess.php @@ -12,8 +12,8 @@ public function handle($column, &$param) { $start_at = $param[$column][0]; $end_at = date('Y-m-d', strtotime('+1 day', strtotime($param[$column][1]))); } else { - $start_at = $param[$column]; - $end_at = date('Y-m-d', strtotime('+1 day', strtotime($param[$column]))); + list($start_at, $end_at) = explode(",", $param[$column]); + $end_at = date('Y-m-d', strtotime('+1 day', strtotime($end_at))); } $param[$column] = [$start_at, $end_at]; }