getPdo(); $stmt = $pdo->prepare("SELECT * FROM persons WHERE id = ?"); $stmt->execute([$id]); $person = $stmt->fetch(); if (!$person) { Response::error('人员不存在'); } $accounts = $pdo->prepare("SELECT id, platform, account_id, profile_url, remark, is_primary, is_defult, is_active FROM social_accounts WHERE owner_type = 'person' AND owner_id = ? ORDER BY is_defult DESC, is_primary DESC, id DESC"); $accounts->execute([$id]); $accountList = $accounts->fetchAll(); // 常用手机/邮箱(优先 is_defult=1,其次 is_primary=1) $phone = ''; $email = ''; foreach ($accountList as $a) { if ($phone === '' && $a['platform'] === 'phone') { $phone = $a['account_id']; } if ($email === '' && $a['platform'] === 'email') { $email = $a['account_id']; } if ($phone !== '' && $email !== '') { break; } } $experiences = $pdo->prepare( "SELECT pwe.id, pwe.company_id, c.display_name, c.industry, pwe.position, pwe.department, pwe.job_level, pwe.start_date, pwe.end_date, pwe.is_current FROM person_work_experiences pwe LEFT JOIN companies c ON c.id = pwe.company_id WHERE pwe.person_id = ? AND pwe.is_active = 1 ORDER BY pwe.is_current DESC, pwe.start_date DESC" ); $experiences->execute([$id]); Response::success([ 'person' => $person, 'accounts' => $accountList, 'phone' => $phone, 'email' => $email, 'experiences' => $experiences->fetchAll(), ]);