abstract:<?phpnamespace app\admin\controller;use app\admin\controller\Common;use app\admin\model\SortModel;use think\facade\Request;use think\facade\Session;class Sort extends Common{ public fu
<?php namespace app\admin\controller; use app\admin\controller\Common; use app\admin\model\SortModel; use think\facade\Request; use think\facade\Session; class Sort extends Common { public function index() { $sort = new SortModel(); $sorts = $sort->order('id', 'desc')->paginate(8); $this->view->sorts = $sorts; return $this->fetch(); } public function DoAdd() { $data = Request::param(); $data['time'] = time(); $data['username'] = Session::get('username'); $sort = new SortModel(); if ($sort->save($data)) { return ['res' => 1, 'msg' => '添加成功!']; } else { return ['res' => 0, 'msg' => '添加失败!']; } } public function edit() { $sortId = Request::param('id'); $sort = SortModel::get($sortId); $this->view->sort = $sort; return $this->fetch(); } public function DoEdit() { $data = Request::param(); $sort = new SortModel(); $info = $sort->save([ 'title' => $data['title'], 'time' => time(), 'username' => Session::get('username'), ], ['id' => $data['id']]); if ($info) { return ['res' => 1, 'msg' => '修改成功!']; } else { return ['res' => 0, 'msg' => '修改失败!']; } } public function del() { $sortId = Request::param('id'); $sort = new SortModel(); if ($sort->destroy($sortId)) { return ['res'=>1,'msg'=>'删除成功!']; } } }
Correcting teacher:查无此人Correction time:2019-06-06 09:18:10
Teacher's summary:完成的不错。后台cms管理系统,就是对数据进行操作。操作越简单越好。继续加油。