Feedback.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace addons\ddrive\controller;
  3. use app\admin\model\Feedback as Model;
  4. use app\common\controller\Api;
  5. /**
  6. * 话题接口
  7. */
  8. class Feedback extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['*'];
  12. public function _initialize()
  13. {
  14. parent::_initialize();
  15. $this->model = new \addons\ddrive\model\Feedback;
  16. }
  17. /**
  18. * 创建话题
  19. *
  20. * @return void
  21. */
  22. public function add()
  23. {
  24. $data = [
  25. 'type' => $this->request->param('type'),
  26. 'content' => $this->request->param('content'),
  27. 'user_id' => $this->auth->id,
  28. 'contact' => $this->request->param('contact'),
  29. ];
  30. if (!$data['type']) {
  31. $this->error('请填写问题分类');
  32. }
  33. if (!$data['content']) {
  34. $this->error('请填写问题内容');
  35. }
  36. $res = $this->model->data($data)->save();
  37. if ($res) {
  38. $this->success('提交成功');
  39. } else {
  40. $this->error('提交失败');
  41. }
  42. }
  43. }