input('admin_id'); $sys_group_id = $request->input('sys_group_id'); $is_system_admin = $request->input('is_system_admin'); $errno = 0; $res = AdminService::all_role_list($admin_id,$sys_group_id,$is_system_admin, $errno); return self::returnValue($res,$errno); } /** * 主体列表 * @param Request $request * @return array */ public function corp_list(Request $request){ $group_admin_id = $request->input("group_admin_id",0); $admin_id = $request->input("admin_id",0); $is_system_admin = $request->input("is_system_admin"); $corp_list = AdminService::corp_list($group_admin_id,$admin_id,$is_system_admin); return self::returnValue($corp_list,0); } /** * 创建管理员 * @param Request $request */ public function create_admin(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'name' => 'required', 'password' => 'required', // 'view_type' => Rule::in($support_view_type), ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $support_view_type[0]; $name = trim($request->input("name")); $password = $request->input("password"); $role_id = $request->input("role_id"); $corp_id = $request->input("corp_id"); $is_promoter = $request->input("is_promoter", 0); $is_all_adq = $request->input("is_all_adq", 0); $adq_account = $request->input("adq_account"); $is_all_mp = $request->input("is_all_mp", 0); $mp_account = $request->input("mp_account"); $can_export = $request->input("can_export", 0); $group_admin_id = $request->input("group_admin_id",0); if(strlen($password)<6 || strlen($password)>18){ return self::returnValue([],4405); //密码不符合要求 } /**系统管理员创建账号时,为新建分组**/ $is_new_group = $request->input("is_system_admin") == Users::SYSTEM_ADMIN ? 1 : 0; $ret_code = AdminService::admin_create( $view_type,$group_admin_id,$name,$password,$role_id,$corp_id,$is_new_group, $is_promoter, $is_all_adq, $adq_account, $is_all_mp, $mp_account, $can_export ); return self::returnValue([],$ret_code); } /** * 编辑管理员 * @param Request $request */ public function edit_admin(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'id' => 'required|integer', // 'is_super_admin' => 'required|integer', // 'view_type' => Rule::in($support_view_type), ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $support_view_type[0]; $sys_user_id = $request->input("id"); $password = $request->input("password",''); $role_id = $request->input("role_id"); $corp_id = $request->input("corp_id"); $is_promoter = $request->input("is_promoter", 0); $is_all_adq = $request->input("is_all_adq", 0); $adq_account = $request->input("adq_account"); $is_all_mp = $request->input("is_all_mp", 0); $mp_account = $request->input("mp_account"); $can_export = $request->input("can_export", 0); $group_admin_id = $request->input("group_admin_id",0); if(empty($password)==false && (strlen($password)<6 || strlen($password)>18)){ return self::returnValue([],4405); //密码不符合要求 } $ret_code = AdminService::admin_edit( $view_type,$group_admin_id,$sys_user_id,$password,$role_id,$corp_id, $is_promoter, $is_all_adq, $adq_account, $is_all_mp, $mp_account, $can_export ); return self::returnValue([],$ret_code); } /** * 删除管理员 * @param Request $request */ public function delete_admin(Request $request) { $validator = \Validator::make($request->all(),[ 'id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $sys_user_id = $request->input("id"); $admin_id = $request->input("admin_id"); $group_admin_id = $request->input("group_admin_id",0); $sys_group_id = $request->input("sys_group_id"); $is_system_admin = $request->input("is_system_admin",0); if($sys_user_id==$admin_id){ return self::returnValue([],4407); //不能删除自己账号 } $ret_code = AdminService::admin_del($is_system_admin,$group_admin_id,$sys_user_id,$sys_group_id, $admin_id); return self::returnValue([],$ret_code); } /** * 管理员列表 * @param Request $request */ public function admin_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"); $page = $request->input("page",1); $page_size = $request->input("page_size",20); $group_admin_id = $request->input("group_admin_id",0); $is_system_admin= $request->input("is_system_admin",0); $errno = 0; list($total,$list) = AdminService::admin_list($view_type,$is_system_admin,$admin_id,$sys_group_id,$group_admin_id,$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 admin_info(Request $request){ $support_view_type = AdminService::VIEW_TYPE; $validator = \Validator::make($request->all(),[ 'id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $view_type = $support_view_type[0]; $sys_user_id = $request->input("id"); $group_admin_id = $request->input("group_admin_id",0); $is_system_id = $request->input("is_system_admin",0); $res = AdminService::admin_info($view_type,$is_system_id,$group_admin_id,$sys_user_id); if(is_numeric($res)){ return self::returnValue([],$res); }else{ return self::returnValue($res); } } /** * 管理的账号组列表 * @param Request $request */ public function accountGroupList(Request $request){ $group_admin_id = $request->input("group_admin_id"); $is_system_admin = $request->input("is_system_admin"); /**目前仅开放系统管理员查看**/ if($is_system_admin != Users::SYSTEM_ADMIN){ return self::returnValue([],4406); //非系统管理员不能管理账号组 } $res = AdminService::manage_account_group_list($group_admin_id,$is_system_admin); return self::returnValue($res,0); } # 获取企微已绑定成员 public function getCorpBindUserList(Request $request) { $validator = \Validator::make($request->all(),[ 'id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpId = $request->input('id'); $supportViewType = AdminService::VIEW_TYPE; $viewType = $supportViewType[0]; $groupAdminId = $request->input("group_admin_id",0); $isSystemAdmin= $request->input("is_system_admin",0); $list = AdminService::getCorpBindUserList($corpId, $viewType, $groupAdminId, $isSystemAdmin); return self::returnValue($list); } # 为企微分配成员 public function corpBindMultipleUser(Request $request) { $validator = \Validator::make($request->all(),[ 'id' => 'required|integer', 'user_id_list' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpId = $request->input('id'); $userIdList = $request->input('user_id_list'); $userIdList = json_decode($userIdList); $supportViewType = AdminService::VIEW_TYPE; $viewType = $supportViewType[0]; list($res, $code) = AdminService::corpBindMultipleUser($corpId, $userIdList, $viewType); return self::returnValue($res, $code); } }