mirror of
https://gitee.com/zhc02/timely_service.git
synced 2025-06-26 04:21:19 +08:00
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* Author: baihu
|
|
* Date: 2019/12/16
|
|
* Time: 15:29
|
|
*/
|
|
|
|
namespace Logic;
|
|
|
|
use think\Db;
|
|
use exception\LogicException;
|
|
use exception\BaseException;
|
|
use think\Exception;
|
|
use exception\ResponsableException;
|
|
class AdminLogic
|
|
{
|
|
/**
|
|
* 登录逻辑
|
|
* @param $account 账号
|
|
* @param $password 密码
|
|
* @return array
|
|
*/
|
|
public static function LoginAdmin($account, $password)
|
|
{
|
|
try {
|
|
|
|
$info = Db::name('admin')->where('account', $account)->find();
|
|
if (!$info) {
|
|
throw new LogicException('账户不存在', 1001);
|
|
}
|
|
if (strtoupper(md5($password)) != $info['password']) {
|
|
throw new LogicException('密码错误', 1002);
|
|
}
|
|
return $info;
|
|
} catch (BaseException $be) {
|
|
throw new ResponsableException($be->getMessage(), $be->getCode());
|
|
} catch (Exception $e) {
|
|
throw new ResponsableException('登录失败', 404);
|
|
}
|
|
}
|
|
}
|