|
@@ -5,10 +5,12 @@
|
|
|
* Date: 2018/12/4
|
|
|
* Time: 10:23
|
|
|
*/
|
|
|
+
|
|
|
namespace App\Services\Common;
|
|
|
|
|
|
use App\Repositories\HotWordRepository;
|
|
|
use App\Repositories\MemberHotwordRepository;
|
|
|
+
|
|
|
//use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
class HotWordService
|
|
@@ -22,55 +24,63 @@ class HotWordService
|
|
|
*/
|
|
|
public function __construct(HotWordRepository $hotWordRepository, MemberHotwordRepository $memberHotwordRepository)
|
|
|
{
|
|
|
- $this->hotWordRepository = $hotWordRepository;
|
|
|
+ $this->hotWordRepository = $hotWordRepository;
|
|
|
$this->memberHotwordRepository = $memberHotwordRepository;
|
|
|
}
|
|
|
+
|
|
|
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);
|
|
|
if ($lists->toArray()) {
|
|
|
- return array('key'=>$key,'list'=>$lists);
|
|
|
+ return ['key' => $key, 'list' => $lists];
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
public function setMemberHotword($key, $type = 1)
|
|
|
{
|
|
|
- $user = array(
|
|
|
+ $user = [
|
|
|
'utype' => 0,
|
|
|
- 'uid' => 0
|
|
|
- );
|
|
|
+ 'uid' => 0,
|
|
|
+ ];
|
|
|
if (auth('web-member')->check()) {
|
|
|
- $user = array(
|
|
|
+ $user = [
|
|
|
'utype' => 2,
|
|
|
- 'uid' => auth('web-member')->user()->id
|
|
|
- );
|
|
|
+ 'uid' => auth('web-member')->user()->id,
|
|
|
+ ];
|
|
|
} elseif (auth('web-company')->check()) {
|
|
|
- $user = array(
|
|
|
+ $user = [
|
|
|
'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);
|
|
|
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);
|
|
|
}
|
|
|
+
|
|
|
+ public function searchHostWords($key, $type = 1)
|
|
|
+ {
|
|
|
+ $this->hotWordRepository->setInc($key, $type);
|
|
|
+ }
|
|
|
}
|