소스 검색

书的范围支持多本书

visuddhinanda 2 년 전
부모
커밋
1338532c74
1개의 변경된 파일10개의 추가작업 그리고 28개의 파일을 삭제
  1. 10 28
      app/Http/Controllers/SearchPaliWbwController.php

+ 10 - 28
app/Http/Controllers/SearchPaliWbwController.php

@@ -22,7 +22,9 @@ class SearchPaliWbwController extends Controller
         $bookId = [];
         $search = new SearchController;
         if($request->has('book')){
-            $bookId = [(int)$request->get('book')];
+            foreach (explode(',',$request->get('book')) as $key => $id) {
+                $bookId[] = (int)$id;
+            }
         }else if($request->has('tags')){
             //查询搜索范围
             //查询搜索范围
@@ -34,21 +36,10 @@ class SearchPaliWbwController extends Controller
         }
 
         $keyWords = explode(',',$request->get('key'));
-        switch ($request->get('view')) {
-            case 'pali':
-                $table = WbwTemplate::whereIn('real',$keyWords)
-                                        ->groupBy(['book','paragraph'])
-                                        ->selectRaw('book,paragraph,sum(weight) as rank');
-                break;
-            case 'para':
-                $table = WbwTemplate::whereIn('word',$keyWords)
-                                    ->groupBy(['book','paragraph'])
-                                    ->selectRaw('book,paragraph');
-                break;
-            default:
-                return $this->error('unknown param view='.$request->get('view'),500,500);
-                break;
-        }
+        $table = WbwTemplate::whereIn('real',$keyWords)
+                            ->groupBy(['book','paragraph'])
+                            ->selectRaw('book,paragraph,sum(weight) as rank');
+
         $placeholderWord = implode(",",array_fill(0, count($keyWords), '?')) ;
         $whereWord = "real in ({$placeholderWord})";
         $whereBookId = '';
@@ -85,17 +76,8 @@ class SearchPaliWbwController extends Controller
             }
         }
         $keyWords = explode(',',$request->get('key'));
-        switch ($request->get('view')) {
-            case 'pali':
-                $table = WbwTemplate::whereIn('real',$keyWords);
-                break;
-            case 'para':
-                $table = WbwTemplate::whereIn('word',$keyWords);
-                break;
-            default:
-                return $this->error('unknown param view='.$request->get('view'),500,500);
-                break;
-        }
+        $table = WbwTemplate::whereIn('real',$keyWords);
+
         if(count($bookId)>0){
             $table = $table->whereIn('pcd_book_id',$bookId);
         }
@@ -112,7 +94,7 @@ class SearchPaliWbwController extends Controller
      */
     public function store(Request $request)
     {
-
+        return $this->index($request);
     }
 
     /**