feat : basic

This commit is contained in:
2024-11-12 11:02:38 +08:00
parent 235acbea9c
commit a9f81888b7
26 changed files with 342 additions and 209 deletions

View File

@@ -13,7 +13,7 @@ namespace App\Service\Api\Login;
use App\Cache\Redis\Api\ApiRedisKey;
use App\Cache\Redis\RedisCache;
use App\Constants\Common\UserCode;
use App\Exception\ApiException;
use App\Exception\ErrException;
use App\Extend\StringUtil;
use App\Extend\SystemUtil;
use App\Lib\Crypto\CryptoFactory;
@@ -91,7 +91,7 @@ abstract class LoginBaseService extends BaseService
$this->userId = empty($this->userId) ? $this->userInfo->id : $this->userId;
if (empty($this->userId)) {
throw new ApiException('登录失败');
throw new ErrException('登录失败');
}
//todo 判断注销 判断封号
@@ -137,7 +137,7 @@ abstract class LoginBaseService extends BaseService
};
if (0 == ($this->redis->addLock($this->lockKey))){
throw new ApiException('请勿重复点击');
throw new ErrException('请勿重复点击');
}
}
@@ -154,7 +154,7 @@ abstract class LoginBaseService extends BaseService
$model->avatar_id = 0;
$model->reg_ip = SystemUtil::getClientIp();
if (!$model->save()) throw new ApiException('数据保存失败-注册失败');
if (!$model->save()) throw new ErrException('数据保存失败-注册失败');
$this->userId = $model->id;
$this->userInfo = $model;

View File

@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace App\Service\Api\Login;
use App\Exception\AdminException;
use App\Exception\ErrException;
use App\Service\Api\BaseService;
class LoginService extends BaseService
@@ -26,7 +26,7 @@ class LoginService extends BaseService
{
'wx_login' => $factory->wxFastLogin(),
'mobile_code' => $factory->mobileCodeLogin(),
default => throw new AdminException('登录类型错误'),
default => throw new ErrException('登录类型错误'),
};
$loginInfo = $service->handle();

View File

@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace App\Service\Api\Login;
use App\Exception\ApiException;
use App\Exception\ErrException;
use App\Model\UserThird;
use App\Service\ServiceTrait\Api\WxMiniTrait;
use Hyperf\DbConnection\Db;
@@ -37,7 +37,7 @@ class WxFastLoginService extends LoginBaseService
{
$this->jsCode = $this->request->input('js_code');
if (empty($this->jsCode)) throw new ApiException('登录参数错误');
if (empty($this->jsCode)) throw new ErrException('登录参数错误');
$wxInfo = $this->jsCodeGetOpenId($this->jsCode);
$this->openId = $wxInfo['openid'];
@@ -88,6 +88,6 @@ class WxFastLoginService extends LoginBaseService
$model->open_id = $this->openId;
$model->union_id = $this->unionId;
if (!$model->save()) throw new ApiException('注册失败-00001');
if (!$model->save()) throw new ErrException('注册失败-00001');
}
}