VehicleBrand.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace catchAdmin\yunying\controller;
  3. use catcher\base\CatchRequest as Request;
  4. use catcher\CatchResponse;
  5. use catcher\base\CatchController;
  6. use catchAdmin\yunying\model\VehicleBrand as vehicleBrandModel;
  7. class VehicleBrand extends CatchController
  8. {
  9. protected $vehicleBrandModel;
  10. public function __construct(vehicleBrandModel $vehicleBrandModel)
  11. {
  12. $this->vehicleBrandModel = $vehicleBrandModel;
  13. }
  14. /**
  15. * 列表
  16. * @time 2022年01月20日 11:28
  17. * @param Request $request
  18. */
  19. public function index(Request $request) : \think\Response
  20. {
  21. $field = $request->get('field')?:'id';
  22. $order = $request->get('order')?:'desc';
  23. return CatchResponse::paginate($this->vehicleBrandModel->getBrandList($field,$order));
  24. }
  25. /**
  26. * 保存信息
  27. * @time 2022年01月20日 11:28
  28. * @param Request $request
  29. */
  30. public function save(Request $request) : \think\Response
  31. {
  32. return CatchResponse::success($this->vehicleBrandModel->storeBy($request->post()));
  33. }
  34. /**
  35. * 读取
  36. * @time 2022年01月20日 11:28
  37. * @param $id
  38. */
  39. public function read($id) : \think\Response
  40. {
  41. return CatchResponse::success($this->vehicleBrandModel->findBy($id));
  42. }
  43. /**
  44. * 更新
  45. * @time 2022年01月20日 11:28
  46. * @param Request $request
  47. * @param $id
  48. */
  49. public function update(Request $request, $id) : \think\Response
  50. {
  51. return CatchResponse::success($this->vehicleBrandModel->updateBy($id, $request->post()));
  52. }
  53. /**
  54. * 删除
  55. * @time 2022年01月20日 11:28
  56. * @param $id
  57. */
  58. public function delete($id) : \think\Response
  59. {
  60. return CatchResponse::success($this->vehicleBrandModel->deleteBy($id));
  61. }
  62. }