CommunityReply.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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\community;
  12. use crmeb\basic\BaseController;
  13. use think\App;
  14. use app\common\repositories\community\CommunityReplyRepository as repository;
  15. class CommunityReply extends BaseController
  16. {
  17. /**
  18. * @var CommunityReplyRepository
  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', 'date', 'username', 'community_id', 'pid']);
  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 delete($id)
  47. {
  48. if (!$this->repository->exists($id))
  49. return app('json')->fail('数据不存在');
  50. $this->repository->update($id, ['is_del' => 1]);
  51. return app('json')->success('删除成功');
  52. }
  53. public function statusForm($id)
  54. {
  55. if (!$this->repository->exists($id))
  56. return app('json')->fail('数据不存在');
  57. return app('json')->success(formToData($this->repository->statusForm($id)));
  58. }
  59. public function switchStatus($id)
  60. {
  61. $data = $this->request->params(['status', 'refusal']);
  62. if (!in_array($data['status'], [1, -1]))
  63. return app('json')->fail('审核类型错误');
  64. if ($data['status'] == -1 && empty($data['refusal']))
  65. return app('json')->fail('请填写拒绝理由');
  66. if (!$this->repository->exists($id))
  67. return app('json')->fail('数据不存在');
  68. $this->repository->update($id, $data);
  69. return app('json')->success('审核成功');
  70. }
  71. }