...
|
...
|
@@ -183,15 +183,15 @@ func UserCompanys(header *protocol.RequestHeader, request *protocol.UserCompanys |
|
|
companys []*models.Company
|
|
|
)
|
|
|
rsp = &protocol.UserCompanysResponse{}
|
|
|
if companys,err =models.GetCompanyByPermission(header.Uid);err!=nil{
|
|
|
if companys, err = models.GetCompanyByPermission(header.Uid); err != nil {
|
|
|
log.Error(err)
|
|
|
err = protocol.NewErrWithMessage(4201) //找不到这家公司
|
|
|
return
|
|
|
}
|
|
|
for i:=range companys{
|
|
|
rsp.Companys =append(rsp.Companys,protocol.Company{
|
|
|
Id:companys[i].Id,
|
|
|
Name:companys[i].Name,
|
|
|
for i := range companys {
|
|
|
rsp.Companys = append(rsp.Companys, protocol.Company{
|
|
|
Id: companys[i].Id,
|
|
|
Name: companys[i].Name,
|
|
|
})
|
|
|
}
|
|
|
return
|
...
|
...
|
@@ -213,11 +213,11 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if auth.CurrentCompanyId == request.CompanyId{
|
|
|
log.Error(fmt.Sprintf("uid:%v 当前公司已经是:%v",header.Uid,request.CompanyId))
|
|
|
if auth.CurrentCompanyId == request.CompanyId {
|
|
|
log.Error(fmt.Sprintf("uid:%v 当前公司已经是:%v", header.Uid, request.CompanyId))
|
|
|
return
|
|
|
}
|
|
|
if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{"CurrentCompanyId": company.CompanyId}); err != nil {
|
|
|
if err = utils.UpdateTableByMap(&models.UserAuth{Id: auth.Id}, map[string]interface{}{"CurrentCompanyId": company.CompanyId, "CurrentCompanyUserId": company.Id}); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -227,15 +227,15 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa |
|
|
//用户信息
|
|
|
func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) {
|
|
|
var (
|
|
|
companyId = header.CompanyId
|
|
|
company *models.UserCompany
|
|
|
baseInfo *protocol.BaseUserInfo
|
|
|
userAuth *models.UserAuth
|
|
|
user *models.User
|
|
|
companyId = header.CompanyId
|
|
|
userCompany *models.UserCompany
|
|
|
baseInfo *protocol.BaseUserInfo
|
|
|
userAuth *models.UserAuth
|
|
|
user *models.User
|
|
|
)
|
|
|
|
|
|
if companyId == 0 {
|
|
|
if company, err = models.GetUserCompanyFirst(header.Uid); err != nil {
|
|
|
if userCompany, err = models.GetUserCompanyFirst(header.Uid); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -243,17 +243,17 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if err = utils.UpdateTableByMap(&models.UserAuth{Id: userAuth.Id}, map[string]interface{}{"CurrentCompanyId": companyId}); err != nil {
|
|
|
if err = utils.UpdateTableByMap(&models.UserAuth{Id: userAuth.Id}, map[string]interface{}{"CurrentCompanyId": userCompany.CompanyId, "CurrentUserCompanyId": userCompany.Id}); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
companyId = int64(company.Id)
|
|
|
companyId = int64(userCompany.CompanyId)
|
|
|
}
|
|
|
if user, err = models.GetUsersById(header.Uid); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if baseInfo, err = agg.GetUserBaseInfo(header.Uid, companyId); err != nil {
|
|
|
if baseInfo, err = agg.GetUserBaseInfo(header.UserId, companyId); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
|