refactor: 修改横幅列表接口
This commit is contained in:
@@ -20,7 +20,8 @@ class Banner
|
||||
|
||||
$banners = SysBannerModel::field([
|
||||
'id',
|
||||
'name'
|
||||
'name',
|
||||
'at_platform'
|
||||
])
|
||||
->withSearch(['name'], [
|
||||
'name' => $param['name'] ?? null
|
||||
@@ -30,7 +31,27 @@ class Banner
|
||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||
->select();
|
||||
|
||||
return success('获取成功', $banners);
|
||||
$datas = [];
|
||||
if (!$banners->isEmpty()) {
|
||||
$temp = [];
|
||||
$map = ['pc' => 'PC端', 'mobile' => '移动端'];
|
||||
foreach ($banners as $banner) {
|
||||
if (!isset($temp[$banner->at_platform])) {
|
||||
$temp[$banner->at_platform] = [
|
||||
'id' => 0,
|
||||
'name' => $map[$banner->at_platform] ?? '未知平台',
|
||||
'children' => []
|
||||
];
|
||||
}
|
||||
$temp[$banner->at_platform]['children'][] = [
|
||||
'id' => $banner->id,
|
||||
'name' => $banner->name
|
||||
];
|
||||
}
|
||||
$datas = array_values($temp);
|
||||
}
|
||||
|
||||
return success('获取成功', $datas);
|
||||
}
|
||||
|
||||
// 分页
|
||||
|
||||
Reference in New Issue
Block a user