AuthGroup.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace Ycbl\AdminAuth\Dao;
  3. use Hyperf\Contract\ConfigInterface;
  4. use Psr\Container\ContainerInterface;
  5. use Ycbl\AdminAuth\Model\AuthGroup as Model;
  6. class AuthGroup
  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'));
  15. }
  16. public function getGroupsById($ids)
  17. {
  18. return $this->model::query()->whereIn('id', $ids)->get();
  19. }
  20. public function getGroupsByPid($ids)
  21. {
  22. return $this->model::query()->whereIn('pid', $ids)->get();
  23. }
  24. public function getEnableGroupsById($ids)
  25. {
  26. return $this->model::query()->select('id', 'pid', 'name', 'rules')
  27. ->whereIn('id', $ids)
  28. ->where('status', '=', '1')
  29. ->get();
  30. }
  31. public function getEnableGroups()
  32. {
  33. return $this->model::query()
  34. ->where('status', '=', '1')
  35. ->get();
  36. }
  37. public function getOneGroupsById($id)
  38. {
  39. return $this->model::query()->where('id', $id)->first();
  40. }
  41. public function insertGroup($data)
  42. {
  43. return $this->model::query()->insert($data);
  44. }
  45. public function updateGroupById($id, $data)
  46. {
  47. return $this->model::query()->where('id', $id)->update($data);
  48. }
  49. public function deleteGroup($ids)
  50. {
  51. return $this->model::query()->whereIn('id',$ids)->delete();
  52. }
  53. }