Esempio n. 1
0
        /// <summary>
        /// 获取角色分页数据
        /// </summary>
        /// <param name="appid">appid</param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public ActionResult PageData(string appid, int page = 1, int size = 10)
        {
            var where = string.IsNullOrEmpty(appid) ? (Expression <Func <Role, bool> >)(g => true) : (g => g.ClientApp.Any(a => a.AppId.Equals(appid)));
            List <int>           ids  = RoleBll.LoadPageEntitiesNoTracking <int, RoleOutputDto>(page, size, out int total, where, a => a.Id, false).Select(g => g.Id).ToList();
            List <RoleOutputDto> list = new List <RoleOutputDto>();

            ids.ForEach(g =>
            {
                List <RoleOutputDto> temp = RoleBll.GetSelfAndChildrenByParentId(g).ToList();
                list.AddRange(temp);
            });
            return(PageResult(list.DistinctBy(u => u.Id), size, total));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取应用所有的角色
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="kw"></param>
        /// <returns></returns>
        public ActionResult GetAll(string appid, string kw)
        {
            var where = string.IsNullOrEmpty(appid) ? (Expression <Func <Role, bool> >)(g => true) : (g => g.ClientApp.Any(a => a.AppId.Equals(appid)));
            List <int>           ids  = RoleBll.LoadEntitiesNoTracking <RoleOutputDto>(where).Select(g => g.Id).ToList();
            List <RoleOutputDto> list = new List <RoleOutputDto>();

            ids.ForEach(g =>
            {
                var raw  = RoleBll.GetSelfAndChildrenByParentId(g);
                var temp = string.IsNullOrEmpty(kw) ? raw.ToList() : raw.Where(u => u.RoleName.Contains(kw)).ToList();
                list.AddRange(temp);
            });
            return(ResultData(list.DistinctBy(u => u.Id)));
        }