public IActionResult Get(string ids) { if (ids.IsNotEmpty()) { var idList = new List <Guid>(); if (ids.IndexOf(",") > 0) { foreach (var item in ids.Split(',')) { if (Guid.TryParse(item, out Guid id)) { idList.Add(id); } } } else { if (Guid.TryParse(ids, out Guid id)) { idList.Add(id); } } StringBuilder content = new StringBuilder(); var result = _webResourceFinder.FindByIds(idList.ToArray()); foreach (var item in result) { content.Append(_webResourceContentCoder.CodeDecode(item.Content)); } return(Content(content.ToString())); } return(Content(T["notfound_record"])); }
public IActionResult GetViewInfo(Guid?id, Guid?entityId, string entityName) { //视图信息 List <QueryView.Domain.QueryView> views = null; //字段信息 List <Schema.Domain.Attribute> attributes = null; //按钮信息 List <RibbonButton.Domain.RibbonButton> buttons = null; //Web资源信息 string webResources = null; List <Guid> webResourceIds = null; QueryView.Domain.QueryView queryView = null; //查询视图信息 if (id.HasValue && !id.Value.Equals(Guid.Empty)) { queryView = _queryViewFinder.FindById(id.Value); if (queryView != null) { views = new List <QueryView.Domain.QueryView> { queryView }; } } else if (entityId.HasValue && !entityId.Equals(Guid.Empty)) { views = _queryViewFinder.QueryAuthorized(n => n.Where(f => f.EntityId == entityId && f.StateCode == RecordState.Enabled) .Sort(s => s.SortAscending(f => f.Name))); if (views.NotEmpty()) { queryView = views.First(x => x.IsDefault); } } else if (entityName.IsNotEmpty()) { views = _queryViewFinder.QueryAuthorized(n => n.Where(f => f.EntityName == entityName && f.StateCode == RecordState.Enabled) .Sort(s => s.SortAscending(f => f.Name))); if (views.NotEmpty()) { queryView = views.FirstOrDefault(x => x.IsDefault); } } if (queryView == null) { return(NotFound()); } //查询字段 var queryExp = new QueryExpression().DeserializeFromJson(queryView.FetchConfig); attributes = _queryMetadataFinder.GetAttributes(queryExp); //查询按钮 FilterContainer <RibbonButton.Domain.RibbonButton> buttonFilter = FilterContainerBuilder.Build <RibbonButton.Domain.RibbonButton>() .And(w => w.StateCode == RecordState.Enabled && w.EntityId == queryView.EntityId && (w.ShowArea == RibbonButtonArea.ListHead || w.ShowArea == RibbonButtonArea.ListRow || w.ShowArea == RibbonButtonArea.SubGrid)); if (queryView.IsCustomButton && queryView.CustomButtons.IsNotEmpty()) { List <Guid> buttonid = new List <Guid>(); buttonid = buttonid.DeserializeFromJson(queryView.CustomButtons); buttonFilter.And(w => w.RibbonButtonId.In(buttonid)); } buttons = _ribbonbuttonFinder.Query(n => n .Where(buttonFilter) .Sort(s => s.SortAscending(f => f.DisplayOrder))); //查询Web资源信息 if (queryView.LayoutConfig.IsNotEmpty()) { QueryViewLayoutConfigModel layoutConfig = new QueryViewLayoutConfigModel().DeserializeFromJson(queryView.LayoutConfig); if (layoutConfig != null && layoutConfig.ClientResources.NotEmpty()) { webResourceIds = layoutConfig.ClientResources; } } if (buttons.NotEmpty()) { buttons.ForEach(x => { if (x.JsLibrary != null) { string[] arr = x.JsLibrary.Split(":"); if (arr.Length > 1) { Guid webResourceId = Guid.Empty; if (Guid.TryParse(arr[1], out webResourceId)) { if (webResourceIds == null) { webResourceIds = new List <Guid>(); } webResourceIds.Add(webResourceId); } } } }); } if (webResourceIds.NotEmpty()) { StringBuilder content = new StringBuilder(); var result = _webResourceFinder.FindByIds(webResourceIds.ToArray()); foreach (var item in result) { content.Append(_webResourceContentCoder.CodeDecode(item.Content)); } webResources = content.ToString(); } else { webResources = T["notfound_record"]; } List <Guid> noneReadFields = new List <Guid>(); //获取字段权限 if (!CurrentUser.IsSuperAdmin && attributes.Count(n => n.AuthorizationEnabled) > 0) { var securityFields = attributes.Where(n => n.AuthorizationEnabled).Select(f => f.AttributeId)?.ToList(); if (securityFields.NotEmpty()) { //无权限的字段 noneReadFields = _systemUserPermissionService.GetNoneReadFields(CurrentUser.SystemUserId, securityFields); } } return(JOk(new { Views = views, Attributes = attributes, Buttons = buttons, WebResources = webResources, NoneReadFields = noneReadFields })); }