FeedBack.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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\admin\user;
  12. use crmeb\basic\BaseController;
  13. use think\App;
  14. use app\common\repositories\user\FeedbackRepository as repository;
  15. class FeedBack extends BaseController
  16. {
  17. /**
  18. * @var UserRepository
  19. */
  20. protected $repository;
  21. /**
  22. * User constructor.
  23. * @param App $app
  24. * @param $repository
  25. */
  26. public function __construct(App $app, repository $repository)
  27. {
  28. parent::__construct($app);
  29. $this->repository = $repository;
  30. }
  31. /**
  32. * @return mixed
  33. * @author Qinii
  34. */
  35. public function lst()
  36. {
  37. $where = $this->request->params(['keyword', 'type', 'status','realname',['is_del',0]]);
  38. [$page, $limit] = $this->getPage();
  39. return app('json')->success($this->repository->getList($where, $page, $limit));
  40. }
  41. /**
  42. * @param $id
  43. * @return mixed
  44. * @author Qinii
  45. */
  46. public function detail($id)
  47. {
  48. if (!$this->repository->fieldExists('feedback_id',$id))
  49. return app('json')->fail('数据不存在');
  50. $feedback = $this->repository->get($id)->toArray();
  51. [$feedback['category'], $feedback['type']] = explode('/', $feedback['type'], 2);
  52. return app('json')->success($feedback);
  53. }
  54. /**
  55. * @param $id
  56. * @return mixed
  57. * @throws \think\db\exception\DbException
  58. * @author Qinii
  59. */
  60. public function reply($id)
  61. {
  62. if (!$this->repository->fieldExists('feedback_id',$id))
  63. return app('json')->fail('数据不存在');
  64. $data = $this->request->params(['reply', 'remake', ['status',0]]);
  65. $this->repository->update($id,$data);
  66. return app('json')->success('回复成功');
  67. }
  68. /**
  69. * @param $id
  70. * @return mixed
  71. * @author Qinii
  72. */
  73. public function delete($id)
  74. {
  75. if (!$this->repository->fieldExists('feedback_id',$id))
  76. return app('json')->fail('数据不存在');
  77. $this->repository->update($id,['is_del' => 1]);
  78. return app('json')->success('删除成功');
  79. }
  80. public function switchStatus($id)
  81. {
  82. $status = $this->request->param('status', 0) == 1 ? 1 : 0;
  83. if (!$this->repository->merExists($id))
  84. return app('json')->fail('数据不存在');
  85. $this->repository->update($id,['status' => $status]);
  86. return app('json')->success('修改成功');
  87. }
  88. }