Notice.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\user\controller;
  3. use app\base\controller\Base;
  4. class Notice extends Base{
  5. private $noticeModel;
  6. public function _initialize(){
  7. parent::_initialize();
  8. $this->noticeModel = new \app\user\model\Notice();
  9. }
  10. public function index(){
  11. $p = $this->request->get('page', 0);
  12. $nick = $this->request->get('n');
  13. $where = ['is_del'=>0];
  14. if($nick) $where['title'] = ['like', "%$nick%"];
  15. $info = $this->noticeModel->getInfo($p, $where);
  16. $page = $this->noticeModel->getPage($where);
  17. $this->assign("info", $info);
  18. $this->assign("page", $page);
  19. return $this->fetch();
  20. }
  21. public function edit(){
  22. $id = $this->request->get('id');
  23. $info = $this->noticeModel->getNoticeById($id);
  24. $this->assign("info", $info);
  25. return $this->fetch('edit');
  26. }
  27. public function create(){
  28. $this->success('创建xml成功!');
  29. }
  30. public function delete(){
  31. $res = $this->noticeModel->where(['id'=>$this->request->get('id')])->update(['is_del'=>1]);
  32. if($res){
  33. $this->success('删除成功!', 'index');
  34. }else{
  35. $this->error('删除失败!');
  36. }
  37. }
  38. public function save(){
  39. $res = $this->noticeModel->addAndSave();
  40. if($res){
  41. $this->success('保存成功!', 'index');
  42. }else{
  43. $this->error('保存失败!');
  44. }
  45. }
  46. }