...
|
...
|
@@ -59,6 +59,41 @@ func (authService *AuthService) CompanySignUp(companySignUpCommand *command.Comp |
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// 个人注册
|
|
|
func (authService *AuthService) UserSignUp(companySignUpCommand *command.UserSignUpCommand) (interface{}, error) {
|
|
|
if err := companySignUpCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
signUpPersonService, err := factory.CreatePgSignUpPersonService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
userInfo := &domain.UserInfo{
|
|
|
UserName: companySignUpCommand.Name,
|
|
|
Phone: companySignUpCommand.Phone,
|
|
|
}
|
|
|
if _, err = signUpPersonService.SignUp(companySignUpCommand.Phone, companySignUpCommand.Password, userInfo); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// 注销账号 (添加用户时重新激活)
|
|
|
func (authService *AuthService) DestroyAccount(destroyAccountCommand *command.DestroyAccountCommand) (interface{}, error) {
|
|
|
if err := destroyAccountCommand.ValidateCommand(); err != nil {
|
...
|
...
|
@@ -331,6 +366,10 @@ func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (in |
|
|
}
|
|
|
ubDto := &dto.UserBaseDto{}
|
|
|
ubDto.LoadDto(userBase)
|
|
|
userRepository, _, _ := factory.FastPgUser(transactionContext, 0)
|
|
|
if user, err := userRepository.FindOne(map[string]interface{}{"userBaseId": userBase.UserBaseId, "userType": domain.UserTypeVisitor}); err == nil {
|
|
|
ubDto.UserId = user.UserId
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|