SystemRoleDao.php 900 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\extra\dao\system;
  3. use app\extra\basic\Dao;
  4. use app\model\system\SystemRole;
  5. class SystemRoleDao extends Dao
  6. {
  7. /**
  8. * 设置模型
  9. * @return string
  10. */
  11. protected function setModel(): string
  12. {
  13. return SystemRole::class;
  14. }
  15. public function getList(array $where,string $field = '*',int $page = 0, int $limit = 0,string $order='id desc')
  16. {
  17. return $this->getModel()->where($where)->field($field)->when($page&&$limit,function($query)use($page,$limit){
  18. $query->page($page,$limit);
  19. })->select();
  20. }
  21. /**
  22. * 获取权限id
  23. * @param array $rules
  24. * @return array
  25. */
  26. public function getRoleIds(array $rules)
  27. {
  28. $rules = $this->dao->getColumn([['id', 'IN', $rules], ['status', '=', '1']], 'rules', 'id');
  29. return array_unique(explode(',', implode(',', $rules)));
  30. }
  31. }