...
|
...
|
@@ -10,7 +10,6 @@ import ( |
|
|
domain_service_i "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/service"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/domain_service"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
|
|
|
protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth"
|
...
|
...
|
@@ -294,61 +293,14 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques |
|
|
return
|
|
|
}
|
|
|
|
|
|
func changeUserInfo(userId int64, phone, password string, transactionContext *transaction.TransactionContext) (err error) {
|
|
|
var (
|
|
|
ucenterApiGateway = svr.NewHttplibUCenterApiServiceGateway()
|
|
|
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
|
|
|
user *domain.Users
|
|
|
)
|
|
|
if user, err = UsersRepository.FindOne(map[string]interface{}{"id": userId}); err != nil || user == nil {
|
|
|
log.Error(err)
|
|
|
err = fmt.Errorf("用户不存在")
|
|
|
return
|
|
|
}
|
|
|
_, err = ucenterApiGateway.UpdateUser(user.OpenId, phone, password)
|
|
|
return
|
|
|
}
|
|
|
func changeUserPhone(userId int64, phone, oldPhone string, transactionContext *transaction.TransactionContext) (err error) {
|
|
|
var (
|
|
|
ucenterApiGateway = svr.NewHttplibUCenterApiServiceGateway()
|
|
|
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
|
|
|
user *domain.Users
|
|
|
)
|
|
|
if user, err = UsersRepository.FindOne(map[string]interface{}{"id": userId}); err != nil || user == nil {
|
|
|
log.Error(err)
|
|
|
err = fmt.Errorf("用户不存在")
|
|
|
return
|
|
|
}
|
|
|
if newUser, e := UsersRepository.FindOne(map[string]interface{}{"phone": phone}); e == nil || newUser != nil {
|
|
|
err = protocol.NewErrWithMessage(2029, err)
|
|
|
return
|
|
|
}
|
|
|
_, err = ucenterApiGateway.ChangePhone(phone, oldPhone)
|
|
|
//if err != nil {
|
|
|
// _, err = transactionContext.PgTx.Exec("update users set phone=? where id=?", phone, userId)
|
|
|
//}
|
|
|
return
|
|
|
}
|
|
|
func changeUserPassword(userId int64, newPwd, oldPwd, phone string, transactionContext *transaction.TransactionContext) (err error) {
|
|
|
var (
|
|
|
ucenterApiGateway = svr.NewHttplibUCenterApiServiceGateway()
|
|
|
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
|
|
|
user *domain.Users
|
|
|
)
|
|
|
if user, err = UsersRepository.FindOne(map[string]interface{}{"id": userId}); err != nil || user == nil {
|
|
|
log.Error(err)
|
|
|
err = fmt.Errorf("用户不存在")
|
|
|
return
|
|
|
}
|
|
|
_, err = ucenterApiGateway.ChangePassword(phone, newPwd, oldPwd)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func CreateUserAuthService(adminType int, transactionContext *transaction.TransactionContext) domain_service_i.UserAuthService {
|
|
|
if adminType == int(protocolx.AdminTypeManager) {
|
|
|
return domain_service.NewPgManagerAuthService(transactionContext)
|
|
|
}
|
|
|
return domain_service.NewPgPartnerAuthService(transactionContext)
|
|
|
//if adminType==0{
|
|
|
return domain_service.NewPgAuthService(transactionContext)
|
|
|
//}
|
|
|
//if adminType == int(protocolx.AdminTypeManager) {
|
|
|
// return domain_service.NewPgManagerAuthService(transactionContext)
|
|
|
//}
|
|
|
//return domain_service.NewPgPartnerAuthService(transactionContext)
|
|
|
}
|
|
|
|
|
|
//TODO:修改密码/重置密码 清除uer_auth 缓存
|
...
|
...
|
|