LiveRoomDao.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. declare (strict_types=1);
  12. namespace app\dao\activity\live;
  13. use app\dao\BaseDao;
  14. use app\model\activity\live\LiveRoom;
  15. /**
  16. * Class LiveRoomDao
  17. * @package app\dao\live
  18. */
  19. class LiveRoomDao extends BaseDao
  20. {
  21. /**
  22. * @return string
  23. * @author xaboy
  24. * @day 2020/7/29
  25. */
  26. protected function setModel(): string
  27. {
  28. return LiveRoom::class;
  29. }
  30. /**
  31. * @param array $where
  32. * @param string $field
  33. * @param int $page
  34. * @param int $limit
  35. * @return array
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\DbException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. */
  40. public function getList(array $where, string $field = '*', array $with = [], int $page, int $limit)
  41. {
  42. return $this->search($where)->field($field)->with($with)->page($page, $limit)->order('sort desc,id desc')->select()->toArray();
  43. }
  44. /**
  45. * @param $roomId
  46. * @return array|\think\Model|null
  47. * @throws \think\db\exception\DataNotFoundException
  48. * @throws \think\db\exception\DbException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. */
  51. public function validRoom($roomId)
  52. {
  53. return $this->getModel()->where('id', $roomId)->where('status', 'IN', [0, 2])->where('is_del', 0)->find();
  54. }
  55. public function getRooms(array $roomIds)
  56. {
  57. return $this->search(['room_id' => $roomIds])->column('live_status,id', 'room_id');
  58. }
  59. }