RechargeGoodsController.php 948 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\admin\controller\goods;
  3. use app\admin\service\goods\GoodsService;
  4. use app\admin\validate\goods\GoodsValidate;
  5. use support\Request;
  6. use support\Response;
  7. class RechargeGoodsController
  8. {
  9. public function select(Request $request)
  10. {
  11. return GoodsService::select($request, 'RECHARGE');
  12. }
  13. public function insert(Request $request): Response
  14. {
  15. $params = $request->post();
  16. $validate = new GoodsValidate();
  17. if (!$validate->scene('add')->check($params)) {
  18. return json_fail($validate->getError());
  19. }
  20. return GoodsService::insertRecharge($params);
  21. }
  22. public function update(Request $request): Response
  23. {
  24. $validate = new GoodsValidate();
  25. if (!$validate->scene('update')->check($request->post())) {
  26. return json_fail($validate->getError());
  27. }
  28. return GoodsService::updateRecharge($request->post());
  29. }
  30. }