|
|
@@ -2,12 +2,15 @@ package service |
|
|
|
|
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"gim/internal/business/comm/db" |
|
|
|
"gim/internal/business/domain/user/model" |
|
|
|
"gim/internal/business/domain/user/repo" |
|
|
|
"gim/pkg/gerrors" |
|
|
|
"gim/pkg/pb" |
|
|
|
"gim/pkg/rpc" |
|
|
|
"gim/pkg/util" |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
@@ -16,7 +19,7 @@ type authService struct{} |
|
|
|
var AuthService = new(authService) |
|
|
|
|
|
|
|
// SignIn 登录 |
|
|
|
func (*authService) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64) (bool, int64, string, int64, error) { |
|
|
|
func (*authService) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64, pushAlia string) (bool, int64, string, int64, error) { |
|
|
|
if !Verify(phoneNumber, code) { |
|
|
|
return false, 0, "", 0, gerrors.ErrBadCode |
|
|
|
} |
|
|
@@ -58,6 +61,23 @@ func (*authService) SignIn(ctx context.Context, phoneNumber, code string, master |
|
|
|
return false, 0, "", 0, err |
|
|
|
} |
|
|
|
|
|
|
|
if pushAlia != "" { |
|
|
|
userPushForJg, err := db.DbUserPushForJg.UserPushForJgGetOne(strconv.FormatInt(user.Id, 10), masterId) |
|
|
|
if err != nil { |
|
|
|
return false, 0, "", 0, err |
|
|
|
} |
|
|
|
if userPushForJg == nil { |
|
|
|
save := db.DbUserPushForJg.UserPushForJgInsert(user.Id, masterId, pushAlia) |
|
|
|
if !save { |
|
|
|
return false, 0, "", 0, errors.New("插入user_push_for_jg记录失败") |
|
|
|
} |
|
|
|
} else { |
|
|
|
update := db.DbUserPushForJg.UserPushForJgUpdate(user.Id, masterId, pushAlia) |
|
|
|
if !update { |
|
|
|
return false, 0, "", 0, errors.New("修改user_push_for_jg记录失败") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return isNew, user.Id, token, masterId, nil |
|
|
|
} |
|
|
|
|
|
|
|