Example #1
0
        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public FuncResult Select(SearchSysUserGroupModel model)
        {
            var query = from a in _context.SysUserGroup
                        where (model.Level == 0 || a.UserGroupLevel == model.Level) && (string.IsNullOrWhiteSpace(model.Name) || a.UserGroupName.Contains(model.Name))
                        join b in _context.SysUserGroup on a.ParentId equals b.UserGroupId
                        into a_temp
                        from a_ifnull in a_temp.DefaultIfEmpty()
                        join c in _context.SysUserGroup on a_ifnull.ParentId equals c.UserGroupId
                        into b_temp
                        from c_ifnul in b_temp.DefaultIfEmpty()
                        orderby a.CreationDate descending
                        select new
            {
                Id        = a.UserGroupId,
                Name      = a.UserGroupName,
                Level     = ChineseCharacter(a.UserGroupLevel),
                firstId   = c_ifnul != null ? c_ifnul.UserGroupId : a_ifnull == null ? "" : a_ifnull.UserGroupId,
                firstName = c_ifnul != null ? c_ifnul.UserGroupName : a_ifnull == null ? "未选择" : a_ifnull.UserGroupName,
                //firstModuleName = a_ifnull != null ? a_ifnull.ModuleName : c_ifnul == null ? "未选择" : c_ifnul.ModuleName,
                firstLevel = c_ifnul != null?ChineseCharacter(c_ifnul.UserGroupLevel) : a_ifnull == null ? "" : ChineseCharacter(a_ifnull.UserGroupLevel),
                                 secondId     = c_ifnul == null ? "" : a_ifnull.UserGroupId,
                                 secondName   = c_ifnul == null ? "未选择" : a_ifnull.UserGroupName,
                                 secondLevel  = c_ifnul == null ? "" : ChineseCharacter(a_ifnull.UserGroupLevel),
                                 CreationDate = a.CreationDate.Value.ToString("yyyy-MM-dd HH:mm:ss")
            };

            int total = query.Count();
            // var data = query.Skip(model.limit * model.page).Take(model.limit);
            var data = query.ToList().Skip(model.limit * model.page);//.Take(model.limit).ToList();

            return(new FuncResult()
            {
                IsSuccess = true, Content = new { data, total }
            });
        }
        public FuncResult Select([FromBody] SearchSysUserGroupModel model)
        {
            model.page--; if (model.page < 0)
            {
                model.page = 0;
            }

            return(userGroupService.Select(model));
        }