Commit 61a677fe by 宁成龙

新增邮箱判断

parent 56373fb8
...@@ -111,6 +111,12 @@ class UserService ...@@ -111,6 +111,12 @@ class UserService
{ {
try { try {
DB::beginTransaction(); DB::beginTransaction();
//判断邮箱是否唯一
$email = $params['email'] ?? '';
$userInfo = User::getInfoByEmail($email);
if ($userInfo) {
throw new \Exception("user email already exists");
}
$userData = [ $userData = [
"company_name" => $params["company_name"] ?? "", "company_name" => $params["company_name"] ?? "",
"user_sn" => $params["user_sn"] ?? "", "user_sn" => $params["user_sn"] ?? "",
......
...@@ -64,6 +64,12 @@ class User extends BaseModel ...@@ -64,6 +64,12 @@ class User extends BaseModel
$res = self::where('id', $userId)->first(); $res = self::where('id', $userId)->first();
return ($res) ? $res->toArray() : []; return ($res) ? $res->toArray() : [];
} }
//根据邮箱获取用户信息
public static function getInfoByEmail($email)
{
$res = self::where('email', $email)->first();
return ($res) ? $res->toArray() : [];
}
// 批量获取用户信息 // 批量获取用户信息
public static function getInfoByUserIds($userId) public static function getInfoByUserIds($userId)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment