【类 型】:feat
【原 因】:机型管理 增删改查 接口 【过 程】: 【影 响】:
This commit is contained in:
parent
ec34269485
commit
930ec695c3
@ -15,6 +15,107 @@ class PlaneController extends PublicController
|
|||||||
{
|
{
|
||||||
echo "hello wolrd";
|
echo "hello wolrd";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 获取 机型列表
|
||||||
|
*/
|
||||||
|
public function getPlaneClassList()
|
||||||
|
{
|
||||||
|
if ($this->tokenShop_id != C('powerId')) { //非总管理员
|
||||||
|
$where['shop_id'] = $this->tokenShop_id;
|
||||||
|
}
|
||||||
|
$where['del'] = "0";
|
||||||
|
$classDb = D('airplane_class');
|
||||||
|
$field = array('id', 'shop_id', 'class_name', 'wheelbase', 'category', 'weight_max', 'describe');
|
||||||
|
if ($planeClassList = $classDb->where($where)->field($field)->select()) {
|
||||||
|
echo json_encode(array('status' => 1, 'msg' => '访问成功', "airList" => $planeClassList));
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('status' => 0, 'msg' => '暂无机型数据'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 创建新机型
|
||||||
|
*/
|
||||||
|
public function addPlaneClass()
|
||||||
|
{
|
||||||
|
//总管理员 可接收任何shop_id 非总管理员 只可以调用自身shop_id 否则会中断
|
||||||
|
$this->isPower();
|
||||||
|
|
||||||
|
if ($_REQUEST['shop_id'] && $_REQUEST['class_name']) {
|
||||||
|
$data['shop_id'] = $_REQUEST['shop_id'];
|
||||||
|
$data['class_name'] = $_REQUEST['class_name'];
|
||||||
|
$data['weight_max'] = $_REQUEST['weight_max'];
|
||||||
|
$data['category'] = $_REQUEST['category'];
|
||||||
|
$data['wheelbase'] = $_REQUEST['wheelbase'];
|
||||||
|
if ($_REQUEST['describe']) {
|
||||||
|
$data['describe'] = $_REQUEST['describe'];
|
||||||
|
}
|
||||||
|
$classDb = D('airplane_class');
|
||||||
|
if ($classDb->data($data)->add()) {
|
||||||
|
echo json_encode(array('status' => 1, 'msg' => '创建成功'));
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('status' => 0, 'msg' => '创建失败'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 更新飞机
|
||||||
|
*/
|
||||||
|
public function savePlaneClass()
|
||||||
|
{
|
||||||
|
//总管理员 可接收任何shop_id 非总管理员 只可以调用自身shop_id 否则会中断
|
||||||
|
$this->isPower();
|
||||||
|
|
||||||
|
if ($_REQUEST['shop_id'] && $_REQUEST['class_name'] && $_REQUEST['id']) {
|
||||||
|
$data['class_name'] = $_REQUEST['class_name'];
|
||||||
|
$data['weight_max'] = $_REQUEST['weight_max'];
|
||||||
|
$data['category'] = $_REQUEST['category'];
|
||||||
|
$data['wheelbase'] = $_REQUEST['wheelbase'];
|
||||||
|
if ($_REQUEST['describe']) {
|
||||||
|
$data['describe'] = $_REQUEST['describe'];
|
||||||
|
}
|
||||||
|
$where['id'] = $_REQUEST['id'];
|
||||||
|
$where['shop_id'] = $_REQUEST['shop_id'];
|
||||||
|
$classDb = D('airplane_class');
|
||||||
|
if ($classDb->where($where)->save($data)) {
|
||||||
|
echo json_encode(array('status' => 1, 'msg' => '更新成功'));
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('status' => 0, 'msg' => '更新失败'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 删除指定飞机
|
||||||
|
*/
|
||||||
|
public function deletePlaneClass()
|
||||||
|
{
|
||||||
|
if ($this->tokenShop_id != C('powerId')) { //非总管理员
|
||||||
|
$where['shop_id'] = $this->tokenShop_id;
|
||||||
|
}
|
||||||
|
if (isset($_REQUEST['idArr'])) {
|
||||||
|
// 将逗号分隔的字符串转换为数组
|
||||||
|
$idArr = explode(',', $_REQUEST['idArr']);
|
||||||
|
} else {
|
||||||
|
$idArr = array(); // 如果未设置,则设置为空数组
|
||||||
|
}
|
||||||
|
if (!empty($idArr)) {
|
||||||
|
$where['id'] = array("in", $_REQUEST['idArr']);
|
||||||
|
$data['del'] = '1';
|
||||||
|
$classDb = D('airplane_class');
|
||||||
|
if ($classDb->where($where)->save($data)) {
|
||||||
|
echo json_encode(array('status' => 1, 'msg' => "机型{$_REQUEST['idArr']}删除成功"));
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('status' => 0, 'msg' => '删除操作失败'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 获取 飞机列表
|
* @description: 获取 飞机列表
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user