...
|
...
|
@@ -205,3 +205,57 @@ func SwitchCompany(header *protocol.RequestHeader, request *protocol.SwitchCompa |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//用户信息
|
|
|
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
|
|
|
)
|
|
|
|
|
|
if companyId == 0 {
|
|
|
if company, err = models.GetUserCompanyFirst(header.Uid); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if userAuth, err = models.GetUserAuthByUserId(header.Uid, 1); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if err = utils.UpdateTableByMap(&models.UserAuth{Id: userAuth.Id}, map[string]interface{}{"CurrentCompanyId": companyId}); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
companyId = int64(company.Id)
|
|
|
}
|
|
|
if user, err = models.GetUsersById(header.Uid); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if baseInfo, err = agg.GetUserBaseInfo(header.Uid, companyId); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.UserInfoResponse{
|
|
|
User: protocol.User{
|
|
|
UserId: baseInfo.UserId,
|
|
|
Name: baseInfo.NickName,
|
|
|
Phone: user.Phone,
|
|
|
Image: protocol.Picture{
|
|
|
Path: user.Icon,
|
|
|
//TODO:图片裁剪
|
|
|
H: 0,
|
|
|
W: 0,
|
|
|
},
|
|
|
Department: baseInfo.Department,
|
|
|
Position: baseInfo.Position,
|
|
|
ImToken: user.ImToken,
|
|
|
CompanyId: int(companyId),
|
|
|
Company: baseInfo.CompanyName,
|
|
|
},
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|