This commit is contained in:
nanguaboss
2026-08-06 00:50:23 +08:00
parent 595520822a
commit 2cb688ed46
29 changed files with 5227 additions and 186 deletions
+25 -2
View File
@@ -1,6 +1,7 @@
<?php
/**
* 人员详情接口 GET /api/person/detail.php?id=1
* v1.0.16:联系方式改为“手机”“邮箱”两字段(仅常用);另有全部账号列表 accounts 供编辑回显
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
@@ -22,8 +23,24 @@ if (!$person) {
Response::error('人员不存在');
}
$accounts = $pdo->prepare("SELECT id, platform, account_id, profile_url, remark, is_primary, is_active FROM social_accounts WHERE owner_type = 'person' AND owner_id = ? ORDER BY is_primary DESC, id DESC");
$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,
@@ -35,4 +52,10 @@ $experiences = $pdo->prepare(
);
$experiences->execute([$id]);
Response::success(['person' => $person, 'accounts' => $accounts->fetchAll(), 'experiences' => $experiences->fetchAll()]);
Response::success([
'person' => $person,
'accounts' => $accountList,
'phone' => $phone,
'email' => $email,
'experiences' => $experiences->fetchAll(),
]);