Hydraulic.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace catchAdmin\hydraulic\controller;
  3. use catcher\base\CatchRequest as Request;
  4. use catcher\CatchResponse;
  5. use catcher\base\CatchController;
  6. use catchAdmin\hydraulic\model\Hydraulic as hydraulicModel;
  7. class Hydraulic extends CatchController
  8. {
  9. protected $hydraulicModel;
  10. public function __construct(HydraulicModel $hydraulicModel)
  11. {
  12. $this->hydraulicModel = $hydraulicModel;
  13. }
  14. /**
  15. * 列表
  16. * @time 2022年03月03日 14:28
  17. * @param Request $request
  18. */
  19. public function index(Request $request) : \think\Response
  20. {
  21. return CatchResponse::paginate($this->hydraulicModel->getList());
  22. }
  23. /**
  24. * 保存信息
  25. * @time 2022年03月03日 14:28
  26. * @param Request $request
  27. */
  28. public function save(Request $request) : \think\Response
  29. {
  30. $data = $request->post();
  31. if(isset($data['out_date']) && is_int($data['out_date'])){
  32. $data['out_date'] = date('Y-m-d',$data['out_date']);
  33. }
  34. return CatchResponse::success($this->hydraulicModel->storeBy($data));
  35. }
  36. /**
  37. * 读取
  38. * @time 2022年03月03日 14:28
  39. * @param $id
  40. */
  41. public function read($id) : \think\Response
  42. {
  43. return CatchResponse::success($this->hydraulicModel->findBy($id));
  44. }
  45. /**
  46. * 更新
  47. * @time 2022年03月03日 14:28
  48. * @param Request $request
  49. * @param $id
  50. */
  51. public function update(Request $request, $id) : \think\Response
  52. {
  53. $data = $request->post();
  54. if(isset($data['out_date']) && is_int($data['out_date'])){
  55. $data['out_date'] = date('Y-m-d',$data['out_date']);
  56. }
  57. return CatchResponse::success($this->hydraulicModel->updateBy($id, $data));
  58. }
  59. /**
  60. * 删除
  61. * @time 2022年03月03日 14:28
  62. * @param $id
  63. */
  64. public function delete($id) : \think\Response
  65. {
  66. return CatchResponse::success($this->hydraulicModel->deleteBy($id,true));
  67. }
  68. }