【类 型】:

【原  因】:
【过  程】:
【影  响】:
This commit is contained in:
air 2025-06-19 13:00:52 +08:00
parent c1a77bcab1
commit cafb7112a0

View File

@ -115,37 +115,50 @@ class PlaneController extends PublicController
}
}
/**
* @description: 获取飞机列表(含机型信息)
*/
public function getAirList()
{
$airDb = D('airplane_register');
$airDb = D('airplane_register'); // 飞机表
$prefix = C('DB_PREFIX'); // 获取表前缀
$where = [];
if ($this->tokenShop_id != C('powerId')) { // 非总管理员
$where['shop_id'] = $this->tokenShop_id;
$where['a.shop_id'] = $this->tokenShop_id;
}
$where['del'] = '0';
$where['a.del'] = '0';
$field = 'a.id, a.name, a.class_id, a.shop_id, a.status, c.class_name, c.wheelbase, c.category, c.weight_max';
$prefix = C('DB_PREFIX');
// 需要的字段,带表别名
$field = 'a.id, a.name, a.macadd, a.shop_id, a.apply_time, a.onoff, c.class_name, c.wheelbase, c.category, c.weight_max';
// 动态拼接带前缀的表名,避免硬编码
$joinTable = $prefix . 'airplane_class';
$airList = $airDb
->alias('a')
->join("LEFT JOIN {$prefix}airplane_class c ON a.class_id = c.id")
->join("LEFT JOIN {$joinTable} c ON a.bind_class_id = c.id")
->where($where)
->field($field)
->order('a.id desc')
->select();
if ($airList) {
echo json_encode(array(
echo json_encode([
'status' => 1,
'msg' => '访问成功',
'airList' => $airList
));
'airList' => $airList,
]);
} else {
echo json_encode(array('status' => 0, 'msg' => '暂无飞机数据'));
echo json_encode([
'status' => 0,
'msg' => '暂无飞机数据',
]);
}
}
/**
* @description: 创建新飞机
*/