GoodsController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: admin
  5. * Date: 2019/12/1
  6. * Time: 13:55
  7. */
  8. namespace business\controllers;
  9. use Yii;
  10. use common\components\util;
  11. use biz\goods\services\GoodsService;
  12. class GoodsController extends BaseController
  13. {
  14. //index,view,create,update,delete,options
  15. public $enableCsrfValidation = false;
  16. public function actionList()
  17. {
  18. $where = null;
  19. $list = GoodsService::getGoodsList($where);
  20. util::success($list);
  21. }
  22. public function actionCreate()
  23. {
  24. $data = Yii::$app->request->get();
  25. GoodsService::add($data);
  26. }
  27. public function actionView()
  28. {
  29. $id = Yii::$app->request->get('id');
  30. $good = GoodsService::getById($id);
  31. util::success($good);
  32. }
  33. public function actionUpdate()
  34. {
  35. $data = Yii::$app->request->get();
  36. $id = $data['id'];
  37. $re = GoodsService::updateById($id, $data);
  38. util::success($re);
  39. }
  40. public function actionDelete()
  41. {
  42. $id = Yii::$app->request->get('id');
  43. $good = GoodsService::deleteById($id);
  44. //util::success($good);
  45. }
  46. }