فهرست منبع

feat: policy search json filter

jiangzixin 1 سال پیش
والد
کامیت
2fd399a5d7
1فایلهای تغییر یافته به همراه7 افزوده شده و 3 حذف شده
  1. 7 3
      server/api/modules/v1/controllers/PolicyController.php

+ 7 - 3
server/api/modules/v1/controllers/PolicyController.php

@@ -42,12 +42,16 @@ class PolicyController extends Controller {
             $arr = [];
        
             foreach ($params as $key=>$value) {
-                if($key == 'page' || $key == 'page_no'){
+                if($key == 'page_size' || $key == 'page_no'){
+                    continue;
+                }
+                if ($key == 'cengci') {
+                    $query->andWhere(new \yii\db\Expression('FIND_IN_SET("'.$value.'", cengci)'));
                     continue;
                 }
     		    if($value){
-    		         $fd = $key.'_' . $value;
-    		         $query->orWhere(new \yii\db\Expression('FIND_IN_SET("'.$fd.'", filter)'));
+                    $expression = 'JSON_CONTAINS(JSON_EXTRACT(`dd_policy`.`filter`, "$.' . $key . '"), JSON_ARRAY("' . $value. '"))';
+    		         $query->andWhere(new \yii\db\Expression($expression));
     		    }
     		}
         }