StoreProductProtection.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\adminapi\controller\v1\product;
  3. use app\adminapi\controller\AuthController;
  4. use app\services\product\product\StoreProductProtectionServices;
  5. use think\facade\App;
  6. class StoreProductProtection extends AuthController
  7. {
  8. public function __construct(App $app, StoreProductProtectionServices $services)
  9. {
  10. parent::__construct($app);
  11. $this->services = $services;
  12. }
  13. public function protectionList()
  14. {
  15. $where = $this->request->getMore([
  16. ['title', ''],
  17. ['status', '']
  18. ]);
  19. $where['is_del'] = 0;
  20. return app('json')->success($this->services->protectionList($where));
  21. }
  22. public function protectionInfo($id)
  23. {
  24. if (!$id) return app('json')->fail('参数错误');
  25. $info = $this->services->protectionInfo($id);
  26. return app('json')->success($info);
  27. }
  28. public function protectionForm($id)
  29. {
  30. return app('json')->success($this->services->protectionForm($id));
  31. }
  32. public function protectionSave($id)
  33. {
  34. $data = $this->request->postMore([
  35. ['title', ''],
  36. ['content', ''],
  37. ['image', ''],
  38. ['sort', 0],
  39. ['status', 0]
  40. ]);
  41. $this->services->protectionSave($id, $data);
  42. return app('json')->success('保存成功');
  43. }
  44. public function protectionStatus($id, $status)
  45. {
  46. if (!$id) return app('json')->fail('参数错误');
  47. $this->services->protectionStatus($id, $status);
  48. return app('json')->success('修改成功');
  49. }
  50. public function protectionDel($id)
  51. {
  52. if (!$id) return app('json')->fail('参数错误');
  53. $this->services->protectionDel($id);
  54. return app('json')->success('删除成功');
  55. }
  56. }