ProductAssistUserDao.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\dao\store\product;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\store\product\ProductAssistUser;
  14. class ProductAssistUserDao extends BaseDao
  15. {
  16. protected function getModel(): string
  17. {
  18. return ProductAssistUser::class;
  19. }
  20. /**
  21. * 获取用户数量及列表
  22. *
  23. * 本函数用于查询数据库中的用户总数,并返回最近创建的用户列表。
  24. * 列表默认包含最近创建的3个用户,但可以通过传入参数$limit来调整返回的用户数量。
  25. *
  26. * @param int $limit 控制返回的用户数量,默认为3。
  27. * @return array 包含两个元素的数组,'count'表示用户总数,'list'表示用户列表。
  28. */
  29. public function userCount(int $limit = 3)
  30. {
  31. // 查询数据库中的用户总数
  32. $count = $this->getModel()::getDB()->count("*");
  33. // 查询最近创建的用户列表,限制返回的数量为$limit,并按创建时间降序排序
  34. $list = $this->getModel()::getDB()->limit($limit)->order('create_time DESC')->select();
  35. // 返回包含用户总数和用户列表的数组
  36. return compact('count','list');
  37. }
  38. }