|
|
package domain_service
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/tiptok/gocomm/xa/eda"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
|
|
|
"strings"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -29,16 +29,16 @@ func (s *PgPartnerAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone |
|
|
)
|
|
|
//验证新手机是否已经存在
|
|
|
if _, e := PartnerInfoService.FindOne(map[string]interface{}{"account": newPhone}); e == nil {
|
|
|
err = protocol.NewErrWithMessage(2029, err) //账号已存在
|
|
|
err = fmt.Errorf("账号已存在") //账号已存在
|
|
|
return
|
|
|
}
|
|
|
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil || (partnerInfo.Account != oldPhone) {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
err = fmt.Errorf("账号不存在") //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if err = PartnerInfoDao.Update(map[string]interface{}{
|
|
|
"Id": userId,
|
|
|
"Account": newPhone,
|
|
|
"oldAccount": oldPhone,
|
|
|
"Account": newPhone,
|
|
|
}); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -51,17 +51,17 @@ func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd, |
|
|
PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext)
|
|
|
)
|
|
|
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
err = fmt.Errorf("账号不存在") //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if !strings.EqualFold(partnerInfo.Password, oldPwd) {
|
|
|
//密码不一致
|
|
|
err = protocol.NewErrWithMessage(2028, err) //账号不存在
|
|
|
err = fmt.Errorf("账号不存在") //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if err = PartnerInfoDao.Update(map[string]interface{}{
|
|
|
"Id": partnerInfo.Id,
|
|
|
"Password": newPwd,
|
|
|
"oldAccount": phone,
|
|
|
"Password": newPwd,
|
|
|
}); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -69,17 +69,17 @@ func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd, |
|
|
}
|
|
|
func (s *PgPartnerAuthService) ResetUserPassword(userId int64, phone, password string) (err error) {
|
|
|
var (
|
|
|
partnerInfo *domain.PartnerInfo
|
|
|
//partnerInfo *domain.PartnerInfo
|
|
|
PartnerInfoDao, _ = dao.NewPartnerInfoDao(s.transactionContext)
|
|
|
PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext)
|
|
|
)
|
|
|
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
if _, err = PartnerInfoService.FindOne(map[string]interface{}{"account": phone}); err != nil {
|
|
|
err = fmt.Errorf("账号不存在") //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if err = PartnerInfoDao.Update(map[string]interface{}{
|
|
|
"Id": partnerInfo.Id,
|
|
|
"Password": password,
|
|
|
"oldAccount": phone,
|
|
|
"Password": password,
|
|
|
}); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
|