mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 19:12:48 +08:00
feat: 优化验证器逻辑
This commit is contained in:
@@ -6,7 +6,6 @@ use app\admin\model\SystemAdmin;
|
|||||||
use app\BaseController;
|
use app\BaseController;
|
||||||
use app\common\constants\AdminConstant;
|
use app\common\constants\AdminConstant;
|
||||||
use app\common\service\AuthService;
|
use app\common\service\AuthService;
|
||||||
use think\facade\Cache;
|
|
||||||
use think\facade\Config;
|
use think\facade\Config;
|
||||||
use think\facade\Env;
|
use think\facade\Env;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
@@ -303,19 +302,21 @@ class AdminControllerBase extends BaseController
|
|||||||
$batch = $this->batchValidate;
|
$batch = $this->batchValidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->validateRule instanceof Validate) {
|
if (!empty($validate)) {
|
||||||
$this->validateRule->message($message);
|
|
||||||
|
|
||||||
// 是否批量验证
|
|
||||||
if ($batch) {
|
|
||||||
$this->validateRule->batch(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->validateRule->failException(true)->check($data);
|
|
||||||
} elseif (is_array($this->validateRule)) {
|
|
||||||
parent::validate($data, $this->validateRule, $message, $batch);
|
|
||||||
} else {
|
|
||||||
parent::validate($data, $validate, $message, $batch);
|
parent::validate($data, $validate, $message, $batch);
|
||||||
|
} elseif (!empty($this->validateRule)) {
|
||||||
|
if ($this->validateRule instanceof Validate) {
|
||||||
|
$this->validateRule->message($message);
|
||||||
|
|
||||||
|
// 是否批量验证
|
||||||
|
if ($batch) {
|
||||||
|
$this->validateRule->batch(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->validateRule->failException(true)->check($data);
|
||||||
|
} elseif (is_array($this->validateRule)) {
|
||||||
|
parent::validate($data, $this->validateRule, $message, $batch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->error($e->getMessage());
|
$this->error($e->getMessage());
|
||||||
@@ -521,7 +522,8 @@ class AdminControllerBase extends BaseController
|
|||||||
$this->assign('session_admin', $model_admin, -1);
|
$this->assign('session_admin', $model_admin, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function readHeaderToken(){
|
protected function readHeaderToken()
|
||||||
|
{
|
||||||
return read_header_token();
|
return read_header_token();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user