Эх сурвалжийг харах

单位招聘热门关键字

linwu 1 жил өмнө
parent
commit
00cfa58375

+ 15 - 9
app/Admin/Controllers/System/HotwordController.php

@@ -109,6 +109,11 @@ class HotwordController extends Controller
             $actions->disableView();
             $actions->disableView();
         });
         });
 
 
+        $grid->filter(function ($filter) {
+            $type_option = ['' => '不限', '1' => '职位搜索', '2' => '企业搜索', '3' => '个人简历搜索', '4' => '资讯搜索'];
+            $filter->equal('type', '类型')->select($type_option)->default('');
+        });
+
         if (Admin::user()->can('system_hotword_delete')) {
         if (Admin::user()->can('system_hotword_delete')) {
             $grid->tools(function ($tools) {
             $grid->tools(function ($tools) {
                 $tools->batch(function ($batch) {
                 $tools->batch(function ($batch) {
@@ -181,10 +186,10 @@ class HotwordController extends Controller
             'required',
             'required',
         ])->setWidth(3)->setMustMark();
         ])->setWidth(3)->setMustMark();
         //搜索类型
         //搜索类型
-        $type_arr = ['1'=>'职位搜索','2'=>'企业搜索','3'=>'个人简历搜索','4'=>'资讯搜索'];
+        $type_arr = ['1' => '职位搜索', '2' => '企业搜索', '3' => '个人简历搜索', '4' => '资讯搜索'];
         $form->select('type', '搜索类型')
         $form->select('type', '搜索类型')
             ->options($type_arr)
             ->options($type_arr)
-            ->rules('required', array('required'=>'请选择搜索类型。'))
+            ->rules('required', ['required' => '请选择搜索类型。'])
             ->setWidth(3)
             ->setWidth(3)
             ->setMustMark();
             ->setMustMark();
         $form->number('w_hot', '搜索次数')->min(0)->default(0);
         $form->number('w_hot', '搜索次数')->min(0)->default(0);
@@ -199,17 +204,17 @@ class HotwordController extends Controller
             'required',
             'required',
         ])->setWidth(3)->setMustMark();
         ])->setWidth(3)->setMustMark();
         //搜索类型
         //搜索类型
-        $type_arr = ['1'=>'职位搜索','2'=>'企业搜索','3'=>'个人简历搜索','4'=>'资讯搜索'];
+        $type_arr = ['1' => '职位搜索', '2' => '企业搜索', '3' => '个人简历搜索', '4' => '资讯搜索'];
         $form->select('type', '搜索类型')
         $form->select('type', '搜索类型')
-             ->options($type_arr)
-             ->default(key($type_arr))
-             ->rules('required', array('required'=>'请选择搜索类型。'))
-             ->setWidth(3)
-             ->setMustMark();
+            ->options($type_arr)
+            ->default(key($type_arr))
+            ->rules('required', ['required' => '请选择搜索类型。'])
+            ->setWidth(3)
+            ->setMustMark();
 
 
         $form->number('w_hot', '搜索次数')->min(0)->default(0);
         $form->number('w_hot', '搜索次数')->min(0)->default(0);
         $form->number('list_order', '显示排序')->min(0)->default(0)->help('(越大越靠前)');
         $form->number('list_order', '显示排序')->min(0)->default(0)->help('(越大越靠前)');
-       
+
         return $form;
         return $form;
     }
     }
 
 
@@ -222,6 +227,7 @@ class HotwordController extends Controller
     {
     {
         return $this->createForm()->store();
         return $this->createForm()->store();
     }
     }
+
     /**
     /**
      * Update the specified resource in storage.
      * Update the specified resource in storage.
      *
      *

+ 5 - 0
app/Http/Controllers/Web/Content/ArticleController.php

@@ -96,6 +96,11 @@ class ArticleController extends WebBaseController
         $recommend_articles = $this->articleService->getPropertyArticles($recommend, $other_num); //推荐资讯
         $recommend_articles = $this->articleService->getPropertyArticles($recommend, $other_num); //推荐资讯
         $bread              = $this->articleCategoryService->getBread($info['id']);
         $bread              = $this->articleCategoryService->getBread($info['id']);
 
 
+        //搜索关键字
+        if ($key) {
+            $this->hotWordService->searchHostWords($key, 4);
+        }
+
         //获取后台职场资讯名称
         //获取后台职场资讯名称
         $where        = [
         $where        = [
             'alias'     => 'AIX_top',
             'alias'     => 'AIX_top',

+ 35 - 25
app/Services/Common/HotWordService.php

@@ -5,10 +5,12 @@
  * Date: 2018/12/4
  * Date: 2018/12/4
  * Time: 10:23
  * Time: 10:23
  */
  */
+
 namespace App\Services\Common;
 namespace App\Services\Common;
 
 
 use App\Repositories\HotWordRepository;
 use App\Repositories\HotWordRepository;
 use App\Repositories\MemberHotwordRepository;
 use App\Repositories\MemberHotwordRepository;
+
 //use Illuminate\Support\Facades\Cache;
 //use Illuminate\Support\Facades\Cache;
 
 
 class HotWordService
 class HotWordService
@@ -22,55 +24,63 @@ class HotWordService
      */
      */
     public function __construct(HotWordRepository $hotWordRepository, MemberHotwordRepository $memberHotwordRepository)
     public function __construct(HotWordRepository $hotWordRepository, MemberHotwordRepository $memberHotwordRepository)
     {
     {
-        $this->hotWordRepository = $hotWordRepository;
+        $this->hotWordRepository       = $hotWordRepository;
         $this->memberHotwordRepository = $memberHotwordRepository;
         $this->memberHotwordRepository = $memberHotwordRepository;
     }
     }
+
     public function getHotWord($key, $type = 1)
     public function getHotWord($key, $type = 1)
     {
     {
-        $where[] = array(
-            'w_word', 'like', '%'.$key.'%',
-        );
-        $where[] = array('type','=',$type);
-        $order = 'list_order desc,w_hot desc';
-        $lists = $this->hotWordRepository->getHotWords($where, $order);
+        $where[] = [
+            'w_word', 'like', '%' . $key . '%',
+        ];
+        $where[] = ['type', '=', $type];
+        $order   = 'list_order desc,w_hot desc';
+        $lists   = $this->hotWordRepository->getHotWords($where, $order);
         //修改热门关键字记录
         //修改热门关键字记录
         $word_rst = $this->hotWordRepository->setInc($key, $type);
         $word_rst = $this->hotWordRepository->setInc($key, $type);
         if ($lists->toArray()) {
         if ($lists->toArray()) {
-            return array('key'=>$key,'list'=>$lists);
+            return ['key' => $key, 'list' => $lists];
         }
         }
         return false;
         return false;
     }
     }
+
     public function setMemberHotword($key, $type = 1)
     public function setMemberHotword($key, $type = 1)
     {
     {
-        $user = array(
+        $user = [
             'utype' => 0,
             'utype' => 0,
-            'uid'   => 0
-        );
+            'uid'   => 0,
+        ];
         if (auth('web-member')->check()) {
         if (auth('web-member')->check()) {
-            $user = array(
+            $user = [
                 'utype' => 2,
                 'utype' => 2,
-                'uid'   => auth('web-member')->user()->id
-            );
+                'uid'   => auth('web-member')->user()->id,
+            ];
         } elseif (auth('web-company')->check()) {
         } elseif (auth('web-company')->check()) {
-            $user = array(
+            $user = [
                 'utype' => 1,
                 'utype' => 1,
-                'uid'   => auth('web-company')->user()->id
-            );
+                'uid'   => auth('web-company')->user()->id,
+            ];
         }
         }
-        $where[] = array('w_word', 'like', '%'.$key.'%',);
-        $where[] = array('type','=',$type);
-        $where[] = array('utype','=',$user['utype']);
-        $where[] = array('uid','=',$user['uid']);
-        $order = 'list_order desc,w_hot desc';
-        $lists = $this->memberHotwordRepository->getHotWords($where, $order);
+        $where[] = ['w_word', 'like', '%' . $key . '%',];
+        $where[] = ['type', '=', $type];
+        $where[] = ['utype', '=', $user['utype']];
+        $where[] = ['uid', '=', $user['uid']];
+        $order   = 'list_order desc,w_hot desc';
+        $lists   = $this->memberHotwordRepository->getHotWords($where, $order);
         //修改热门关键字记录
         //修改热门关键字记录
         $word_rst = $this->memberHotwordRepository->setInc($key, $type, $user);
         $word_rst = $this->memberHotwordRepository->setInc($key, $type, $user);
         if ($lists->toArray()) {
         if ($lists->toArray()) {
-            return array('key'=>$key,'list'=>$lists);
+            return ['key' => $key, 'list' => $lists];
         }
         }
     }
     }
-    public function getHotWords($where = array (), $order = 'w_hot desc', $limit = '')
+
+    public function getHotWords($where = [], $order = 'w_hot desc', $limit = '')
     {
     {
         return $this->hotWordRepository->getHotWords($where, $order, $limit);
         return $this->hotWordRepository->getHotWords($where, $order, $limit);
     }
     }
+
+    public function searchHostWords($key, $type = 1)
+    {
+        $this->hotWordRepository->setInc($key, $type);
+    }
 }
 }