ArticleCateLists.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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\ArticleCate;
  19. /**
  20. * 资讯分类列表
  21. * Class ArticleCateLists
  22. * @package app\adminapi\lists\article
  23. */
  24. class ArticleCateLists 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. }
  36. /**
  37. * @notes 设置支持排序字段
  38. * @return array
  39. * @author heshihu
  40. * @date 2022/2/9 15:11
  41. */
  42. public function setSortFields(): array
  43. {
  44. return ['create_time' => 'create_time', 'id' => 'id'];
  45. }
  46. /**
  47. * @notes 设置默认排序
  48. * @return array
  49. * @author heshihu
  50. * @date 2022/2/9 15:08
  51. */
  52. public function setDefaultOrder(): array
  53. {
  54. return ['sort' => 'desc','id' => 'desc'];
  55. }
  56. /**
  57. * @notes 获取管理列表
  58. * @return array
  59. * @author heshihu
  60. * @date 2022/2/21 17:11
  61. */
  62. public function lists(): array
  63. {
  64. $ArticleCateLists = ArticleCate::where($this->searchWhere)
  65. ->append(['is_show_desc'])
  66. ->limit($this->limitOffset, $this->limitLength)
  67. ->order($this->sortOrder)
  68. ->append(['article_count'])
  69. ->select()
  70. ->toArray();
  71. return $ArticleCateLists;
  72. }
  73. /**
  74. * @notes 获取数量
  75. * @return int
  76. * @author heshihu
  77. * @date 2022/2/9 15:12
  78. */
  79. public function count(): int
  80. {
  81. return ArticleCate::where($this->searchWhere)->count();
  82. }
  83. public function extend()
  84. {
  85. return [];
  86. }
  87. }