Search.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\api\controller;
  15. use app\api\controller\Base;
  16. use think\Db;
  17. use think\Model;
  18. /**
  19. * @title 搜索管理
  20. * @controller Search
  21. * @group member
  22. */
  23. class Search extends Base
  24. {
  25. /**
  26. * @title 搜索推荐(新闻)
  27. * @desc 搜索推荐
  28. * @author QGF
  29. * @url /api/Search/news_search_recommend
  30. * @method GET
  31. * @tag 搜索推荐
  32. * @header name:Authorization require:1 desc:Token
  33. * @return name:-- type:array default:-- desc:搜索推荐词语列表(title:词语名称)
  34. */
  35. public function news_search_recommend(){
  36. //查找新闻标题
  37. $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();
  38. $this->success('获取成功',$list);
  39. }
  40. /**
  41. * @title 搜索历史(新闻)
  42. * @desc 搜索历史
  43. * @author QGF
  44. * @url /api/Search/news_search_history
  45. * @method GET
  46. * @tag 搜索历史
  47. * @header name:Authorization require:0 desc:Token
  48. * @return name:-- type:array default:-- desc:搜索历史词语列表(name:词语名称)
  49. */
  50. public function news_search_history(){
  51. $uid = $this->get_uid();
  52. $keyword_list = Db::name('store_search_keyword')->field('name')->where('user_id',$uid)->where('type',1)->select();
  53. $this->success('获取成功',$keyword_list);
  54. }
  55. /**
  56. * @title 删除搜索历史(新闻)
  57. * @desc 删除搜索历史
  58. * @author QGF
  59. * @url /api/Search/deleted_news_search_history
  60. * @method GET
  61. * @tag 删除搜索历史
  62. * @header name:Authorization require:1 desc:Token
  63. * @return name:-- type:array default:-- desc:搜索历史词语列表(name:词语名称)
  64. */
  65. public function deleted_news_search_history(){
  66. $this->check_login();
  67. $uid = $this->uid;
  68. Db::name('store_search_keyword')->where('user_id',$uid)->where('type',1)->delete();
  69. $this->success('删除成功');
  70. }
  71. /**
  72. * @title 搜索推荐(咨询)
  73. * @desc 搜索推荐
  74. * @author QGF
  75. * @url /api/Search/consult_search_recommend
  76. * @method GET
  77. * @tag 搜索推荐
  78. * @header name:Authorization require:1 desc:Token
  79. * @return name:-- type:array default:-- desc:搜索推荐词语列表(title:词语名称)
  80. */
  81. public function consult_search_recommend(){
  82. //查找新闻标题
  83. $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();
  84. $this->success('获取成功',$list);
  85. }
  86. /**
  87. * @title 搜索历史(咨询)
  88. * @desc 搜索历史
  89. * @author QGF
  90. * @url /api/Search/consult_search_history
  91. * @method GET
  92. * @tag 搜索历史
  93. * @header name:Authorization require:0 desc:Token
  94. * @return name:-- type:array default:-- desc:搜索历史词语列表(name:词语名称)
  95. */
  96. public function consult_search_history(){
  97. $uid = $this->get_uid();
  98. $keyword_list = Db::name('store_search_keyword')->field('name')->where('user_id',$uid)->where('type',2)->select();
  99. $this->success('获取成功',$keyword_list);
  100. }
  101. /**
  102. * @title 删除搜索历史(咨询)
  103. * @desc 删除搜索历史
  104. * @author QGF
  105. * @url /api/Search/deleted_consult_search_history
  106. * @method GET
  107. * @tag 删除搜索历史
  108. * @header name:Authorization require:1 desc:Token
  109. * @return name:-- type:array default:-- desc:搜索历史词语列表(name:词语名称)
  110. */
  111. public function deleted_consult_search_history(){
  112. $this->check_login();
  113. $uid = $this->uid;
  114. Db::name('store_search_keyword')->where('user_id',$uid)->where('type',2)->delete();
  115. $this->success('删除成功');
  116. }
  117. }