|
|
package user
|
|
|
|
|
|
import (
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/auth"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/command"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/query"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/service"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/protocol"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/services/auth"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
|
|
|
"strings"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -23,14 +23,16 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) |
|
|
return
|
|
|
}
|
|
|
rsp.User = protocol.User{
|
|
|
Id: partnerInfo.Id,
|
|
|
PartnerCategory: partnerInfo.PartnerCategory,
|
|
|
PartnerName: partnerInfo.PartnerName,
|
|
|
RegionInfo: partnerInfo.RegionInfo,
|
|
|
Id: partnerInfo.Id,
|
|
|
PartnerName: partnerInfo.PartnerName,
|
|
|
Phone: partnerInfo.Account,
|
|
|
CooperateCompany: protocol.Company{
|
|
|
Id: 1,
|
|
|
Name: "福州素天下有限公司",
|
|
|
},
|
|
|
JoinWay: partnerInfo.PartnerCategoryInfo(),
|
|
|
District: partnerInfo.RegionInfo,
|
|
|
SerialNo: partnerInfo.Id,
|
|
|
CooperateTime: partnerInfo.CooperateTime.Unix() * 1000,
|
|
|
}
|
|
|
if len(partnerInfo.Salesman) > 0 {
|
...
|
...
|
@@ -44,19 +46,15 @@ func CheckSmsCode(header *protocol.RequestHeader, request *protocol.CheckSmsCode |
|
|
var (
|
|
|
PartnerInfoService = service.NewPartnerInfoService(nil)
|
|
|
partnerInfo *domain.PartnerInfo
|
|
|
result bool
|
|
|
)
|
|
|
if partnerInfo, err = PartnerInfoService.GetPartnerInfo(&query.GetPartnerInfoQuery{Id: int(header.UserId)}); err != nil {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if result, err = auth.CheckSmsCode(strings.TrimSpace(partnerInfo.Account), request.Captcha); err != nil {
|
|
|
log.Error(err)
|
|
|
if _, err = auth.CheckSmsCode(strings.TrimSpace(partnerInfo.Account), request.Captcha); err != nil {
|
|
|
log.Error(err, partnerInfo.Account, request.Captcha)
|
|
|
return
|
|
|
}
|
|
|
if !result {
|
|
|
err = protocol.NewErrWithMessage(1012)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -69,12 +67,15 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe |
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if _, err = PartnerInfoService.GetPartnerInfo(&query.GetPartnerInfoQuery{Account: request.Phone}); err == nil {
|
|
|
err = protocol.NewErrWithMessage(2029, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if _, err = auth.CheckSmsCode(request.Phone, request.Captcha); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if _, err = PartnerInfoService.UpdatePartnerInfo(&command.UpdatePartnerInfoCommand{Account: request.Phone}); err == nil {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
return
|
...
|
...
|
@@ -84,7 +85,7 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe |
|
|
func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswordRequest) (rsp *protocol.ResetPasswordResponse, err error) {
|
|
|
var (
|
|
|
PartnerInfoService = service.NewPartnerInfoService(nil)
|
|
|
//partnerInfo *domain.PartnerInfo
|
|
|
partnerInfo *domain.PartnerInfo
|
|
|
)
|
|
|
if len(request.NewPwd) < 6 {
|
|
|
err = protocol.NewErrWithMessage(2027)
|
...
|
...
|
@@ -94,10 +95,14 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo |
|
|
err = protocol.NewErrWithMessage(2026)
|
|
|
return
|
|
|
}
|
|
|
if _, err = PartnerInfoService.GetPartnerInfo(&query.GetPartnerInfoQuery{Id: int(header.UserId)}); err != nil {
|
|
|
if partnerInfo, err = PartnerInfoService.GetPartnerInfo(&query.GetPartnerInfoQuery{Id: int(header.UserId)}); err != nil {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if _, err = auth.CheckSmsCode(partnerInfo.Account, request.Captcha); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if _, err = PartnerInfoService.UpdatePartnerInfo(&command.UpdatePartnerInfoCommand{Password: request.ConfirmPwd}); err == nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
|