123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\api\controller;
- use app\api\controller\Base;
- use think\Db;
- use think\Model;
- /**
- * @title 搜索管理
- * @controller Search
- * @group member
- */
- class Search extends Base
- {
- /**
- * @title 搜索推荐(新闻)
- * @desc 搜索推荐
- * @author QGF
- * @url /api/Search/news_search_recommend
- * @method GET
- * @tag 搜索推荐
- * @header name:Authorization require:1 desc:Token
- * @return name:-- type:array default:-- desc:搜索推荐词语列表(title:词语名称)
- */
- public function news_search_recommend(){
- //查找新闻标题
- $list = Db::name('store_goods')->field('title')->where('status',1)->where('is_deleted',0)->page(1,10)->order(['is_top'=>'desc','sort'=>'desc','id'=>'desc'])->select();
- $this->success('获取成功',$list);
- }
- /**
- * @title 搜索历史(新闻)
- * @desc 搜索历史
- * @author QGF
- * @url /api/Search/news_search_history
- * @method GET
- * @tag 搜索历史
- * @header name:Authorization require:0 desc:Token
- * @return name:-- type:array default:-- desc:搜索历史词语列表(name:词语名称)
- */
- public function news_search_history(){
- $uid = $this->get_uid();
- $keyword_list = Db::name('store_search_keyword')->field('name')->where('user_id',$uid)->where('type',1)->select();
- $this->success('获取成功',$keyword_list);
- }
- /**
- * @title 删除搜索历史(新闻)
- * @desc 删除搜索历史
- * @author QGF
- * @url /api/Search/deleted_news_search_history
- * @method GET
- * @tag 删除搜索历史
- * @header name:Authorization require:1 desc:Token
- * @return name:-- type:array default:-- desc:搜索历史词语列表(name:词语名称)
- */
- public function deleted_news_search_history(){
- $this->check_login();
- $uid = $this->uid;
- Db::name('store_search_keyword')->where('user_id',$uid)->where('type',1)->delete();
- $this->success('删除成功');
- }
- /**
- * @title 搜索推荐(咨询)
- * @desc 搜索推荐
- * @author QGF
- * @url /api/Search/consult_search_recommend
- * @method GET
- * @tag 搜索推荐
- * @header name:Authorization require:1 desc:Token
- * @return name:-- type:array default:-- desc:搜索推荐词语列表(title:词语名称)
- */
- public function consult_search_recommend(){
- //查找新闻标题
- $list = Db::name('store_consult')->field('title')->where('status',1)->where('is_deleted',0)->page(1,10)->order(['is_recommend'=>'desc','sort'=>'desc','id'=>'desc'])->select();
- $this->success('获取成功',$list);
- }
- /**
- * @title 搜索历史(咨询)
- * @desc 搜索历史
- * @author QGF
- * @url /api/Search/consult_search_history
- * @method GET
- * @tag 搜索历史
- * @header name:Authorization require:0 desc:Token
- * @return name:-- type:array default:-- desc:搜索历史词语列表(name:词语名称)
- */
- public function consult_search_history(){
- $uid = $this->get_uid();
- $keyword_list = Db::name('store_search_keyword')->field('name')->where('user_id',$uid)->where('type',2)->select();
- $this->success('获取成功',$keyword_list);
- }
- /**
- * @title 删除搜索历史(咨询)
- * @desc 删除搜索历史
- * @author QGF
- * @url /api/Search/deleted_consult_search_history
- * @method GET
- * @tag 删除搜索历史
- * @header name:Authorization require:1 desc:Token
- * @return name:-- type:array default:-- desc:搜索历史词语列表(name:词语名称)
- */
- public function deleted_consult_search_history(){
- $this->check_login();
- $uid = $this->uid;
- Db::name('store_search_keyword')->where('user_id',$uid)->where('type',2)->delete();
- $this->success('删除成功');
- }
- }
|