作者 刘锟

升级项目自定义模块采集调整

... ... @@ -562,24 +562,30 @@ class ProjectUpdate extends Command
$url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]);
$data = curl_c($url);
if (isset($data['code']) && $data['code'] == 200) {
$children = [];
//判断分类里面是否存在自定义模块路由
$is_exist = 0;
if ($data['data']['category'] ?? []) {
foreach ($data['data']['category'] as $vc) {
$c_route = $this->get_url_route($vc['url'] ?? '');
if ($c_route != $custom_info['route']) {
$children[] = $vc;
if ($c_route == $custom_info['route']) {
$is_exist = 1;
}
}
}
$category = [
[
'id' => 0,
'name' => $custom_info['route'],
'url' => '/' . $custom_info['route'],
'parent' => 0,
'children' => $children
]
];
if ($is_exist) {
//存在,无需添加自定义模块路由为分类路由
$category = $data['data']['category'];
} else {
//不存在,需要添加自定义模块路由为分类路由
$category = [
[
'id' => 0,
'name' => $custom_info['route'],
'url' => '/' . $custom_info['route'],
'parent' => $data['data']['category'] ?? []
]
];
}
$this->category_custom_insert($project_id, $custom_info['id'], $category, 0);
$count = $data['data']['count'] ?? 0;
... ...