Beispiel #1
0
        /// <summary>
        /// 获取所有角色数据
        /// </summary>
        /// <param name="roleSerach">查询条件</param>
        /// <returns></returns>
        public async Task <IActionResult> GetList([FromQuery] RoleSerach roleSerach)
        {
            if (!string.IsNullOrWhiteSpace(roleSerach.Name))
            {
                LinqComm <Role> .And(d => d.Name.Contains(roleSerach.Name));
            }
            var getResult = await _roleServices.GetListPagedAsync(Specification <Role> .Eval(LinqComm <Role> .GetExpression()), d => d.Sid, SortOrder.Descending, roleSerach.Page, roleSerach.Limit);

            var roleList = getResult.data.Select(d => new RoleList
            {
                Id         = d.Id,
                RoleName   = d.Name,
                Sid        = d.Sid,
                Remarks    = d.Remarks,
                UpdateTime = d.UpdateTime,
                UpdateUser = d.UpdateUser?.RealName,
                IsDefault  = d.IsDefault
            }).ToList();

            return(Json(new PageResult <RoleList>
            {
                code = getResult.code,
                msg = getResult.msg,
                count = getResult.count,
                data = roleList
            }));
        }