2018-11-29 22:44:16 +08:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* UserRequest.php
|
|
|
|
* Created by wuyanwen <wuyanwen1992@gmail.com>
|
|
|
|
* Date: 2018/11/29 0029 21:56
|
|
|
|
*/
|
|
|
|
namespace app\admin\request;
|
|
|
|
|
|
|
|
use think\Request;
|
|
|
|
|
|
|
|
abstract class FormRequest extends Request
|
|
|
|
{
|
2018-11-30 09:56:27 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* FormRequest constructor.
|
|
|
|
*/
|
2018-11-29 22:44:16 +08:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
2018-11-30 09:56:27 +08:00
|
|
|
if ($this->withServer($_SERVER)->isAjax(true) && $err = $this->validate()) {
|
|
|
|
exit($this->error($err));
|
|
|
|
}
|
2018-11-29 22:44:16 +08:00
|
|
|
}
|
|
|
|
|
2018-11-30 09:56:27 +08:00
|
|
|
protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
|
|
|
|
{
|
2018-11-29 22:44:16 +08:00
|
|
|
|
2018-11-30 09:56:27 +08:00
|
|
|
return json([
|
|
|
|
'code' => 0,
|
|
|
|
'msg' => $msg,
|
|
|
|
'data' => $data,
|
|
|
|
'url' => $url,
|
|
|
|
'wait' => $wait,
|
|
|
|
])->send();
|
|
|
|
}
|
2018-11-29 22:44:16 +08:00
|
|
|
|
|
|
|
}
|