public IActionResult Get([FromQuery] QueryArgs queryArgs) { try { //args check if (queryArgs == null) { return(JsonResultModel.Error($"Parameter invalid:queryArgs = null")); } var checkResult = queryArgs.QueryArgsCheck(); if (!checkResult.IsSuccess) { return(checkResult.ToJsonResultModel()); } //argumentsDic generate Dictionary <string, object> argumentsDic = new Dictionary <string, object>(); foreach (var item in Request.Query) { if (!argumentsDic.ContainsKey(item.Key)) { argumentsDic.Add(item.Key.ToUpperInvariant(), item.Value); } } //get filter var interfaceAggregation = interfaceAggregationService.GetByInterfaceAggregationCode(queryArgs.interfaceCode); if (interfaceAggregation == null) { return(JsonResultModel.Error($"未能找到接口编码为[{queryArgs.interfaceCode}]对应的接口信息")); } var filter = conditionAggregationService.AnalysisConditionToFilterDefinitionByConditionId(interfaceAggregation.MetaObjectId, interfaceAggregation.SearchConditionId, argumentsDic); //get result switch ((InterfaceType)interfaceAggregation.InterfaceType) { case InterfaceType.CloudSingleObject: filter = triggerScriptEngineService.SingleObjectBefore(interfaceAggregation.MetaObjectId, interfaceAggregation.Code, filter); var singleObjectComponent = dataAccessService.GetSingleObjectComponent(interfaceAggregation.MetaObjectId, interfaceAggregation.FieldListId, filter); singleObjectComponent = triggerScriptEngineService.SingleObjectAfter(interfaceAggregation.MetaObjectId, interfaceAggregation.Code, singleObjectComponent); return(JsonResultModel.Success("get single data success", singleObjectComponent)); case InterfaceType.CloudTableList: filter = triggerScriptEngineService.TableListBefore(interfaceAggregation.MetaObjectId, interfaceAggregation.Code, filter); var sort = metaFieldService.GetSortDefinitionBySortFields(interfaceAggregation.MetaObjectId, null); var tableListComponent = dataAccessService.GetTableListComponent(interfaceAggregation.MetaObjectId, interfaceAggregation.FieldListId, filter, queryArgs.pageIndex, queryArgs.pageSize, sort, out int totalCount); tableListComponent = triggerScriptEngineService.TableListAfter(interfaceAggregation.MetaObjectId, interfaceAggregation.Code, tableListComponent); return(JsonResultModel.Success("get data list success", tableListComponent)); case InterfaceType.CloudCount: filter = triggerScriptEngineService.CountBefore(interfaceAggregation.MetaObjectId, interfaceAggregation.Code, filter); var count = dataAccessService.GetCount(interfaceAggregation.MetaObjectId, filter); count = triggerScriptEngineService.CountAfter(interfaceAggregation.MetaObjectId, interfaceAggregation.Code, count); return(JsonResultModel.Success("get data count success", count)); case InterfaceType.EnumeDataSource: break; case InterfaceType.TriggerScriptDataSource: object triggerScriptDataSourceResult = triggerScriptEngineService.TriggerScriptDataSource(interfaceAggregation.Code, argumentsDic, interfaceAggregation.Script); return(JsonResultModel.Success("get trigger script result success", triggerScriptDataSourceResult)); default: break; } return(JsonResultModel.Success("success,no data")); } catch (ArgumentNullException argNullEx) { return(JsonResultModel.Error(argNullEx.Message)); } catch (ArgumentException argEx) { return(JsonResultModel.Error(argEx.Message)); } catch (Exception ex) { return(JsonResultModel.Error(ex.Message)); } }
public IActionResult Post([FromBody] UITableListQueryArgs queryArgs) { try { //args check if (queryArgs == null) { return(JsonResultModel.Error($"Parameter invalid:queryArgs = null")); } var checkResult = queryArgs.ArgsCheck(); if (!checkResult.IsSuccess) { return(checkResult.ToJsonResultModel()); } //argumentsDic generate Dictionary <string, object> argumentsDic = new Dictionary <string, object>(); foreach (var item in Request.Query) { if (!argumentsDic.ContainsKey(item.Key)) { argumentsDic.Add(item.Key.ToUpperInvariant(), item.Value); } } //search data条件参数提供 if (queryArgs.SearchData?.Items != null) { foreach (var item in queryArgs.SearchData.Items) { if (!argumentsDic.ContainsKey(item.Name)) { argumentsDic.Add(item.Name.ToUpperInvariant(), item.Value); } } } //get filter var indexView = indexViewService.GetByCode(queryArgs.ViewName); if (indexView == null) { return(JsonResultModel.Error($"未能找到视图编码为[{queryArgs.ViewName}]对应的视图信息")); } //分析搜索条件,是否忽略参数校验为true,如果参数没传递则不抛出异常且处理为忽略参数 var filter = conditionAggregationService.AnalysisConditionToFilterDefinitionByConditionId(indexView.MetaObjectId, indexView.SearchConditionId, argumentsDic, true); //如果参数都没传递或者其他原因导致条件没有,则直接返回全部 if (filter == null) { filter = Builders <BsonDocument> .Filter.Empty; } filter = triggerScriptEngineService.TableListBefore(indexView.MetaObjectId, indexView.Code, filter); var sort = metaFieldService.GetSortDefinitionBySortFields(indexView.MetaObjectId, queryArgs.SortFields); var tableListComponent = dataAccessService.GetTableListComponent(indexView.MetaObjectId, indexView.FieldListId, filter, queryArgs.PageIndex, queryArgs.PageSize, sort, out int totalCount); tableListComponent = triggerScriptEngineService.TableListAfter(indexView.MetaObjectId, indexView.Code, tableListComponent); return(JsonResultModel.Success("get data list success", tableListComponent)); } catch (ArgumentNullException argNullEx) { return(JsonResultModel.Error(argNullEx.Message)); } catch (ArgumentException argEx) { return(JsonResultModel.Error(argEx.Message)); } catch (Exception ex) { return(JsonResultModel.Error(ex.Message)); } }