Feedback.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\controller\api\user;
  3. use ln\basic\BaseController;
  4. use app\common\repositories\user\FeedbackRepository;
  5. use app\validate\api\FeedbackValidate;
  6. use think\App;
  7. class Feedback extends BaseController
  8. {
  9. protected $repository;
  10. public function __construct(App $app, FeedbackRepository $repository)
  11. {
  12. parent::__construct($app);
  13. $this->repository = $repository;
  14. }
  15. /**
  16. * @param FeedbackValidate $validate
  17. * @param FeedbackRepository $repository
  18. * @return mixed
  19. * @author zfy
  20. * @day 2020/5/28
  21. */
  22. public function feedback(FeedbackValidate $validate)
  23. {
  24. $data = $this->request->params(['type', 'content', ['images', []], 'realname', 'contact',['status',1]]);
  25. $validate->check($data);
  26. $data['uid'] = $this->request->uid();
  27. $this->repository->create($data);
  28. return app('json')->success('反馈成功');
  29. }
  30. /**
  31. * @return mixed
  32. * @author zfy
  33. * @day 2020/5/28
  34. */
  35. public function feedbackList()
  36. {
  37. [$page, $limit] = $this->getPage();
  38. return app('json')->success($this->repository->getList(['uid' => $this->request->uid(),'is_del' => 0,'status' => 1], $page, $limit));
  39. }
  40. public function detail($id)
  41. {
  42. if (!$this->repository->uidExists($id, $this->request->uid()))
  43. return app('json')->fail('数据不存在');
  44. $feedback = $this->repository->get($id);
  45. return app('json')->success($feedback);
  46. }
  47. }