Synscheme.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace catchAdmin\synscheme\controller;
  3. use catcher\base\CatchRequest as Request;
  4. use catcher\CatchResponse;
  5. use catcher\base\CatchController;
  6. use catchAdmin\synscheme\model\Synscheme as synschemeModel;
  7. class Synscheme extends CatchController
  8. {
  9. protected $synschemeModel;
  10. public function __construct(SynschemeModel $synschemeModel)
  11. {
  12. $this->synschemeModel = $synschemeModel;
  13. }
  14. /**
  15. * 列表
  16. * @time 2022年05月09日 19:06
  17. * @param Request $request
  18. */
  19. public function index(Request $request) : \think\Response
  20. {
  21. return CatchResponse::paginate($this->synschemeModel->getList());
  22. }
  23. /**
  24. * 保存信息
  25. * @time 2022年05月09日 19:06
  26. * @param Request $request
  27. */
  28. public function save(Request $request) : \think\Response
  29. {
  30. return CatchResponse::success($this->synschemeModel->storeBy($request->post()));
  31. }
  32. /**
  33. * 读取
  34. * @time 2022年05月09日 19:06
  35. * @param $id
  36. */
  37. public function read($id) : \think\Response
  38. {
  39. return CatchResponse::success($this->synschemeModel->findBy($id));
  40. }
  41. /**
  42. * 更新
  43. * @time 2022年05月09日 19:06
  44. * @param Request $request
  45. * @param $id
  46. */
  47. public function update(Request $request, $id) : \think\Response
  48. {
  49. return CatchResponse::success($this->synschemeModel->updateBy($id, $request->post()));
  50. }
  51. /**
  52. * 删除
  53. * @time 2022年05月09日 19:06
  54. * @param $id
  55. */
  56. public function delete($id) : \think\Response
  57. {
  58. return CatchResponse::success($this->synschemeModel->deleteBy($id));
  59. }
  60. /**
  61. * 获取方案
  62. * @param Request $request
  63. * @return void
  64. */
  65. public function getSynscheme(Request $request)
  66. {
  67. $data =$request->get();
  68. $where=[];
  69. if(!empty($data['id']))
  70. { $ids =implode(",",$data['id']);
  71. $where[] = ['id','in',$ids];
  72. }
  73. $syn_list=$this->synschemeModel->where($where)->select();
  74. return CatchResponse::success($syn_list);
  75. }
  76. /**
  77. * 选择同步方案
  78. *
  79. * @param Request $request
  80. * @return void
  81. */
  82. public function chooseSynscheme(Request $request)
  83. {
  84. $list = $this->synschemeModel->field('id as value,name as text')->select();
  85. return CatchResponse::success($list);
  86. }
  87. }