Reply.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CatchAdmin [Just Like ~ ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
  8. // +----------------------------------------------------------------------
  9. // | Author: JaguarJack [ njphper@gmail.com ]
  10. // +----------------------------------------------------------------------
  11. namespace catchAdmin\wechat\controller;
  12. use catchAdmin\wechat\repository\WechatReplyRepository;
  13. use catcher\base\CatchController;
  14. use catcher\base\CatchRequest;
  15. use catcher\CatchResponse;
  16. class Reply extends CatchController
  17. {
  18. protected $reply;
  19. public function __construct(WechatReplyRepository $reply)
  20. {
  21. $this->reply = $reply;
  22. }
  23. /**
  24. * 列表
  25. *
  26. * @time 2020年06月29日
  27. * @param CatchRequest $request
  28. * @return \think\response\Json
  29. */
  30. public function index(CatchRequest $request)
  31. {
  32. return CatchResponse::paginate($this->reply->getList());
  33. }
  34. /**
  35. * 读取
  36. *
  37. * @time 2020年09月13日
  38. * @param $id
  39. * @return \think\response\Json
  40. */
  41. public function read($id)
  42. {
  43. return CatchResponse::success($this->reply->findBy($id));
  44. }
  45. /**
  46. * 保存
  47. *
  48. * @time 2020年06月29日
  49. * @param CatchRequest $request
  50. * @return \think\response\Json
  51. */
  52. public function save(CatchRequest $request)
  53. {
  54. return CatchResponse::success($this->reply->storeBy($request->param()));
  55. }
  56. /**
  57. * 更新
  58. *
  59. * @time 2020年09月13日
  60. * @param $id
  61. * @param CatchRequest $request
  62. * @return \think\response\Json
  63. */
  64. public function update($id, CatchRequest $request)
  65. {
  66. return CatchResponse::success($this->reply->updateBy($id, $request->param()));
  67. }
  68. /**
  69. * 删除
  70. *
  71. * @time 2020年06月29日
  72. * @param $id
  73. * @return \think\response\Json
  74. */
  75. public function delete($id)
  76. {
  77. return CatchResponse::success($this->reply->deleteBy($id));
  78. }
  79. /**
  80. * 禁用启用
  81. *
  82. * @time 2020年06月29日
  83. * @param $id
  84. * @return \think\response\Json
  85. */
  86. public function disOrEnable($id)
  87. {
  88. return CatchResponse::success($this->reply->disOrEnable($id));
  89. }
  90. }