AdminGroupService.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Services;
  3. use App\Model\AdminGroup;
  4. use App\Model\Admin;
  5. class AdminGroupService
  6. {
  7. public static function getAdminGroupList($page, $len)
  8. {
  9. $data = AdminGroup::getAdminGroupPage($page, $len);
  10. if (!$data) {
  11. return [];
  12. }
  13. // $adminIds = array_column($data, "admin_id");
  14. // $adminData = Admin::getInAll($adminIds);
  15. // $adminIdData = array_column($adminData,null,'id');
  16. foreach ($data as $k => &$v){
  17. $v['status'] = $v['id'] == 1?0:1; // 0 不可删除 1 可以删除
  18. // $v["admin_name"] = $adminIdData[$v["admin_id"]]["name"];
  19. if($v["role"] != "all"){
  20. $v["role"] = json_decode($v['role'],true);
  21. }
  22. }
  23. return $data;
  24. }
  25. // 添加管理员组
  26. public static function add($groupName,$desc,$role,$admin_id)
  27. {
  28. return AdminGroup::add($groupName,$desc,json_encode($role),$admin_id);
  29. }
  30. // 添加管理员组
  31. public static function edit($id,$groupName,$desc,$role)
  32. {
  33. $state = AdminGroup::edit($id,$groupName,$desc,json_encode($role));
  34. if($state){
  35. return true;
  36. }else{
  37. return false;
  38. }
  39. }
  40. }