作者 yangfu

登录修改

... ... @@ -117,3 +117,14 @@ func GetUserCompanyIdAll(companyId int) (v []int64, err error) {
}
return nil, err
}
//获取用户所有的公司列表
//@uid 表user.id
func GetUserAllCompany(uid int64) (v []*UserCompany, err error) {
o := orm.NewOrm()
sql := "select * from user_company where user_id=? and enable=1" //and enable=1
if _, err = o.Raw(sql, uid).QueryRows(&v); err == nil {
return v, nil
}
return nil, err
}
... ...
... ... @@ -275,25 +275,23 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa
//用户信息
func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) {
var (
companyId int64
userCompany *models.UserCompany
userAuth *models.UserAuth
userBaseAgg *protocol.UserBaseInfoAggregation
companys []*models.Company
companyId int64
userCompany *models.UserCompany
userAuth *models.UserAuth
userBaseAgg *protocol.UserBaseInfoAggregation
companys []*models.Company
userCompanys []*models.UserCompany
)
if companys, err = models.GetCompanyByPermission(header.Uid); err != nil {
log.Error(err)
return
}
//保证用户登录期间公司有权限
//if len(companys) == 0 {
// //无权限
// err = protocol.NewErrWithMessage(2002)
// return
//}
for i := range companys {
if companys[i].Id == header.CompanyId {
if userCompanys, err = models.GetUserAllCompany(header.Uid); err != nil {
log.Error(err)
return
}
for i := range userCompanys {
if userCompanys[i].Id == header.UserId && userCompanys[i].CompanyId == header.CompanyId {
companyId = header.CompanyId
break
}
... ...