/// <summary>
        ///     根据组织机构Id查询角色信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <IEnumerable <SystemRoleOutput> > GetRolesByOrganizationId(SystemRolesGetByOrganizationId input)
        {
            var data    = (await _roleRepository.GetRolesByOrganizationId(input)).ToList();
            var allOrgs = (await _organizationRepository.FindAllAsync()).ToList();

            foreach (var user in data)
            {
                var organization = allOrgs.FirstOrDefault(w => w.OrganizationId == user.OrganizationId);
                if (organization != null && !organization.ParentIds.IsNullOrEmpty())
                {
                    foreach (var parent in organization.ParentIds.Split(','))
                    {
                        //查找上级
                        var dicinfo = allOrgs.FirstOrDefault(w => w.OrganizationId.ToString() == parent);
                        if (dicinfo != null)
                        {
                            user.OrganizationNames += dicinfo.Name + ">";
                        }
                    }
                    if (!user.OrganizationNames.IsNullOrEmpty())
                    {
                        user.OrganizationNames = user.OrganizationNames.TrimEnd('>');
                    }
                }
            }
            return(data);
        }
Beispiel #2
0
 /// <summary>
 ///     根据组织机构Id查询角色信息
 /// </summary>
 /// <param name="input"></param>
 /// <param name="isFreeze">是否冻结</param>
 /// <returns></returns>
 public async Task <IEnumerable <SystemRoleOutput> > GetRolesByOrganizationId(NullableIdInput input = null,
                                                                              bool?isFreeze         = null)
 {
     return(await _roleRepository.GetRolesByOrganizationId(input, isFreeze));
 }