CategoryServices.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\services\other;
  12. use app\dao\other\CategoryDao;
  13. use app\services\BaseServices;
  14. /**
  15. * Class CategoryServices
  16. * @package app\services\other
  17. */
  18. class CategoryServices extends BaseServices
  19. {
  20. protected $cacheName = 'crmeb_cate';
  21. /**
  22. * CategoryServices constructor.
  23. * @param CategoryDao $dao
  24. */
  25. public function __construct(CategoryDao $dao)
  26. {
  27. $this->dao = $dao;
  28. }
  29. /**
  30. * 获取分类列表
  31. * @param array $where
  32. * @return array
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\DbException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. */
  37. public function getCateList(array $where = [], array $field = ['*'])
  38. {
  39. [$page, $limit] = $this->getPageValue();
  40. $data = $this->dao->getCateList($where, $page, $limit, $field);
  41. if ($where['owner_id'] == 0) {
  42. array_unshift($data, ['id' => 0, 'name' => '系统话术', 'sort' => 0]);
  43. }
  44. $count = $this->dao->count($where);
  45. return compact('data', 'count');
  46. }
  47. }