...
|
...
|
@@ -441,6 +441,32 @@ func (svr AuthService) ResetPassword(resetPasswordCommand *command.ResetPassword |
|
|
func (svr AuthService) getUserInfo(operator domain.Operator) (interface{}, error) {
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
|
|
|
operator)
|
|
|
|
|
|
// 个人用户登录
|
|
|
if operator.UserId == 0 && len(operator.Phone) != 0 {
|
|
|
resultUser, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
|
|
|
Account: operator.Phone,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
var user = map[string]interface{}{
|
|
|
"userId": 0,
|
|
|
//"userOpenId": fmt.Sprintf("%v",resultUser.UserBaseID),
|
|
|
"userInfo": map[string]interface{}{
|
|
|
"userName": resultUser.UserInfo.UserName,
|
|
|
"userPhone": resultUser.UserInfo.Phone,
|
|
|
"userAvatar": resultUser.UserInfo.Avatar,
|
|
|
"email": resultUser.UserInfo.Email,
|
|
|
},
|
|
|
"department": struct{}{},
|
|
|
"company": map[string]interface{}{},
|
|
|
"im": resultUser.Im,
|
|
|
"org": struct{}{},
|
|
|
}
|
|
|
return user, nil
|
|
|
}
|
|
|
// 企业用户登录
|
|
|
resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
|
|
|
UserId: int(operator.UserId),
|
|
|
})
|
...
|
...
|
@@ -455,12 +481,13 @@ func (svr AuthService) getUserInfo(operator domain.Operator) (interface{}, error |
|
|
}
|
|
|
var user = map[string]interface{}{
|
|
|
"userId": resultUser.UserId,
|
|
|
//"userOpenId": fmt.Sprintf("%v",resultUser.UserBaseId),
|
|
|
"userInfo": map[string]interface{}{
|
|
|
"userName": resultUser.UserInfo.UserName,
|
|
|
"userPhone": resultUser.UserInfo.Phone,
|
|
|
"userAvatar": resultUser.UserInfo.Avatar,
|
|
|
//"userCode": resultUser.UserInfo.UserCode,
|
|
|
"email": resultUser.UserInfo.Email,
|
|
|
"userCode": resultUser.UserInfo.UserCode,
|
|
|
"email": resultUser.UserInfo.Email,
|
|
|
},
|
|
|
"department": resultUser.Department,
|
|
|
"company": map[string]interface{}{
|
...
|
...
|
@@ -486,8 +513,9 @@ func (svr AuthService) getUserInfo(operator domain.Operator) (interface{}, error |
|
|
func (svr AuthService) getToken(loginToken domain.LoginToken) (map[string]interface{}, error) {
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
|
|
userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
|
|
|
Phone: loginToken.Account,
|
|
|
UserType: domain.UserTypeEmployee,
|
|
|
Phone: loginToken.Account,
|
|
|
UserType: domain.UserTypeEmployee,
|
|
|
EnableStatus: domain.UserStatusEnable,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "用户信息获取失败,"+err.Error())
|
...
|
...
|
@@ -516,17 +544,30 @@ loopUser1: |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if !currentOrgIsOK {
|
|
|
if !currentOrgIsOK && loginToken.Platform == domain.LoginPlatformWeb {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录的公司组织不可用")
|
|
|
}
|
|
|
loginToken.UserId = int64(currentUser.UserId)
|
|
|
loginToken.UserBaseId = int64(currentUser.UserBaseId)
|
|
|
loginToken.CompanyId = int64(currentUser.Company.CompanyId)
|
|
|
var orgIds []int64
|
|
|
for i := range currentUser.UserOrg {
|
|
|
orgIds = append(orgIds, int64(currentUser.UserOrg[i].OrgID))
|
|
|
if currentOrgIsOK {
|
|
|
loginToken.UserId = int64(currentUser.UserId)
|
|
|
loginToken.UserBaseId = int64(currentUser.UserBaseId)
|
|
|
loginToken.CompanyId = int64(currentUser.Company.CompanyId)
|
|
|
var orgIds []int64
|
|
|
for i := range currentUser.UserOrg {
|
|
|
orgIds = append(orgIds, int64(currentUser.UserOrg[i].OrgID))
|
|
|
}
|
|
|
loginToken.OrgIds = orgIds
|
|
|
}
|
|
|
|
|
|
// 个人登录
|
|
|
if len(userSearchResult.Users) == 0 {
|
|
|
userBase, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
|
|
|
Account: loginToken.Account,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "账号不存在")
|
|
|
}
|
|
|
loginToken.UserBaseId = int64(userBase.UserBaseID)
|
|
|
}
|
|
|
loginToken.OrgIds = orgIds
|
|
|
|
|
|
// 2. 更新currentAccess信息
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
...
|
...
|
|