Feedback.php 1.7 KB

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