80 行
2.2 KiB
PHP
80 行
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\shopro\business_school;
|
|
|
|
use app\admin\controller\shopro\Base;
|
|
|
|
class School extends Base
|
|
{
|
|
protected $model = null;
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->model = new \app\admin\model\shopro\business_school\School;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$this->request->filter(['strip_tags']);
|
|
if ($this->request->isAjax()) {
|
|
list($where, $sort, $order, $offset, $limit) = $this->custombuildparams();
|
|
$total = $this->model->where($where)->count();
|
|
$list = $this->model->where($where)->order($sort, $order)->limit($offset, $limit)->select();
|
|
return $this->success('商学院列表', null, ['total' => $total, 'rows' => $list]);
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
if ($this->request->isPost()) {
|
|
$params = $this->request->post('row/a');
|
|
if (empty($params['name'])) {
|
|
$this->error('请输入商学院名称');
|
|
}
|
|
$this->model->create($params);
|
|
$this->success('添加成功');
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function edit($ids = null)
|
|
{
|
|
$row = $this->model->get($ids);
|
|
if (!$row) {
|
|
$this->error('记录不存在');
|
|
}
|
|
if ($this->request->isPost()) {
|
|
$params = $this->request->post('row/a');
|
|
if (empty($params['name'])) {
|
|
$this->error('请输入商学院名称');
|
|
}
|
|
$row->save($params);
|
|
$this->success('保存成功');
|
|
}
|
|
$this->view->assign('row', $row);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function del($ids = null)
|
|
{
|
|
$row = $this->model->get($ids);
|
|
if (!$row) {
|
|
$this->error('记录不存在');
|
|
}
|
|
$row->status = 'forbidden';
|
|
$row->save();
|
|
$this->success('操作成功');
|
|
}
|
|
|
|
/**
|
|
* 下拉选择
|
|
*/
|
|
public function select()
|
|
{
|
|
$list = $this->model->where('status', 'normal')->field('id,name')->order('id desc')->select();
|
|
return $this->success('操作成功', null, $list);
|
|
}
|
|
}
|