<?php
|
|
namespace app\operations\controller\takeout;
|
|
use app\operations\controller\Controller;
|
use app\operations\model\takeout\School as SchoolModel;
|
|
/**
|
* 控制器
|
*/
|
class School extends Controller
|
{
|
/**
|
* 获取列表
|
*/
|
public function index()
|
{
|
$model = new SchoolModel;
|
$list = $model->getList($this->postData());
|
return $this->renderSuccess('', compact('list'));
|
}
|
|
/**
|
* 添加
|
*/
|
public function add()
|
{
|
$model = new SchoolModel;
|
// 新增记录
|
if ($model->add($this->postData())) {
|
return $this->renderSuccess('添加成功');
|
}
|
return $this->renderError($model->getError() ?: '添加失败');
|
}
|
|
/**
|
* 编辑
|
*/
|
public function edit($school_id)
|
{
|
// 详情
|
$model = SchoolModel::detail($school_id);
|
// 更新记录
|
if ($model->edit($this->postData())) {
|
return $this->renderSuccess('更新成功');
|
}
|
return $this->renderError($model->getError() ?: '更新失败');
|
}
|
|
/**
|
* 删除
|
*/
|
public function delete($school_id)
|
{
|
$model = SchoolModel::detail($school_id);
|
if (!$model->remove()) {
|
return $this->renderError('删除失败');
|
}
|
return $this->renderSuccess('删除成功');
|
}
|
}
|