12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace app\sys\controller;
- use app\BaseController;
- use app\Request;
- use app\logics\ToolAvoidPitLogic;
- use think\facade\View;
- class ToolAvoidPit extends BaseController
- {
- /**
- * 显示资源列表
- */
- public function index()
- {
- if(!$this->request->isAjax()){
- View::assign('type', config('app.params.avoid_pit_type'));
- return View::fetch();
- }
- $param = $this->request->param();
- $condition = [];
- if (!empty($param['type'])) {
- $condition[] = ['type', 'eq', $param['type']];
- }
- if (!empty($param['label'])) {
- $condition[] = ['label', 'like', '%'.$param['label'].'%'];
- }
- if (!empty($param['title'])) {
- $condition[] = ['title', 'like', '%'.$param['title'].'%'];
- }
- $data = ToolAvoidPitLogic::list($condition);
- $count = ToolAvoidPitLogic::count($condition);
- return json(['code'=>0, 'data'=>$data, 'count'=>$count]);
- }
- /**
- * 保存新建的资源
- */
- public function save()
- {
- $param = $this->request->param();
- ToolAvoidPitLogic::save($param);
- return json(['code'=>0, 'msg'=>'保存成功']);
- }
- /**
- * 删除
- */
- public function delete()
- {
- $id = $this->request->param('id');
- ToolAvoidPitLogic::delete($id);
- return json(['code'=>0, 'msg'=>'删除成功']);
- }
- }
|