|
...
|
...
|
@@ -3,6 +3,7 @@ package user |
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/astaxie/beego/orm"
|
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid"
|
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
|
|
|
|
"opp/internal/utils"
|
|
|
|
"opp/models"
|
|
...
|
...
|
@@ -10,6 +11,7 @@ import ( |
|
|
|
"opp/services/agg"
|
|
|
|
"opp/services/auth"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
//验证smscode
|
|
...
|
...
|
@@ -226,7 +228,7 @@ func UserCompanys(header *protocol.RequestHeader, request *protocol.UserCompanys |
|
|
|
}
|
|
|
|
|
|
|
|
//切换公司
|
|
|
|
func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompanyRequest) (rsp *protocol.UserInfoResponse, err error) {
|
|
|
|
func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompanyRequest) (rsp *protocol.SwitchCompanyResponse, err error) {
|
|
|
|
var (
|
|
|
|
userCompany *models.UserCompany
|
|
|
|
auth *models.UserAuth
|
|
...
|
...
|
@@ -244,17 +246,19 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa |
|
|
|
log.Error(fmt.Sprintf("uid:%v 当前公司已经是:%v", header.Uid, request.CompanyId))
|
|
|
|
//return
|
|
|
|
} else {
|
|
|
|
if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{"CurrentCompanyId": userCompany.CompanyId, "CurrentUserCompanyId": userCompany.Id}); err != nil {
|
|
|
|
auth.AuthCode = uid.NewV1().StringNoDash()
|
|
|
|
auth.AuthCodeExp = time.Now().Add(time.Second * protocol.TokenExpire)
|
|
|
|
if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{
|
|
|
|
"CurrentCompanyId": userCompany.CompanyId, "CurrentUserCompanyId": userCompany.Id, "AuthCode": auth.AuthCode, "AuthCodeExp": auth.AuthCodeExp},
|
|
|
|
); err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
header.CompanyId = userCompany.CompanyId
|
|
|
|
header.UserId = userCompany.Id
|
|
|
|
}
|
|
|
|
if rsp, err = UserInfo(header, &protocol.UserInfoRequest{}); err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
rsp = &protocol.SwitchCompanyResponse{}
|
|
|
|
rsp.AuthCode = auth.AuthCode
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|