getAllData([ ['uid', '=', $this->mid] ], 'id,content', 'sort desc'); return sendSuccessArray([ // 热门搜索列表 'search_hot_list' => $search_hot_list ]); } /** * 获取历史搜索 * @date 2022-11-18 */ public function listHistorySearch() { $search_model = new IntegralSearchHistory(); // 获取商城历史搜索 $search_history_list = $search_model->getAllData([ ['uid', '=', $this->mid], ['user_id', '=', $this->userId], ], 'id,content', 'update_time desc', '10'); return sendSuccessArray([ // 历史搜索列表 'search_history_list' => $search_history_list ]); } /** * 添加历史搜索 * @param string $keyword 关键字 * @date 2022-11-18 */ public function insertHistorySearch($keyword) { $search_model = new IntegralSearchHistory(); // 添加历史搜索 $data = [ 'uid' => $this->mid, 'user_agent' => $this->userAgent, 'user_id' => $this->userId, 'content' => $keyword ]; $res = $search_model->updateSearch($data); if (!$res) { return sendErrorArray(3001, '添加失败'); } return sendSuccessArray(); } /** * 清空历史搜索 * @date 2022-11-18 */ public function deleteAllHistorySearch() { $search_model = new IntegralSearchHistory(); // 删除商城历史搜索 $res = $search_model->dataDestory([ ['uid', '=', $this->mid], ['user_id', '=', $this->userId], ]); if (!$res) { return sendErrorArray(3001, '删除失败'); } return sendSuccessArray(); } }