diff --git a/app/controller/api/dataview/Login.php b/app/controller/api/dataview/Login.php new file mode 100644 index 00000000..b010fcea --- /dev/null +++ b/app/controller/api/dataview/Login.php @@ -0,0 +1,53 @@ +request->post('account', ''); + $password = $this->request->post('password', ''); + if (!$account){ + return app('json')->fail('请输入账号'); + } + $user = Db::name('dataview_account')->where('account', $account)->find(); + + if (!$user) { + throw new ValidateException("账号不存在"); + } + + if (!md5($password) === $user['password']) { + $msg = '账号或密码错误'; + throw new ValidateException($msg); + } + + $expire = time()+ 3600 * 24; + $token = md5($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 082de479..d69d6519 100644 --- a/route/api.php +++ b/route/api.php @@ -764,7 +764,8 @@ Route::group('api/', function () { Route::get('financial_record', 'Finance/financialRecord'); Route::get('financial_record_detail/:type', 'Finance/financialDetail'); - + // login + Route::post('login', 'Login/login'); /**---------------------数据之眼可视化大屏api-------------------- end */