StoreProductRule.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\product;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\product\sku\StoreProductRuleServices;
  14. use think\facade\App;
  15. /**
  16. * 规则管理
  17. * Class StoreProductRule
  18. * @package app\adminapi\controller\v1\product
  19. */
  20. class StoreProductRule extends AuthController
  21. {
  22. public function __construct(App $app, StoreProductRuleServices $service)
  23. {
  24. parent::__construct($app);
  25. $this->services = $service;
  26. }
  27. /**
  28. * 规格列表
  29. * @return mixed
  30. * @throws \think\db\exception\DataNotFoundException
  31. * @throws \think\db\exception\DbException
  32. * @throws \think\db\exception\ModelNotFoundException
  33. */
  34. public function index()
  35. {
  36. $where = $this->request->getMore([
  37. ['rule_name', '']
  38. ]);
  39. $list = $this->services->getList($where);
  40. return app('json')->success($list);
  41. }
  42. /**
  43. * 保存规格
  44. * @param $id
  45. * @return mixed
  46. */
  47. public function save($id)
  48. {
  49. $data = $this->request->postMore([
  50. ['rule_name', ''],
  51. ['spec', []]
  52. ]);
  53. $this->services->save($id, $data);
  54. return app('json')->success(100000);
  55. }
  56. /**
  57. * 获取规格信息
  58. * @param $id
  59. * @return mixed
  60. */
  61. public function read($id)
  62. {
  63. $info = $this->services->getInfo($id);
  64. return app('json')->success($info);
  65. }
  66. /**
  67. * 删除指定资源
  68. *
  69. * @param int $id
  70. * @return \think\Response
  71. */
  72. public function delete()
  73. {
  74. [$ids] = $this->request->postMore([
  75. ['ids', '']
  76. ], true);
  77. $this->services->del((string)$ids);
  78. return app('json')->success(100002);
  79. }
  80. }