input("view_type",AdminService::VIEW_TYPE[0]); $admin_id = $request->input("admin_id",1); $sys_group_id = $request->input('sys_group_id'); $is_system_admin = $request->input("is_system_admin",0); // $res = PermissionService::permission_tree($view_type); $res = PermissionService::user_permission($view_type, $admin_id, $is_system_admin,$sys_group_id); return self::returnValue($res); } /** * 创建顶级菜单 * @param Request $request * @return array */ public function create_permission_l1(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'title' => 'required', 'icon' => 'required', 'view_type' => Rule::in($support_view_type), ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $request->input("view_type",$support_view_type[0]); $id = $request->input('id'); $admin_id = $request->input('admin_id',0); $title = $request->input('title'); $route = $request->input('route',''); $icon = $request->input('icon'); $parent_id = 0; //顶级菜单 $weight = time(); //时间戳,默认新增内容排放在最后 $ret_code = PermissionService::create_permission($view_type,$admin_id,$parent_id,$title,$route,$weight,$icon); return self::returnValue([],$ret_code); } /*** * 编辑权限 * @param Request $request */ public function edit_permission_l1(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'id' => 'required', 'title' => 'required', 'icon' => 'required', 'view_type' => Rule::in($support_view_type), ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $request->input("view_type",$support_view_type[0]); $id = $request->input('id'); $title = $request->input('title'); $route = $request->input('route',''); $icon = $request->input('icon'); $ret_code = PermissionService::edit_permission_l1($view_type,$id,$title,$route,$icon); return self::returnValue([],$ret_code); } /** * 创建非顶级菜单 * @param Request $request * @return array */ public function create_permission_l2(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'title' => 'required', 'route' => 'required', 'parent_id' => 'required', 'view_type' => Rule::in($support_view_type), ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $request->input("view_type",$support_view_type[0]); $admin_id = $request->input('admin_id',0); $title = $request->input('title'); $route = $request->input('route'); $weight = time(); //时间戳,默认新增内容排放在最后 $icon = ''; $parent_id = $request->input("parent_id"); //上级菜单ID $ret_code = PermissionService::create_permission($view_type,$admin_id,$parent_id,$title,$route,$weight,$icon); return self::returnValue([],$ret_code); } /*** * 编辑权限 * @param Request $request */ public function edit_permission_l2(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'id' => 'required', 'title' => 'required', 'view_type' => Rule::in($support_view_type), ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $request->input("view_type",$support_view_type[0]); $id = $request->input('id'); $title = $request->input('title'); $route = $request->input('route',''); $ret_code = PermissionService::edit_permission_l2($view_type,$id,$title,$route); return self::returnValue([],$ret_code); } /** * 对菜单进行排序设置 * @param Request $request */ public function be_sort(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'p_id' => 'required|array', 'parent_id' => 'required', 'view_type' => Rule::in($support_view_type), ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $request->input("view_type",$support_view_type[0]); $admin_id = $request->input('admin_id',0); $parent_id = $request->input('parent_id'); $permission_id_arr = $request->input('p_id'); $ret_code = PermissionService::be_sort($view_type,$parent_id,$permission_id_arr); return self::returnValue([],$ret_code); } /** * 权限列表 * @param Request $request * @return array */ public function permission_list(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $view_type = $request->input("view_type",$support_view_type[0]); $parent_id = $request->input('parent_id',0); $list = PermissionService::permission_list($view_type,$parent_id); return self::returnValue($list,0); } /** * 权限删除 * @param Request $request * @return array */ public function permission_del(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $view_type = $request->input("view_type",$support_view_type[0]); $p_id = $request->input('id',0); $ret_code = PermissionService::del_permission($view_type,$p_id); return self::returnValue([],$ret_code); } }