DefaultController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace addons\Scratch\api\modules\v1\controllers;
  3. use addons\Scratch\api\modules\v1\services\DefaultService;
  4. use addons\Scratch\common\models\ScratchModel;
  5. use addons\Distribution\common\enums\DistributionEnum;
  6. use common\enums\StatusEnum;
  7. use common\models\common\CapitalLog;
  8. use common\models\order\OrderDetail;
  9. use Yii;
  10. use api\controllers\OnAuthController;
  11. /**
  12. * 默认控制器
  13. *
  14. * Class DefaultController
  15. * @package addons\Scratch\api\modules\v1\controllers
  16. */
  17. class DefaultController extends OnAuthController
  18. {
  19. public $modelClass = '';
  20. public $from_type = ['Scratch'];
  21. /**
  22. * 不用进行登录验证的方法
  23. *
  24. * 例如: ['index', 'update', 'create', 'view', 'delete']
  25. * 默认全部需要验证
  26. *
  27. * @var array
  28. */
  29. protected $authOptional = ['index'];
  30. /**
  31. * 首页
  32. *
  33. * @return string
  34. */
  35. public function actionIndex()
  36. {
  37. return 'Scratch,Hello world!!!!!';
  38. }
  39. /**
  40. * @return mixed|void
  41. */
  42. public function actionInfo()
  43. {
  44. try {
  45. if(!\Yii::$app->request->isGet){
  46. throw new \ErrorException('NOT IS GET!');
  47. }
  48. $this->success('ok', DefaultService::getInfo(
  49. $this->mall_id,
  50. $this->user
  51. ));
  52. }catch (\ErrorException $errorException){
  53. $this->error($errorException->getMessage());
  54. }catch (\Exception $exception){
  55. $this->error($exception->getMessage());
  56. }
  57. }
  58. /**
  59. *
  60. */
  61. public function actionLogList()
  62. {
  63. try {
  64. if(!\Yii::$app->request->isGet){
  65. throw new \ErrorException('NOT IS GET!');
  66. }
  67. $page = \Yii::$app->request->get('page', 1);
  68. $limit = \Yii::$app->request->get('limit', 10);
  69. $capitalType = \Yii::$app->request->get('capital_type', '');
  70. $this->success('ok', DefaultService::getLogList(
  71. $this->mall_id,
  72. $this->user,
  73. $this->from_type,
  74. $capitalType,
  75. $page,
  76. $limit
  77. ));
  78. }catch (\ErrorException $errorException){
  79. $this->error($errorException->getMessage());
  80. }catch (\Exception $exception){
  81. $this->error($exception->getMessage());
  82. }
  83. }
  84. }