From cafb7112a007181a51b9b6c8e1cc2032e879a0ed Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Thu, 19 Jun 2025 13:00:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9A=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91=EF=BC=9A?= =?UTF-8?q?=20=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=20?= =?UTF-8?q?=E3=80=90=E5=BD=B1=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PlaneController.class.php | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/FlyCube/MpApi/Controller/PlaneController.class.php b/FlyCube/MpApi/Controller/PlaneController.class.php index 93f5309..03a033c 100644 --- a/FlyCube/MpApi/Controller/PlaneController.class.php +++ b/FlyCube/MpApi/Controller/PlaneController.class.php @@ -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: 创建新飞机 */