|
|
@@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Log;
|
|
|
use App\Tools\Tools;
|
|
|
use App\Models\WbwTemplate;
|
|
|
use App\Models\PageNumber;
|
|
|
+use App\Tools\PaliSearch;
|
|
|
|
|
|
|
|
|
class SearchController extends Controller
|
|
|
@@ -34,7 +35,7 @@ class SearchController extends Controller
|
|
|
if(substr($key,0,4) === 'para' || in_array(substr($key,0,1),$pageHead)){
|
|
|
return $this->page($request);
|
|
|
}else{
|
|
|
- return $this->pali($request);
|
|
|
+ return $this->pali_rpc($request);
|
|
|
}
|
|
|
break;
|
|
|
case 'page':
|
|
|
@@ -167,6 +168,30 @@ class SearchController extends Controller
|
|
|
|
|
|
return $this->ok(["rows"=>SearchResource::collection($result),"count"=>$resultCount[0]->co]);
|
|
|
}
|
|
|
+ public function pali_rpc(Request $request)
|
|
|
+ {
|
|
|
+ //
|
|
|
+ $bookId = [];
|
|
|
+ if($request->has('book')){
|
|
|
+ $bookId = [(int)$request->get('book')];
|
|
|
+ }else if($request->has('tags')){
|
|
|
+ //查询搜索范围
|
|
|
+ //查询搜索范围
|
|
|
+ $tagItems = explode(';',$request->get('tags'));
|
|
|
+
|
|
|
+ foreach ($tagItems as $tagItem) {
|
|
|
+ $bookId = array_merge($bookId,$this->getBookIdByTags(explode(',',$tagItem)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $key = explode(';',$request->get('key')) ;
|
|
|
+ $limit = $request->get('limit',10);
|
|
|
+ $offset = $request->get('offset',0);
|
|
|
+ $matchMode = $request->get('match','case');
|
|
|
+ $result = PaliSearch::search($key,$bookId,$matchMode,$offset,$limit);
|
|
|
+ return $this->ok(["rows"=>SearchResource::collection(collect($result['rows'])),"count"=>$result['total']]);
|
|
|
+ }
|
|
|
+
|
|
|
public function page(Request $request)
|
|
|
{
|
|
|
//
|
|
|
@@ -220,10 +245,11 @@ class SearchController extends Controller
|
|
|
$searchBooks = [];
|
|
|
$queryBookId = '';
|
|
|
|
|
|
+ $bookId = [];
|
|
|
if($request->has('tags')){
|
|
|
//查询搜索范围
|
|
|
$tagItems = explode(';',$request->get('tags'));
|
|
|
- $bookId = [];
|
|
|
+
|
|
|
foreach ($tagItems as $tagItem) {
|
|
|
# code...
|
|
|
$bookId = array_merge($bookId,$this->getBookIdByTags(explode(',',$tagItem)));
|
|
|
@@ -239,10 +265,11 @@ class SearchController extends Controller
|
|
|
$queryWhere = "type='.ctl.' AND word = ?";
|
|
|
$query = "SELECT pcd_book_id, count(*) as co FROM wbw_templates WHERE {$queryWhere} {$queryBookId} GROUP BY pcd_book_id ORDER BY co DESC;";
|
|
|
$result = DB::select($query, [$key]);
|
|
|
+
|
|
|
}else{
|
|
|
- $queryWhere = $this->getQueryWhere($key,$request->get('match','case'));
|
|
|
- $query = "SELECT pcd_book_id, count(*) as co FROM fts_texts WHERE {$queryWhere['query']} {$queryBookId} GROUP BY pcd_book_id ORDER BY co DESC;";
|
|
|
- $result = DB::select($query, $queryWhere['param']);
|
|
|
+ $rpc_result = PaliSearch::book_list(explode(';',$key) ,$bookId,
|
|
|
+ $request->get('match','case'));
|
|
|
+ $result = collect($rpc_result['rows']);
|
|
|
}
|
|
|
break;
|
|
|
case 'page':
|