作者 yangfu

用户注销修改

... ... @@ -10,7 +10,7 @@ import (
type DestroyAccountCommand struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
Account string `cname:"账号" json:"account" valid:"Required"`
}
func (destroyAccountCommand *DestroyAccountCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -81,7 +81,7 @@ func (authService *AuthService) DestroyAccount(destroyAccountCommand *command.De
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.UserId); err != nil {
if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.Account); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ...
... ... @@ -4,5 +4,5 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
// PgAuthAccountDestroyService 账号注销服务
type PgAuthAccountDestroyService interface {
DestroyAccount(optUser *domain.User, userId int64) error
DestroyAccount(optUser *domain.User, userId string) error
}
... ...
... ... @@ -13,21 +13,21 @@ type PgAuthAccountDestroyService struct {
transactionContext *pgTransaction.TransactionContext
}
func (ptr *PgAuthAccountDestroyService) DestroyAccount(optUser *domain.User, userId int64) error {
func (ptr *PgAuthAccountDestroyService) DestroyAccount(optUser *domain.User, account string) error {
// 1.查询账号记录
userRepository, _ := repository.NewUserRepository(ptr.transactionContext)
var userBaseId int64
if user, err := userRepository.FindOne(map[string]interface{}{"userId": userId}); err != nil {
if err == domain.ErrorNotFound {
return fmt.Errorf("该用户不存在")
}
return err
} else {
userBaseId = user.UserBaseId
}
//var userBaseId int64
//if user, err := userRepository.FindOne(map[string]interface{}{"userId": userId}); err != nil {
// if err == domain.ErrorNotFound {
// return fmt.Errorf("该用户不存在")
// }
// return err
//} else {
// userBaseId = user.UserBaseId
//}
userBaseRepository, _ := repository.NewUserBaseRepository(ptr.transactionContext)
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userBaseId})
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": account})
if err != nil {
return err
}
... ...