DeviceMold.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /*
  3. * @Descripttion:
  4. * @version: 1.0.0
  5. * @Author: likang
  6. * @Date: 2022-05-27 13:34:31
  7. * @LastEditors: likang
  8. * @LastEditTime: 2022-08-05 09:26:09
  9. */
  10. namespace catchAdmin\hydraulic\controller;
  11. use catcher\base\CatchRequest as Request;
  12. use catcher\CatchResponse;
  13. use catcher\base\CatchController;
  14. use catchAdmin\hydraulic\model\DeviceMold as deviceMoldModel;
  15. class DeviceMold extends CatchController
  16. {
  17. protected $deviceMoldModel;
  18. public function __construct(DeviceMoldModel $deviceMoldModel)
  19. {
  20. $this->deviceMoldModel = $deviceMoldModel;
  21. }
  22. /**
  23. * 列表
  24. * @time 2022年05月06日 10:22
  25. * @param Request $request
  26. */
  27. public function index(Request $request): \think\Response
  28. {
  29. return CatchResponse::paginate($this->deviceMoldModel->getList());
  30. }
  31. /**
  32. * 保存信息
  33. * @time 2022年05月06日 10:22
  34. * @param Request $request
  35. */
  36. public function save(Request $request): \think\Response
  37. {
  38. return CatchResponse::success($this->deviceMoldModel->storeBy($request->post()));
  39. }
  40. /**
  41. * 读取
  42. * @time 2022年05月06日 10:22
  43. * @param $id
  44. */
  45. public function read($id): \think\Response
  46. {
  47. return CatchResponse::success($this->deviceMoldModel->findBy($id));
  48. }
  49. /**
  50. * 更新
  51. * @time 2022年05月06日 10:22
  52. * @param Request $request
  53. * @param $id
  54. */
  55. public function update(Request $request, $id): \think\Response
  56. {
  57. return CatchResponse::success($this->deviceMoldModel->updateBy($id, $request->post()));
  58. }
  59. /**
  60. * 删除
  61. * @time 2022年05月06日 10:22
  62. * @param $id
  63. */
  64. public function delete($id): \think\Response
  65. {
  66. return CatchResponse::success($this->deviceMoldModel->deleteBy($id, true));
  67. }
  68. /**
  69. * 根据设备类型获取设备型号
  70. * @time 2022年05月06日 10:22
  71. * @param $id
  72. */
  73. public function getDeviceMold(Request $request): \think\Response
  74. {
  75. $type = $request->get('type');
  76. return CatchResponse::success($this->deviceMoldModel->where('device_type', $type)->field('id as value,name as text')->select());
  77. }
  78. }