作者 唐旭辉

bug 修复,主管获得所有

@@ -245,7 +245,7 @@ func (c *AuthController) Me() { @@ -245,7 +245,7 @@ func (c *AuthController) Me() {
245 if err != nil { 245 if err != nil {
246 log.Error("获取用户的公司失败") 246 log.Error("获取用户的公司失败")
247 } 247 }
248 - permissionMap := serveauth.GetUserMenuPermission(userid) 248 + permissionMap := serveauth.GetUserMenuPermission(userid, companyid)
249 data := map[string]interface{}{ 249 data := map[string]interface{}{
250 "user": userinfo, 250 "user": userinfo,
251 "menus": menus, 251 "menus": menus,
@@ -370,11 +370,22 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er @@ -370,11 +370,22 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er
370 return list, nil 370 return list, nil
371 } 371 }
372 372
373 -func GetUserMenuPermission(userid int64) map[string]serverbac.PermissionOptionObject { 373 +func GetUserMenuPermission(userid int64, companyid int64) map[string]serverbac.PermissionOptionObject {
  374 +
374 var ( 375 var (
375 permissionMap = make(map[string]serverbac.PermissionOptionObject) 376 permissionMap = make(map[string]serverbac.PermissionOptionObject)
376 err error 377 err error
  378 + companyinfo *models.Company
377 ) 379 )
  380 + companyinfo, err = models.GetCompanyById(companyid)
  381 + if err != nil {
  382 + log.Error("获取公司信息失败:%s", err)
  383 + return permissionMap
  384 + }
  385 + if companyinfo.AdminId == userid {
  386 + permissionMap = AdminUserMenuPersmission()
  387 + return permissionMap
  388 + }
378 permissionMap, err = redisdata.GetUserPermissionAll(userid) 389 permissionMap, err = redisdata.GetUserPermissionAll(userid)
379 if err != nil { 390 if err != nil {
380 log.Error("获取权限数据失败 :%s", err) 391 log.Error("获取权限数据失败 :%s", err)
@@ -391,6 +402,28 @@ func GetUserMenuPermission(userid int64) map[string]serverbac.PermissionOptionOb @@ -391,6 +402,28 @@ func GetUserMenuPermission(userid int64) map[string]serverbac.PermissionOptionOb
391 return permissionMap 402 return permissionMap
392 } 403 }
393 404
  405 +func AdminUserMenuPersmission() map[string]serverbac.PermissionOptionObject {
  406 + permissionMap := make(map[string]serverbac.PermissionOptionObject)
  407 + permissionMap[serverbac.M_ENTERPRISE] = &serverbac.PermissionOptionBase{Check: 1}
  408 + permissionMap[serverbac.M_SYSTEM] = &serverbac.PermissionOptionBase{Check: 1}
  409 + permissionMap[serverbac.M_ENTERPRISE_PROFILE] = &serverbac.PermissionOptionBase{Check: 1}
  410 + permissionMap[serverbac.M_ENTERPRISE_ORGANIZATION] = &serverbac.PermissionOptionBase{Check: 1}
  411 + permissionMap[serverbac.M_ENTERPRISE_EMPLOYEE_POST] = &serverbac.PermissionOptionBase{Check: 1}
  412 + permissionMap[serverbac.M_ENTERPRISE_EMPLOYEE_ROLE] = &serverbac.PermissionOptionBase{Check: 1}
  413 + permissionMap[serverbac.M_ENTERPRISE_EMPLOYEE] = &serverbac.PermissionOptionBase{Check: 1}
  414 + permissionMap[serverbac.M_SYSTEM_OPPORTUNITY_TEMPLATE] = &serverbac.PermissionOptionBase{Check: 1}
  415 + permissionMap[serverbac.M_SYSTEM_RATING] = &serverbac.PermissionOptionBase{Check: 1}
  416 + permissionMap[serverbac.M_SYSTEM_ANNOUNCEMENT] = &serverbac.PermissionOptionBase{Check: 1}
  417 + permissionMap[serverbac.M_SYSTEM_OPPORTUNITY] = &serverbac.OptionOpportunity{
  418 + Check: serverbac.OpportunityCheckLv4,
  419 + EditSorce: 1,
  420 + EditPublicStatus: 1,
  421 + CloseChance: 1,
  422 + EditChance: 1,
  423 + }
  424 + return permissionMap
  425 +}
  426 +
394 func LoginAuthBySmsCode(uclientReturn *ucenter.ResponseLoginSms) ( 427 func LoginAuthBySmsCode(uclientReturn *ucenter.ResponseLoginSms) (
395 protocol.LoginAuthToken, error) { 428 protocol.LoginAuthToken, error) {
396 var ( 429 var (