up
This commit is contained in:
@@ -165,6 +165,37 @@ class CrawlerService
|
||||
return $data ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 从职位树数据中收集可爬取的职位代码(排除 nocheck: true 的节点)
|
||||
* 接口返回扁平数组 [ { CODE, TITLE, nocheck?, ... }, ... ]
|
||||
* @param array $treeData getPositionTree 的返回值(可为裸数组或包装结构)
|
||||
* @return string[]
|
||||
*/
|
||||
public function collectPositionCodesExcludingNocheck(array $treeData): array
|
||||
{
|
||||
$codes = [];
|
||||
$nodes = $treeData;
|
||||
if (isset($treeData['data']) && is_array($treeData['data'])) {
|
||||
$nodes = $treeData['data'];
|
||||
} elseif (isset($treeData['tree']) && is_array($treeData['tree'])) {
|
||||
$nodes = $treeData['tree'];
|
||||
}
|
||||
foreach ($nodes as $item) {
|
||||
if (!is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
// 有 nocheck 且为真(true / "true" / 1)则跳过;避免把字符串 "false" 当真理
|
||||
$nocheck = $item['nocheck'] ?? $item['noCheck'] ?? null;
|
||||
if ($nocheck === true || $nocheck === 1 || (is_string($nocheck) && strtolower($nocheck) === 'true')) {
|
||||
continue;
|
||||
}
|
||||
if (isset($item['CODE']) && $item['CODE'] !== '') {
|
||||
$codes[] = $item['CODE'];
|
||||
}
|
||||
}
|
||||
return $codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取职位详细信息
|
||||
* @param string $zwdm 职位代码
|
||||
|
||||
Reference in New Issue
Block a user