Exemplo n.º 1
0
        public TableData Load(QueryResourcesReq request)
        {
            var result    = new TableData();
            var resources = UnitWork.Find <Resource>(null);

            if (!string.IsNullOrEmpty(request.key))
            {
                resources = resources.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
            }

            if (!string.IsNullOrEmpty(request.TypeId))
            {
                resources = resources.Where(u => u.TypeId == request.TypeId);
            }
            if (request.Status == 1)
            {
                //查已启用
                resources = resources.Where(x => x.Disable == false);
            }
            else if (request.Status == 2)
            {
                //查已禁用
                resources = resources.Where(x => x.Disable == true);
            }

            result.data = resources.OrderBy(u => u.TypeId)
                          .Skip((request.page - 1) * request.limit)
                          .Take(request.limit).ToList();
            result.count = resources.Count();
            return(result);
        }
Exemplo n.º 2
0
        public async Task <TableData> Load(QueryResourcesReq request)
        {
            var loginContext = _auth.GetCurrentUser();

            if (loginContext == null)
            {
                throw new CommonException("登录已过期", Define.INVALID_TOKEN);
            }

            var columnFields = loginContext.GetTableColumns("Resource");

            if (columnFields == null || columnFields.Count == 0)
            {
                throw new Exception("请在代码生成界面配置Resource表的字段属性");
            }


            var result    = new TableData();
            var resources = GetDataPrivilege("u");

            if (!string.IsNullOrEmpty(request.key))
            {
                resources = resources.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
            }

            if (!string.IsNullOrEmpty(request.appId))
            {
                resources = resources.Where(u => u.AppId == request.appId);
            }

            var propertyStr = string.Join(',', columnFields.Select(u => u.ColumnName));

            result.columnFields = columnFields;
            result.data         = resources.OrderBy(u => u.TypeId)
                                  .Skip((request.page - 1) * request.limit)
                                  .Take(request.limit).Select($"new ({propertyStr})");
            result.count = await resources.CountAsync();

            return(result);
        }
Exemplo n.º 3
0
        public TableData Load(QueryResourcesReq request)
        {
            var loginContext = _auth.GetCurrentUser();

            if (loginContext == null)
            {
                throw new CommonException("登录已过期", Define.INVALID_TOKEN);
            }

            var properties = loginContext.GetProperties("Resource");

            if (properties == null || properties.Count == 0)
            {
                throw new Exception("当前登录用户没有访问该模块字段的权限,请联系管理员配置");
            }


            var result    = new TableData();
            var resources = UnitWork.Find <Resource>(null);

            if (!string.IsNullOrEmpty(request.key))
            {
                resources = resources.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
            }

            if (!string.IsNullOrEmpty(request.appId))
            {
                resources = resources.Where(u => u.AppId == request.appId);
            }

            var propertyStr = string.Join(",", properties.Select(u => u.Key));

            result.columnHeaders = properties;
            result.data          = resources.OrderBy(u => u.TypeId)
                                   .Skip((request.page - 1) * request.limit)
                                   .Take(request.limit).Select($"new ({propertyStr})");
            result.count = resources.Count();
            return(result);
        }
Exemplo n.º 4
0
        public async Task <TableData> Load(QueryResourcesReq request)
        {
            var loginContext = _auth.GetCurrentUser();

            if (loginContext == null)
            {
                throw new CommonException("登錄已過期", Define.INVALID_TOKEN);
            }

            var properties = loginContext.GetProperties("Resource");

            if (properties == null || properties.Count == 0)
            {
                throw new Exception("當前登錄使用者沒有訪問該模組欄位的許可權,請聯繫管理員配置");
            }


            var result    = new TableData();
            var resources = GetDataPrivilege("u");

            if (!string.IsNullOrEmpty(request.key))
            {
                resources = resources.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
            }

            if (!string.IsNullOrEmpty(request.appId))
            {
                resources = resources.Where(u => u.AppId == request.appId);
            }

            var propertyStr = string.Join(',', properties.Select(u => u.Key));

            result.columnHeaders = properties;
            result.data          = resources.OrderBy(u => u.TypeId)
                                   .Skip((request.page - 1) * request.limit)
                                   .Take(request.limit).Select($"new ({propertyStr})");
            result.count = resources.Count();
            return(result);
        }
Exemplo n.º 5
0
        public TableData Load(QueryResourcesReq request)
        {
            var result    = new TableData();
            var resources = UnitWork.Find <Resource>(null);

            if (!string.IsNullOrEmpty(request.key))
            {
                resources = resources.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
            }

            if (!string.IsNullOrEmpty(request.appId))
            {
                resources = resources.Where(u => u.AppId == request.appId);
            }


            result.data = resources.OrderBy(u => u.TypeId)
                          .Skip((request.page - 1) * request.limit)
                          .Take(request.limit).ToList();
            result.count = resources.Count();
            return(result);
        }
 public string Load([FromQuery] QueryResourcesReq request)
 {
     return(JsonHelper.Instance.Serialize(_app.Load(request)));
 }
Exemplo n.º 7
0
 public TableData Load([FromQuery] QueryResourcesReq request)
 {
     return(_app.Load(request));
 }
Exemplo n.º 8
0
 public async Task <TableData> Load([FromQuery] QueryResourcesReq request)
 {
     return(await _app.Load(request));
 }
Exemplo n.º 9
0
        public async Task <string> Load([FromQuery] QueryResourcesReq request)
        {
            var objs = await _app.Load(request);

            return(JsonHelper.Instance.Serialize(objs));
        }