AuthGroupAccess.php 916 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Ycbl\AdminAuth\Dao;
  3. use Hyperf\Contract\ConfigInterface;
  4. use Psr\Container\ContainerInterface;
  5. use Ycbl\AdminAuth\Model\AuthGroupAccess as Model;
  6. class AuthGroupAccess
  7. {
  8. /**
  9. * @var Model
  10. */
  11. protected $model;
  12. public function __construct(ContainerInterface $container, ConfigInterface $config)
  13. {
  14. $this->model = $container->get($config->get('admin_auth.auth_group_access'));
  15. }
  16. public function getUserGroupIds($uid)
  17. {
  18. return $this->model::query()->where('uid', $uid)->pluck('group_id');
  19. }
  20. public function getUsersByGroupId($group_id)
  21. {
  22. return $this->model::query()->whereIn('group_id', $group_id)->get();
  23. }
  24. public function saveAll($data)
  25. {
  26. return $this->model::insert($data);
  27. }
  28. public function deleteByUid($uid)
  29. {
  30. return $this->model::query()->where('uid', $uid)->delete();
  31. }
  32. }