<?php

namespace App\Http\Controllers\APi\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Admin\GroupService;
use App\Services\Admin\MenuService;
class GroupController extends Controller
{
    //获取全部组
    public function GetList(){
        $type =request('type');
        $page =request('page');
        $pagesize =request('pagesize');
        $s=app()->make(GroupService::class);
        return $s->GetList(['type'=>$type,'page'=>$page,'pagesize'=>$pagesize]);
    }
    public function ChangeMenu(Request $request){
        $userid = $request->get('userid');//中间件产生的参数
        $group =request('groupId');
        $menuList =request('menuList');
        $s=app()->make(GroupService::class);
        return $s->ChangeMenu(['groupid'=>$group,'menuList'=>$menuList]);
    }
    public function Save(){
        $groupInfo =request('groupInfo');
        $type =request('type');
        $s=app()->make(GroupService::class);
        return $s->Save(['info'=>$groupInfo,'type'=>$type]);

    }
    //管理员查询分组使用的菜单
    public function GetGroupMenuList(){
        $groupId =request('groupId');
        if($groupId){
            $group =$groupId;
            $userid='search';
            $s=app()->make(MenuService::class);
            // dd($s->GetBaseMenuList(['userid'=>$userid,'group'=>$group]));
            return $s->GetBaseMenuList(['userid'=>$userid,'group'=>$group]);
        }

    }
}
