12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\user\controller;
- use app\base\controller\Base;
- class Notice extends Base{
-
- private $noticeModel;
-
- public function _initialize(){
- parent::_initialize();
-
- $this->noticeModel = new \app\user\model\Notice();
- }
-
- public function index(){
- $p = $this->request->get('page', 0);
- $nick = $this->request->get('n');
- $where = ['is_del'=>0];
-
- 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 create(){
-
- $this->success('创建xml成功!');
- }
-
- public function delete(){
- $res = $this->noticeModel->where(['id'=>$this->request->get('id')])->update(['is_del'=>1]);
-
- if($res){
- $this->success('删除成功!', 'index');
- }else{
- $this->error('删除失败!');
- }
- }
-
- public function save(){
- $res = $this->noticeModel->addAndSave();
-
- if($res){
- $this->success('保存成功!', 'index');
- }else{
- $this->error('保存失败!');
- }
- }
-
- }
|