update
This commit is contained in:
@@ -248,6 +248,75 @@ class Crawler extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动获取全部职位代码并返回职位详情(无需手动勾选)
|
||||
*/
|
||||
public function fetchAllPositions()
|
||||
{
|
||||
try {
|
||||
$dsdm = $this->request->param('dsdm', '');
|
||||
$examid = $this->request->param('examid', '');
|
||||
$bmid = $this->request->param('bmid', '');
|
||||
$userid = $this->request->param('userid', '');
|
||||
$aa = $this->request->param('aa', '');
|
||||
$cookiesParam = $this->request->param('cookies', '');
|
||||
|
||||
if (empty($dsdm) || empty($examid) || empty($bmid) || empty($userid) || empty($aa)) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '请填写examid、bmid、userid、dsdm,并先获取地区选项生成aa',
|
||||
]);
|
||||
}
|
||||
|
||||
if (empty($cookiesParam)) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '请填写Cookie数据',
|
||||
]);
|
||||
}
|
||||
|
||||
$cookies = is_string($cookiesParam) ? json_decode($cookiesParam, true) : $cookiesParam;
|
||||
if (json_last_error() !== JSON_ERROR_NONE || empty($cookies)) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => 'Cookie数据格式错误,请检查JSON格式',
|
||||
]);
|
||||
}
|
||||
|
||||
$service = new CrawlerService();
|
||||
$treeData = $service->getPositionTree($dsdm, $examid, $bmid, $userid, (string)$aa, $cookies);
|
||||
|
||||
$zwdmList = [];
|
||||
if (is_array($treeData)) {
|
||||
foreach ($treeData as $item) {
|
||||
if (isset($item['CODE']) && !empty($item['CODE'])) {
|
||||
$zwdmList[] = $item['CODE'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($zwdmList)) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '未获取到职位代码',
|
||||
]);
|
||||
}
|
||||
|
||||
$results = $service->batchGetPositionInfo($zwdmList, $examid, $cookies);
|
||||
|
||||
return json([
|
||||
'code' => 1,
|
||||
'data' => $results,
|
||||
'msg' => '获取成功',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取失败: ' . $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取职位详细信息
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user