Rule.php 861 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\user\controller;
  3. use app\base\controller\Base;
  4. class Rule extends Base{
  5. private $ruleModel;
  6. public function _initialize(){
  7. parent::_initialize();
  8. $this->ruleModel = new \app\user\model\Rule();
  9. }
  10. public function index(){
  11. $info = $this->ruleModel->getInfo();
  12. $this->assign("info", $info);
  13. return $this->fetch();
  14. }
  15. public function edit(){
  16. $id = $this->request->post('id');
  17. $info = $this->ruleModel->getRuleById($id);
  18. return json($info);
  19. }
  20. public function save(){
  21. $res = $this->ruleModel->addAndSave();
  22. if($res){
  23. $this->success('保存成功!', 'index');
  24. }else{
  25. $this->error('保存失败!');
  26. }
  27. }
  28. public function delete(){
  29. $res = $this->ruleModel->remove();
  30. if($res){
  31. $this->success('删除成功!', 'index');
  32. }else{
  33. $this->error('删除失败!');
  34. }
  35. }
  36. }