You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.6 KiB
105 lines
2.6 KiB
<?php
|
|
declare (strict_types=1);
|
|
|
|
/**
|
|
* Created by 安徽云掌.
|
|
* User: 云掌.帮德
|
|
* Date: 2020/3/8 22:30
|
|
* Desc: 获取权限菜单
|
|
*/
|
|
|
|
namespace app\api\controller;
|
|
use think\App;
|
|
|
|
class Cate extends CmsBase
|
|
{
|
|
public $model = null;
|
|
|
|
public function __construct(App $app)
|
|
{
|
|
parent::__construct($app);
|
|
$this->model = new \app\api\model\Cate();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
//接受参数
|
|
$_get = $this->request->param();
|
|
|
|
//指定搜索参数
|
|
$this->model->search_arr = ['cate_name'];
|
|
|
|
//验证参数
|
|
// validate(\app\api\validate\Cate::class)->scene('lists')->check($_get);
|
|
|
|
$_data = $this->model->index();
|
|
|
|
//返回数据
|
|
return send_http_status($_data);
|
|
}
|
|
|
|
|
|
public function add()
|
|
{
|
|
//接收参数
|
|
$_post = $this->request->post();
|
|
|
|
//验证参数
|
|
validate(\app\api\validate\Cate::class)->check($_post);
|
|
//处理并返回参数
|
|
$insertId = $this->model->parentAdd($_post);
|
|
return send_http_status($insertId, $insertId ? 201 : 202);
|
|
}
|
|
|
|
public function read($id = '')
|
|
{
|
|
//验证参数
|
|
validate(\app\api\validate\Cate::class)->scene('read')->check(['id' => $id]);
|
|
|
|
//返回数据
|
|
return send_http_status($this->model->parentRead($id));
|
|
}
|
|
|
|
|
|
public function edit($id = 0)
|
|
{
|
|
//接收参数
|
|
$_post = $this->request->post();
|
|
$_post['id'] = $id; //安全赋值,以免客户端没传id,修改需要id字段
|
|
|
|
//验证参数
|
|
validate(\app\api\validate\Cate::class)->scene('update')->check($_post);
|
|
|
|
//处理并返回数据
|
|
return send_http_status('', $this->model->parentEdit($_post, $id) ? 203 : 204);
|
|
}
|
|
|
|
public function delete()
|
|
{
|
|
//接收参数
|
|
$ids = $this->request->param('id');
|
|
|
|
//验证参数
|
|
validate(['ids|id' => 'require|length:1,100'])->check(['ids' => $ids]);
|
|
|
|
//处理并返回数据
|
|
return send_http_status('', $this->model->parentDel($ids) ? 205 : 206);
|
|
}
|
|
|
|
public function status()
|
|
{
|
|
//接收参数
|
|
$ids = $this->request->param('id');
|
|
$status = $this->request->param('status');
|
|
|
|
//验证参数
|
|
$_rules = [
|
|
'ids|id' => 'require|length:1,100',
|
|
'status|状态值' => 'require|number|length:1',
|
|
];
|
|
validate($_rules)->check(['ids' => $ids, 'status' => $status]);
|
|
|
|
//处理并返回数据
|
|
return send_http_status('', $this->model->parentStatus($ids, $status) !== false ? 207 : 208);
|
|
}
|
|
}
|
|
|