api/expert_manage/getList 加国家筛选

解析简历信息
This commit is contained in:
wyn
2026-06-08 11:00:54 +08:00
parent 1d54946fef
commit aee9b00c6f
5 changed files with 100 additions and 3 deletions

View File

@@ -3311,4 +3311,63 @@ class User extends Base
return jsonSuccess([]);
}
/**
* 根据 user_id 查 user_cv 简历,调用大模型解析用户基本信息。
*
* POST/GET user_id=用户ID也支持 userId
* 简历地址https://submission.tmrjournals.com/public/reviewer/{cv}
* 同机部署时优先读 public/reviewer/ 本地文件。
*/
public function getUserInfoByFile()
{
@set_time_limit(180);
$userId = intval($this->request->param('user_id', $this->request->param('userId', 0)));
if ($userId <= 0) {
return jsonError('请提供 user_id');
}
try {
$service = new \app\common\UserInfoFromFileService();
$result = $service->parseFromUserId($userId);
\think\Log::info('[getUserInfoByFile] user_id=' . $userId . ' ' . json_encode($result['user_info'], JSON_UNESCAPED_UNICODE));
return jsonSuccess([
'message' => '解析完成',
'user_id' => $result['user_id'],
'cv' => $result['cv'],
'cv_url' => $result['cv_url'],
'file' => $result['file'],
'text_length' => $result['text_length'],
'text_preview' => $result['text_preview'],
'user_info' => $result['user_info'],
'print' => $this->formatUserInfoForPrint($result['user_info']),
]);
} catch (\Throwable $e) {
return jsonError($e->getMessage());
}
}
private function formatUserInfoForPrint(array $info)
{
$labels = [
'realname' => '姓名',
'email' => '邮箱',
'phone' => '电话',
'orcid' => 'ORCID',
'technical' => '职称',
'field' => '研究领域',
'company' => 'Institution',
'department' => '科室',
'country' => '国家',
'introduction' => '简介',
];
$lines = [];
foreach ($labels as $key => $label) {
$val = trim((string) ($info[$key] ?? ''));
$lines[] = $label . '' . ($val !== '' ? $val : '(未识别)');
}
return implode("\n", $lines);
}
}