SystemThemePageLists.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\lists\theme;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\
  22. {
  23. model\SystemTheme,
  24. enum\ThemePageEnum,
  25. lists\ListsSearchInterface,
  26. };
  27. /**
  28. * 系统主题列表页
  29. * Class SystemThemePageLists
  30. * @package app\adminapi\lists\theme
  31. */
  32. class SystemThemePageLists extends BaseAdminDataLists implements ListsSearchInterface
  33. {
  34. /**
  35. * @notes 搜索条件
  36. * @return array
  37. * @author cjhao
  38. * @date 2021/8/5 10:24
  39. */
  40. public function setSearch(): array
  41. {
  42. return [
  43. '%like%' => ['name']
  44. ];
  45. }
  46. /**
  47. * @notes 页面列表
  48. * @return array
  49. * @author cjhao
  50. * @date 2021/8/5 10:24
  51. */
  52. public function lists(): array
  53. {
  54. //todo 现在系统主题只有主页,暂时用模型关联
  55. $lists = SystemTheme::with(['theme_page' => function($query){
  56. $query->where(['type'=>ThemePageEnum::TYPE_HOME])->withField(['id,theme_id,name,content,common']);
  57. }])->field('id,name,image,create_time')
  58. ->where($this->searchWhere)
  59. ->limit($this->limitOffset, $this->limitLength)
  60. // ->order(['id'=>'desc'])
  61. ->select()
  62. ->toArray();
  63. return $lists;
  64. }
  65. /**
  66. * @notes 查看页面数量
  67. * @return int
  68. * @author cjhao
  69. * @date 2021/8/5 10:25
  70. */
  71. public function count(): int
  72. {
  73. return SystemTheme::where($this->searchWhere)->count();
  74. }
  75. }