Exemple #1
0
        /// <summary>
        /// 获取角色列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <RoleIndexViewModel> GetListAsync(RoleIndexSearch search)
        {
            var uri            = API.SysRole.GetListAsync(_baseUrl, search);
            var responseString = await _apiClient.GetStringAsync(uri);

            return(responseString.ToObject <RoleIndexViewModel>());
        }
        public async Task <Page <SysRole> > GetPageAsync(RoleIndexSearch search)
        {
            Page <SysRole> page = new Page <SysRole>()
            {
                PageIndex = search.PageIndex,
                PageSize  = search.PageSize
            };

            string sqlWhere = $@"systemid = {search.SystemId} ";

            if (!search.RoleName.IsNullOrEmpty())
            {
                sqlWhere += $@" AND RoleName LIKE '%{search.RoleName}%' ";
            }
            if (search.IsDel != -1)
            {
                sqlWhere += $@" AND IsDel = {search.IsDel} ";
            }

            string sql = $"SELECT * FROM sys_role WHERE {sqlWhere} LIMIT {search.OffSet()},{search.PageSize}";

            page.Items = await this.QueryAsync(sql);

            page.TotalItems = await this.Connection.ExecuteScalarAsync <int>($"SELECT COUNT(1) FROM sys_role WHERE {sqlWhere}");

            return(page);
        }
        public async Task <IActionResult> Index(RoleIndexSearch search)
        {
            if (search.PageIndex.IsDefault())
            {
                search.PageIndex = 1;
            }
            if (search.PageSize.IsDefault())
            {
                search.PageSize = 10;
            }
            var res = await _roleService.GetListAsync(search);

            return(View(res));
        }
        public async Task <RoleIndexViewModel> GetListAsync(RoleIndexSearch search)
        {
            var dbsystems = await _databaseFixture.Db.SysSystem.FindAllAsync(m => m.IsDel == 0);

            RoleIndexViewModel dto = new RoleIndexViewModel
            {
                Systems = dbsystems.Select(m => new SelectListItem()
                {
                    Text     = m.SystemName,
                    Value    = m.SystemId.ToString(),
                    Selected = m.SystemId == search.SystemId
                }).ToList(),
                Page       = await _databaseFixture.Db.SysRole.GetPageAsync(search),
                RoleSearch = search
            };

            return(dto);
        }
 public static string GetListAsync(string baseUri, RoleIndexSearch search) => $"{baseUri}/Role/GetListAsync?{search.ToUrlParam()}";
 public async Task <RoleIndexViewModel> GetListAsync([FromQuery] RoleIndexSearch search)
 {
     return(await _roleService.GetListAsync(search));
 }