SearchLogic.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\logic;
  15. use app\common\logic\BaseLogic;
  16. use app\common\model\HotSearch;
  17. use app\common\service\ConfigService;
  18. /**
  19. * 搜索逻辑
  20. * Class SearchLogic
  21. * @package app\api\logic
  22. */
  23. class SearchLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 热搜列表
  27. * @return array
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. * @author 段誉
  32. * @date 2022/9/23 14:34
  33. */
  34. public static function hotLists()
  35. {
  36. $data = HotSearch::field(['name', 'sort'])
  37. ->order(['sort' => 'desc', 'id' => 'desc'])
  38. ->select()->toArray();
  39. return [
  40. // 功能状态 0-关闭 1-开启
  41. 'status' => ConfigService::get('hot_search', 'status', 0),
  42. // 热门搜索数据
  43. 'data' => $data,
  44. ];
  45. }
  46. }