|
|
|
@ -19,6 +19,34 @@ class UserService extends BaseService |
|
|
|
$this->dao = $dao; |
|
|
|
} |
|
|
|
|
|
|
|
public function register($params) |
|
|
|
{ |
|
|
|
$user = $this->dao->getModel()->where(function ($query) use ($params){ |
|
|
|
$query->where('phone', '=', $params['phone']); |
|
|
|
})->find(); |
|
|
|
if ($user) { |
|
|
|
throw new ApiException(trans(400007), 400007); |
|
|
|
} |
|
|
|
//验证码验证
|
|
|
|
if(env('APP_DEBUG') != true){ |
|
|
|
$captcha = new Captcha(); |
|
|
|
$res = $captcha->verify($params['phone'],$params['code'],"register"); |
|
|
|
if($res['code'] != 200){ |
|
|
|
throw new ApiException($res['msg']); |
|
|
|
} |
|
|
|
} |
|
|
|
$res = $this->dao->save([ |
|
|
|
'name' => $params['name'], |
|
|
|
'account' => $params['phone'], |
|
|
|
'phone' => $params['phone'], |
|
|
|
'password' => password_hash(12345678, PASSWORD_ARGON2I), |
|
|
|
'gender' => $params['gender'] ?? '' |
|
|
|
]); |
|
|
|
if (!$res) { |
|
|
|
throw new ApiException(trans(400008), 400008); |
|
|
|
} |
|
|
|
return $res; |
|
|
|
} |
|
|
|
|
|
|
|
// 用户登录
|
|
|
|
public function login($params) |
|
|
|
@ -39,6 +67,9 @@ class UserService extends BaseService |
|
|
|
$user = $this->dao->getModel()->where(function ($query) use ($params){ |
|
|
|
$query->where('phone', '=', $params['phone']); |
|
|
|
})->find(); |
|
|
|
if (!$user) { |
|
|
|
throw new ApiException(trans(502001), 502001); |
|
|
|
} |
|
|
|
//验证码验证
|
|
|
|
if(env('APP_DEBUG') != true){ |
|
|
|
$captcha = new Captcha(); |
|
|
|
|