ArticleLists.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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\adminapi\lists\article;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\lists\ListsSearchInterface;
  17. use app\common\lists\ListsSortInterface;
  18. use app\common\model\article\Article;
  19. /**
  20. * 资讯列表
  21. * Class ArticleLists
  22. * @package app\adminapi\lists\article
  23. */
  24. class ArticleLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
  25. {
  26. /**
  27. * @notes 设置搜索条件
  28. * @return array
  29. * @author heshihu
  30. * @date 2022/2/8 18:39
  31. */
  32. public function setSearch(): array
  33. {
  34. return [
  35. '%like%' => ['title'],
  36. '=' => ['cid', 'is_show']
  37. ];
  38. }
  39. /**
  40. * @notes 设置支持排序字段
  41. * @return array
  42. * @author heshihu
  43. * @date 2022/2/9 15:11
  44. */
  45. public function setSortFields(): array
  46. {
  47. return ['create_time' => 'create_time', 'id' => 'id'];
  48. }
  49. /**
  50. * @notes 设置默认排序
  51. * @return array
  52. * @author heshihu
  53. * @date 2022/2/9 15:08
  54. */
  55. public function setDefaultOrder(): array
  56. {
  57. return ['sort' => 'desc', 'id' => 'desc'];
  58. }
  59. /**
  60. * @notes 获取管理列表
  61. * @return array
  62. * @author heshihu
  63. * @date 2022/2/21 17:11
  64. */
  65. public function lists(): array
  66. {
  67. $ArticleLists = Article::where($this->searchWhere)
  68. ->append(['cate_name', 'click'])
  69. ->limit($this->limitOffset, $this->limitLength)
  70. ->order($this->sortOrder)
  71. ->select()
  72. ->toArray();
  73. return $ArticleLists;
  74. }
  75. /**
  76. * @notes 获取数量
  77. * @return int
  78. * @author heshihu
  79. * @date 2022/2/9 15:12
  80. */
  81. public function count(): int
  82. {
  83. return Article::where($this->searchWhere)->count();
  84. }
  85. public function extend()
  86. {
  87. return [];
  88. }
  89. }