ThemeModuleDao.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\diy;
  12. use app\dao\BaseDao;
  13. use app\model\diy\ThemeModule;
  14. class ThemeModuleDao extends BaseDao
  15. {
  16. protected function setModel(): string
  17. {
  18. return ThemeModule::class;
  19. }
  20. /**
  21. * 条件查询模型对象
  22. * @param $where
  23. * @return \crmeb\basic\BaseModel
  24. */
  25. public function getConditionModel($where)
  26. {
  27. return $this->getModel()
  28. ->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) {
  29. $query->where('type', $where['type']);
  30. });
  31. }
  32. /**
  33. * 获取组件列表
  34. * @param $where
  35. * @param $field
  36. * @param int $page
  37. * @param int $limit
  38. * @param string $order
  39. * @return array
  40. * @throws \think\db\exception\DataNotFoundException
  41. * @throws \think\db\exception\DbException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. */
  44. public function themeModuleList($where, $field, $page = 0, $limit = 0, $order = 'id desc')
  45. {
  46. return $this->getConditionModel($where)
  47. ->field($field)
  48. ->order($order)
  49. ->when($page != 0, function ($query) use ($page, $limit) {
  50. $query->page($page, $limit);
  51. })->select()->toArray();
  52. }
  53. /**
  54. * 获取组件数量
  55. * @param $where
  56. * @return int
  57. */
  58. public function themeModuleCount($where)
  59. {
  60. return $this->getConditionModel($where)->count();
  61. }
  62. }