feat: minilogin改造
This commit is contained in:
@@ -23,18 +23,6 @@ func NewCreateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
|
||||
}
|
||||
|
||||
func (l *CreateUserLogic) CreateUser(in *system.CreateUserReq) (*system.CreateUserResp, error) {
|
||||
// 如果有 OpenId,先查是否已存在(社交登录场景:已有用户直接返回)
|
||||
if in.OpenId != "" {
|
||||
var existing sysModel.SundynixUser
|
||||
if err := l.svcCtx.DB.Where("open_id = ?", in.OpenId).First(&existing).Error; err == nil {
|
||||
// 用户已存在,更新 session_key 后直接返回
|
||||
if in.SessionKey != "" {
|
||||
l.svcCtx.DB.Model(&existing).Update("session_key", in.SessionKey)
|
||||
}
|
||||
return &system.CreateUserResp{User: convertUserToProto(&existing)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有 Account,检查是否重复(后台创建用户场景:禁止重复)
|
||||
if in.Account != "" {
|
||||
var count int64
|
||||
@@ -45,12 +33,11 @@ func (l *CreateUserLogic) CreateUser(in *system.CreateUserReq) (*system.CreateUs
|
||||
}
|
||||
|
||||
u := sysModel.SundynixUser{
|
||||
Name: in.Name,
|
||||
Account: in.Account,
|
||||
Phone: in.Phone,
|
||||
OpenID: in.OpenId,
|
||||
SessionKey: in.SessionKey,
|
||||
ClientID: in.ClientId,
|
||||
Name: in.Name,
|
||||
Account: in.Account,
|
||||
Phone: in.Phone,
|
||||
NickName: in.NickName,
|
||||
ClientID: in.ClientId,
|
||||
}
|
||||
if in.Password != "" {
|
||||
u.Password = hash.BcryptHash(in.Password)
|
||||
|
||||
Reference in New Issue
Block a user