...
|
...
|
@@ -9,7 +9,6 @@ import ( |
|
|
"net/http"
|
|
|
"opp/internal/utils"
|
|
|
"opp/services/agg"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid"
|
...
|
...
|
@@ -37,9 +36,14 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp |
|
|
var (
|
|
|
user *models.User
|
|
|
userAuth *models.UserAuth
|
|
|
getUserRequest *protocol.UCenterGetUserRequest = &protocol.UCenterGetUserRequest{}
|
|
|
getUserRequest *protocol.UCenterServerLoginRequest = &protocol.UCenterServerLoginRequest{
|
|
|
Uid: request.Uid,
|
|
|
Token: request.Token,
|
|
|
Type: 2,
|
|
|
}
|
|
|
getUserResponse *protocol.UCenterGetUserResponse
|
|
|
message *protocol.Message
|
|
|
company *models.Company
|
|
|
)
|
|
|
user, err = models.GetUserByUcenterId(request.Uid)
|
|
|
if err != nil {
|
...
|
...
|
@@ -47,10 +51,15 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp |
|
|
err = protocol.NewErrWithMessage(2002, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
if userAuth, err = models.GetUserAuthByUserId(user.Id, protocol.DeviceType); err == nil {
|
|
|
if company, err = models.GetCompanyById(userAuth.CurrentCompanyId); err == nil {
|
|
|
getUserRequest.CompanyId = company.UserCenterId
|
|
|
}
|
|
|
}
|
|
|
//TODO:验证模块权限
|
|
|
|
|
|
//从用户中心获取用户信息
|
|
|
if _, err = agg.RequestUserCenter(fmt.Sprintf("%v%v", protocol.MethodGetUser, request.Uid), http.MethodGet, getUserRequest, &message); err != nil {
|
|
|
if _, err = agg.RequestUserCenter(protocol.MethodServerLogin, http.MethodPost, getUserRequest, &message); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -70,9 +79,12 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp |
|
|
case 2002:
|
|
|
err = protocol.NewErrWithMessage(2002, err) //账号不存在
|
|
|
return
|
|
|
case 10001:
|
|
|
err = protocol.NewErrWithMessage(2002, err) //账号不存在
|
|
|
return
|
|
|
default:
|
|
|
err = fmt.Errorf("error_no:%v msg:%v", message.Errno, message.Errmsg)
|
|
|
break
|
|
|
return
|
|
|
}
|
|
|
|
|
|
Success:
|
...
|
...
|
@@ -93,11 +105,11 @@ Success: |
|
|
userAuth.AuthCode = uid.NewV1().StringNoDash()
|
|
|
|
|
|
/*更新用户信息*/
|
|
|
user.CsAccount, _ = strconv.ParseInt(getUserResponse.CustomerAccount, 10, 64)
|
|
|
user.ImToken = getUserResponse.Token
|
|
|
user.CsAccount = getUserResponse.CustomerAccount
|
|
|
user.ImToken = getUserResponse.ImToken
|
|
|
user.Icon = getUserResponse.Avatar
|
|
|
user.NickName = getUserResponse.NickName
|
|
|
user.Accid, _ = strconv.ParseInt(getUserResponse.Accid, 10, 64)
|
|
|
user.Accid = getUserResponse.Accid
|
|
|
user.UserCenterId = getUserResponse.Id
|
|
|
if err = repository.User.UpdateUserInfo(user); err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
|