all(),[ 'name' => 'required', 'permission_id' => 'required', 'role_type' => Rule::in([10,20,30]) ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $support_view_type[0]; $admin_id = $request->input('admin_id'); $role_type = $request->input('role_type'); $sys_group_id = $request->input('sys_group_id'); $is_system_admin = $request->input('is_system_admin'); $name = $request->input('name'); $desc = $request->input('desc',''); $permission_id_arr = $request->input('permission_id',[]); $errno = RoleService::create_role($view_type,$admin_id,$sys_group_id,$is_system_admin,$name,$desc,$role_type,$permission_id_arr); return self::returnValue([],$errno); } /** * 编辑角色 * @param Request $request * @return array */ public function edit_role(Request $request) { $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'id' => 'required|integer', 'name' => 'required', 'permission_id' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $support_view_type[0]; $admin_id = $request->input('admin_id'); $role_type = $request->input('role_type'); $sys_group_id = $request->input('sys_group_id'); $is_system_admin = $request->input('is_system_admin'); $role_id = $request->input("id"); $name = $request->input('name'); $desc = $request->input('desc',''); $permission_id_arr = $request->input('permission_id',[]); $errNo = RoleService::edit_role( $view_type,$admin_id,$sys_group_id,$is_system_admin,$role_id,$name,$desc,$role_type,$permission_id_arr ); return self::returnValue([], $errNo); } /** * 角色列表 * @param Request $request * @return array */ public function role_list(Request $request) { $support_view_type = AdminService::VIEW_TYPE; $view_type = $support_view_type[0]; $admin_id = $request->input('admin_id'); $sys_group_id = $request->input('sys_group_id'); $is_system_admin = $request->input('is_system_admin'); $page = $request->input('page',1); $page_size = $request->input('page_size',20); $errno = 0; list($total,$list) = RoleService::role_list($view_type,$admin_id,$sys_group_id,$is_system_admin,$page,$page_size, $errno); if($errno) return self::returnValue([], $errno); return self::returnPageValue($list,$total,$page_size,$page); } /** * 角色详情 * @param Request $request * @return array */ public function role_info(Request $request) { $validator = \Validator::make($request->all(),[ 'id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $role_id = $request->input('id'); $admin_id = $request->input('admin_id'); $sys_group_id = $request->input('sys_group_id'); $is_system_admin = $request->input('is_system_admin'); $errno = 0; $data = RoleService::role_info($role_id,$admin_id,$sys_group_id,$is_system_admin,$errno); return self::returnValue($data, $errno); } /** * 获取角色类型 * */ public function role_type(Request $request) { $admin_id = $request->input('admin_id'); $sys_group_id = $request->input('sys_group_id'); $is_system_admin = $request->input('is_system_admin'); $errno = 0; # 获取用户可使用的角色类型 $data = RoleService::role_type($admin_id, $sys_group_id, $is_system_admin, $errno); return self::returnValue($data, $errno); } /** * 删除角色 * @param Request $request * @return array */ public function del_role(Request $request) { $validator = \Validator::make($request->all(),[ 'id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $role_id = $request->input('id'); $admin_id = $request->input('admin_id',0); $sys_group_id = $request->input('sys_group_id',0); $is_system_admin = $request->input('is_system_admin'); $errno = RoleService::del_role($role_id,$admin_id,$sys_group_id,$is_system_admin); return self::returnValue([],$errno); } }