add 大屏登录
This commit is contained in:
parent
458b0cc791
commit
ac992fc93f
53
app/controller/api/dataview/Login.php
Normal file
53
app/controller/api/dataview/Login.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\api\dataview;
|
||||
use app\common\repositories\user\UserRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\App;
|
||||
|
||||
use think\facade\Db;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
|
||||
class Login extends BaseController
|
||||
{
|
||||
/**
|
||||
* @var repository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
public $areaCode; // 区县地区码
|
||||
|
||||
public $streetCode; // 镇街道地区码
|
||||
|
||||
|
||||
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
public function login(UserRepository $repository)
|
||||
{
|
||||
$account = $this->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'));
|
||||
}
|
||||
|
||||
}
|
@ -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 */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user