From ac4023b113e0d17bcdd23b6ddd1eaca1550916c2 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Fri, 8 Dec 2023 18:31:29 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=95=B0=E6=8D=AE=E4=B9=8B=E8=A8=80-?= =?UTF-8?q?=E5=95=86=E6=88=B7=E7=99=BB=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Login.php | 23 ++++++++++++++++++++++- route/api.php | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/controller/api/dataview/Login.php b/app/controller/api/dataview/Login.php index a33cd145..7d9b0aa7 100644 --- a/app/controller/api/dataview/Login.php +++ b/app/controller/api/dataview/Login.php @@ -39,8 +39,29 @@ class Login extends BaseController $expire = time()+ 3600 * 24; $token = md5($expire); // 缓存token - Cache::set($token.'_'.$user['uid'], $expire); + Cache::set($token.'_dataview_'.$user['id'], $expire); + return app('json')->success(compact('user','token', 'expire')); + } + public function mechantLogin(UserRepository $repository) + { + $account = $this->request->param('account'); + $password= $this->request->param('password'); + + if (!$account) return app('json')->fail('请输入账号'); + + $user = $repository->accountByUser($account); + + if (!$user)return app('json')->fail('账号不存在');; + if (!password_verify($password, $user['pwd'])) { + $msg = '账号或密码错误'; + throw new ValidateException($msg); + } + $expire = time()+ 3600 * 24; + $token = md5($expire); + // 缓存token + Cache::set($token.'_merchant_'.$user['uid'], $expire); return app('json')->success(compact('user','token', 'expire')); } + } \ No newline at end of file diff --git a/route/api.php b/route/api.php index d69d6519..38f63fcb 100644 --- a/route/api.php +++ b/route/api.php @@ -766,6 +766,7 @@ Route::group('api/', function () { // login Route::post('login', 'Login/login'); + Route::post('mechant_login', 'Login/mechantLogin'); /**---------------------数据之眼可视化大屏api-------------------- end */