Feedback.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\user;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\user\FeedbackRepository;
  14. use app\validate\api\FeedbackValidate;
  15. use think\App;
  16. class Feedback extends BaseController
  17. {
  18. protected $repository;
  19. public function __construct(App $app, FeedbackRepository $repository)
  20. {
  21. parent::__construct($app);
  22. $this->repository = $repository;
  23. }
  24. /**
  25. * @param FeedbackValidate $validate
  26. * @param FeedbackRepository $repository
  27. * @return mixed
  28. * @author xaboy
  29. * @day 2020/5/28
  30. */
  31. public function feedback(FeedbackValidate $validate)
  32. {
  33. $data = $this->request->params(['type', 'content', ['images', []], 'realname', 'contact',['status',1]]);
  34. $validate->check($data);
  35. $data['uid'] = $this->request->uid();
  36. $this->repository->create($data);
  37. return app('json')->success('反馈成功');
  38. }
  39. /**
  40. * @return mixed
  41. * @author xaboy
  42. * @day 2020/5/28
  43. */
  44. public function feedbackList()
  45. {
  46. [$page, $limit] = $this->getPage();
  47. return app('json')->success($this->repository->getList(['uid' => $this->request->uid(),'is_del' => 0,'status' => 1], $page, $limit));
  48. }
  49. public function detail($id)
  50. {
  51. if (!$this->repository->uidExists($id, $this->request->uid()))
  52. return app('json')->fail('数据不存在');
  53. $feedback = $this->repository->get($id);
  54. return app('json')->success($feedback);
  55. }
  56. }