39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* 人员详情接口 GET /api/person/detail.php?id=1
|
|
*/
|
|
require_once __DIR__ . '/../common/db.php';
|
|
require_once __DIR__ . '/../common/response.php';
|
|
require_once __DIR__ . '/../common/auth.php';
|
|
|
|
checkPermission('person');
|
|
|
|
$id = (int)($_REQUEST['id'] ?? 0);
|
|
if ($id <= 0) {
|
|
Response::error('参数错误', 400);
|
|
}
|
|
|
|
$pdo = DB::getInstance()->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_active FROM social_accounts WHERE owner_type = 'person' AND owner_id = ? ORDER BY is_primary DESC, id DESC");
|
|
$accounts->execute([$id]);
|
|
|
|
$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' => $accounts->fetchAll(), 'experiences' => $experiences->fetchAll()]);
|