LiveRoomDao.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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. * 直播间
  17. * Class LiveRoomDao
  18. * @package app\dao\activity\live
  19. */
  20. class LiveRoomDao extends BaseDao
  21. {
  22. /**
  23. * @return string
  24. * @author xaboy
  25. * @day 2020/7/29
  26. */
  27. protected function setModel(): string
  28. {
  29. return LiveRoom::class;
  30. }
  31. /**
  32. * @param array $where
  33. * @param string $field
  34. * @param array $with
  35. * @param int $page
  36. * @param int $limit
  37. * @return array
  38. * @throws \think\db\exception\DataNotFoundException
  39. * @throws \think\db\exception\DbException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. */
  42. public function getList(array $where, string $field = '*', array $with = [], int $page = 0, int $limit = 0)
  43. {
  44. return $this->search($where)->field($field)->with($with)->page($page, $limit)->order('sort desc,id desc')->select()->toArray();
  45. }
  46. /**
  47. * @param $roomId
  48. * @return array|\think\Model|null
  49. * @throws \think\db\exception\DataNotFoundException
  50. * @throws \think\db\exception\DbException
  51. * @throws \think\db\exception\ModelNotFoundException
  52. */
  53. public function validRoom($roomId)
  54. {
  55. return $this->getModel()->where('id', $roomId)->where('status', 'IN', [0, 2])->where('is_del', 0)->find();
  56. }
  57. public function getRooms(array $roomIds)
  58. {
  59. return $this->search(['room_id' => $roomIds])->column('live_status,id', 'room_id');
  60. }
  61. }