/// <summary> /// 通过父类编号获取子类编号并序列化为json /// </summary> /// <param name="parentId"></param> /// <returns></returns> public JsonResult GetAreaChild(string ParentAId) { using (ResponseResult <List <AreaViewModel> > result = new ResponseResult <List <AreaViewModel> >()) { //获取用户信息 if (this.UserInfo.IsSuperAdmin) { var areaChilds = areaRepository.GetAreaChilds(ParentAId); result.Entity = areaChilds; result.IsSuccess = true; return(new JsonResultEx(result)); } //获得用户角色信息 var roleList = this.adminUserRepository.GetRoles(UserId); //是否拥有管理员角色 if (roleList.Any(role => role.RoleID == (int)RoleType.Admin)) { var areaChilds = areaRepository.GetAreaChilds(ParentAId); result.Entity = areaChilds; result.IsSuccess = true; return(new JsonResultEx(result)); } //是否拥有经销商角色 else if (roleList.Any(role => role.RoleID == (int)RoleType.Dealer)) { //获取经销商可管理的区域 var areaChilds = areaRepository.GetManageArea(ParentAId, UserId); if (areaChilds == null || areaChilds.Count == 0) { return(new JsonResultEx(result)); } else { result.IsSuccess = true; result.Entity = Mapper.Map <List <AreaViewModel> >(areaChilds); return(new JsonResultEx(result)); } } else { throw new UnauthorizedAccessException(); } } }