StuckSection.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace catchAdmin\transport\controller;
  3. use catcher\base\CatchRequest as Request;
  4. use catcher\CatchResponse;
  5. use catcher\base\CatchController;
  6. use catchAdmin\transport\model\StuckSection as stuckSectionModel;
  7. class StuckSection extends CatchController
  8. {
  9. protected $stuckSectionModel;
  10. public function __construct(StuckSectionModel $stuckSectionModel)
  11. {
  12. $this->stuckSectionModel = $stuckSectionModel;
  13. }
  14. /**
  15. * 列表
  16. * @time 2022年11月01日 16:27
  17. * @param Request $request
  18. */
  19. public function index(Request $request) : \think\Response
  20. {
  21. return CatchResponse::paginate($this->stuckSectionModel->getList());
  22. }
  23. /**
  24. * 保存信息
  25. * @time 2022年11月01日 16:27
  26. * @param Request $request
  27. */
  28. public function save(Request $request) : \think\Response
  29. {
  30. return CatchResponse::success($this->stuckSectionModel->storeBy($request->post()));
  31. }
  32. /**
  33. * 读取
  34. * @time 2022年11月01日 16:27
  35. * @param $id
  36. */
  37. public function read($id) : \think\Response
  38. {
  39. return CatchResponse::success($this->stuckSectionModel->findBy($id));
  40. }
  41. /**
  42. * 更新
  43. * @time 2022年11月01日 16:27
  44. * @param Request $request
  45. * @param $id
  46. */
  47. public function update(Request $request, $id) : \think\Response
  48. {
  49. return CatchResponse::success($this->stuckSectionModel->updateBy($id, $request->post()));
  50. }
  51. /**
  52. * 删除
  53. * @time 2022年11月01日 16:27
  54. * @param $id
  55. */
  56. public function delete($id) : \think\Response
  57. {
  58. return CatchResponse::success($this->stuckSectionModel->deleteBy($id));
  59. }
  60. /**
  61. *
  62. * @time 2019年12月07日
  63. * @param $id
  64. * @return \think\response\Json
  65. */
  66. public function switchRetrograde($id): \think\response\Json
  67. {
  68. $info = $this->stuckSectionModel->findBy($id);
  69. $this->stuckSectionModel->updateBy($id, [
  70. 'retrograde_stat' => $info->retrograde_stat == 1 ? 0 : 1,
  71. ]);
  72. return CatchResponse::success([], '操作成功');
  73. }
  74. /**
  75. *
  76. * @time 2019年12月07日
  77. * @param $id
  78. * @return \think\response\Json
  79. */
  80. public function switchOverSpeed($id): \think\response\Json
  81. {
  82. $info = $this->stuckSectionModel->findBy($id);
  83. $this->stuckSectionModel->updateBy($id, [
  84. 'over_speed_stat' => $info->over_speed_stat == 1 ? 0 : 1,
  85. ]);
  86. return CatchResponse::success([], '操作成功');
  87. }
  88. }