...
|
...
|
@@ -238,7 +238,7 @@ func UserCompanys(header *protocol.RequestHeader, request *protocol.UserCompanys |
|
|
}
|
|
|
|
|
|
//切换公司
|
|
|
func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompanyRequest) (rsp *protocol.SwitchCompanyResponse, err error) {
|
|
|
func SwitchCompanyV3(header *protocol.RequestHeader, request *protocol.SwitchCompanyRequest) (rsp *protocol.SwitchCompanyResponse, err error) {
|
|
|
var (
|
|
|
userCompany *models.UserCompany
|
|
|
auth *models.UserAuth
|
...
|
...
|
@@ -276,6 +276,40 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa |
|
|
return
|
|
|
}
|
|
|
|
|
|
func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompanyRequest) (rsp *protocol.SwitchCompanyResponse, err error) {
|
|
|
var (
|
|
|
userCompany *models.UserCompany
|
|
|
auth *models.UserAuth
|
|
|
)
|
|
|
if userCompany, err = models.GetUserCompanyByUserId(header.Uid, int64(request.CompanyId)); err != nil {
|
|
|
log.Error(err)
|
|
|
err = protocol.NewErrWithMessage(4201) //找不到这家公司
|
|
|
return
|
|
|
}
|
|
|
if auth, err = models.GetUserAuthByUserId(header.Uid, protocol.DeviceType); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if auth.CurrentCompanyId == request.CompanyId {
|
|
|
log.Error(fmt.Sprintf("uid:%v 当前公司已经是:%v", header.Uid, request.CompanyId))
|
|
|
//return
|
|
|
} else {
|
|
|
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
|
|
|
}
|
|
|
rsp = &protocol.SwitchCompanyResponse{}
|
|
|
rsp.AuthCode = auth.AuthCode
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//用户信息
|
|
|
func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) {
|
|
|
var (
|
...
|
...
|
|