Feedback.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\api\controller\service;
  3. use app\common\controller\Api;
  4. use think\Validate;
  5. /**
  6. * 首页接口
  7. */
  8. class Feedback extends Api
  9. {
  10. protected $noNeedLogin = [''];
  11. protected $noNeedRight = ['*'];
  12. public function submitFeedback()
  13. {
  14. if (!$this->request->isPost()) {
  15. $this->error('请求方式异常');
  16. }
  17. $uid = $this->auth->id;
  18. $post = input('post.','','trim,strip_tags,htmlspecialchars,xss_clean');
  19. $rule = [
  20. 'mobile' => 'number',
  21. 'content'=> 'require',
  22. 'type' => 'require',
  23. ];
  24. $msg = [
  25. 'mobile.number' => '手机号必须是数字',
  26. 'content.require'=> '请填写反馈内容',
  27. 'type.require' => '请提交用户身份'
  28. ];
  29. $validate = new Validate($rule, $msg);
  30. $result = $validate->check($post);
  31. if (!$result) {
  32. $this->error($validate->getError());
  33. }
  34. $post['user_id'] = $uid;
  35. $applySkill = new \app\api\model\service\Feedback();
  36. $applySkill->data($post)->save();
  37. $this->success('反馈意见已提交');
  38. }
  39. }