Feedback.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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. * 用户反馈
  26. * @param FeedbackValidate $validate
  27. * @param FeedbackRepository $repository
  28. * @return mixed
  29. * @author xaboy
  30. * @day 2020/5/28
  31. */
  32. public function feedback(FeedbackValidate $validate)
  33. {
  34. $data = $this->request->params(['type', 'content', ['images', []], 'realname', 'contact',['status',0]]);
  35. $validate->check($data);
  36. $data['uid'] = $this->request->uid();
  37. $FeedBack = $this->repository->create($data);
  38. event('user.feedback',compact('FeedBack'));
  39. return app('json')->success('反馈成功');
  40. }
  41. /**
  42. * 用户反馈列表
  43. * @return mixed
  44. * @author xaboy
  45. * @day 2020/5/28
  46. */
  47. public function feedbackList()
  48. {
  49. [$page, $limit] = $this->getPage();
  50. return app('json')->success($this->repository->getList(['uid' => $this->request->uid(),'is_del' => 0], $page, $limit));
  51. }
  52. /**
  53. * 反馈详情
  54. * @param $id
  55. * @return \think\response\Json
  56. * @author wuhaotian
  57. * @email 442384644@qq.com
  58. * @date 2024/7/10
  59. */
  60. public function detail($id)
  61. {
  62. if (!$this->repository->uidExists($id, $this->request->uid()))
  63. return app('json')->fail('数据不存在');
  64. $feedback = $this->repository->get($id);
  65. return app('json')->success($feedback);
  66. }
  67. }