noticeModel = new \app\user\model\Notice(); } public function index(){ $p = $this->request->get('page', 0); $nick = $this->request->get('n'); $where = []; if($nick) $where['title'] = ['like', "%$nick%"]; $info = $this->noticeModel->getInfo($p, $where); $page = $this->noticeModel->getPage($where); $this->assign("info", $info); $this->assign("page", $page); return $this->fetch(); } public function edit(){ $id = $this->request->get('id'); $info = $this->noticeModel->getNoticeById($id); $this->assign("info", $info); return $this->fetch('edit'); } public function delete(){ $res = $this->noticeModel->where(['id'=>$this->request->get('id')])->delete(); if($res){ $this->success('删除成功!', 'index'); }else{ $this->error('删除失败!'); } } public function save(){ $res = $this->noticeModel->addAndSave(); if($res){ $this->success('保存成功!', 'index'); }else{ $this->error('保存失败!'); } } }