| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\api\validate;
- use think\exception\HttpResponseException;
- use think\Request;
- use think\Response;
- use think\Validate;
- /**
- * Class BaseApiValidate
- * @package app\api\validate
- */
- class BaseApiValidate extends Validate
- {
- /**
- * @param array $rules
- * @param string $scene
- * @return array|bool|mixed|null
- */
- public function checkBody($rules = [], $scene = '')
- {
- $data = Request::instance()->param();
- $check = parent::check($data, $rules, $scene); // TODO: Change the autogenerated stub
- if (!$check) {
- $response = Response::create([
- 'code' => 0,
- 'msg' => $this->getError(),
- 'time' => Request::instance()->server('REQUEST_TIME'),
- 'data' => null,
- ], 'json')->header([]);
- throw new HttpResponseException($response);
- }
- return $data;
- }
- }
|