Commit 96ef7e43 by lcx

graphql允许字段为null,添加字典接口

parent 2ed59b4b
...@@ -7,12 +7,12 @@ public class ChartDataType : ObjectGraphType<ChartData> ...@@ -7,12 +7,12 @@ public class ChartDataType : ObjectGraphType<ChartData>
{ {
public ChartDataType() public ChartDataType()
{ {
Field(x => x.X); Field(x => x.X, nullable: true);
Field(x => x.Y); Field(x => x.Y, nullable: true);
Field(x => x.Name); Field(x => x.Name, nullable: true);
Field(x => x.Value); Field(x => x.Value, nullable: true);
Field(x => x.Total); Field(x => x.Total, nullable: true);
Field(x => x.Type); Field(x => x.Type, nullable: true);
} }
} }
} }
...@@ -59,6 +59,21 @@ public PerformanceQuery(GraphQLService service) ...@@ -59,6 +59,21 @@ public PerformanceQuery(GraphQLService service)
return service.GetReportPerformance(reportId, parameters); return service.GetReportPerformance(reportId, parameters);
} }
); );
Field<ListGraphType<ReportPerformanceType>>("dictionary",
arguments: new QueryArguments(
new QueryArgument<IntGraphType>() { Name = QueryParams.reportId },
new QueryArgument<ListGraphType<StringGraphType>>() { Name = QueryParams.category }
),
resolve: context =>
{
int reportId = context.Arguments.ContainsKey(QueryParams.reportId)
? ConvertHelper.To<int>(context.Arguments[QueryParams.reportId])
: 15;
var parameters = GetDynamicParameters(context.Arguments, QueryParams.category);
return service.GetReportPerformance(reportId, parameters);
}
);
} }
public static QueryArguments Arguments(params QueryArgument[] args) public static QueryArguments Arguments(params QueryArgument[] args)
...@@ -92,9 +107,6 @@ public DynamicParameters GetDynamicParameters(Dictionary<string, object> argumen ...@@ -92,9 +107,6 @@ public DynamicParameters GetDynamicParameters(Dictionary<string, object> argumen
{ {
if (arguments.ContainsKey(item)) if (arguments.ContainsKey(item))
{ {
if (item == QueryParams.category)
parameters.Add(item.ToLower(), arguments[item]?.ToString().Split(','));
else
parameters.Add(item.ToLower(), arguments[item]); parameters.Add(item.ToLower(), arguments[item]);
} }
} }
......
...@@ -9,9 +9,9 @@ public class ReportDataType : ObjectGraphType<ReportData> ...@@ -9,9 +9,9 @@ public class ReportDataType : ObjectGraphType<ReportData>
{ {
public ReportDataType() public ReportDataType()
{ {
Field(x => x.ReportID); Field(x => x.ReportID, type: typeof(IdGraphType));
Field(x => x.ChartType); Field(x => x.ChartType, nullable: true);
Field(x => x.Sort); Field(x => x.Sort, nullable: true);
Field(x => x.Title); Field(x => x.Title);
Field(x => x.QueryName); Field(x => x.QueryName);
Field(x => x.QueryArguments); Field(x => x.QueryArguments);
...@@ -24,8 +24,8 @@ public ReportDataType() ...@@ -24,8 +24,8 @@ public ReportDataType()
Field(x => x.NTitle); Field(x => x.NTitle);
Field(x => x.NUnit); Field(x => x.NUnit);
Field(x => x.Formula); Field(x => x.Formula);
Field(x => x.DataType); Field(x => x.DataType, nullable: true);
Field(x => x.FilterValue); Field(x => x.FilterValue, nullable: true);
} }
} }
} }
...@@ -8,14 +8,14 @@ public class ReportPerformanceType : ObjectGraphType<ReportTable> ...@@ -8,14 +8,14 @@ public class ReportPerformanceType : ObjectGraphType<ReportTable>
{ {
public ReportPerformanceType() public ReportPerformanceType()
{ {
Field(x => x.AccountingUnit); Field(x => x.AccountingUnit, nullable: true);
Field(x => x.Category); Field(x => x.Category, nullable: true);
Field(x => x.ItemName); Field(x => x.ItemName, nullable: true);
Field(x => x.CurrentValue); Field(x => x.CurrentValue, nullable: true);
Field(x => x.LastIssueValue); Field(x => x.LastIssueValue, nullable: true);
Field(x => x.SamePeriodValue); Field(x => x.SamePeriodValue, nullable: true);
Field(x => x.BudgetValue); Field(x => x.BudgetValue, nullable: true);
Field(x => x.RatioValue); Field(x => x.RatioValue, nullable: true);
} }
} }
} }
...@@ -10,8 +10,8 @@ public class ReportData ...@@ -10,8 +10,8 @@ public class ReportData
public ReportData(rep_report report) public ReportData(rep_report report)
{ {
ReportID = report.ID; ReportID = report.ID;
ChartType = report.ChartType ?? 0; ChartType = report.ChartType;
Sort = report.Sort ?? 0; Sort = report.Sort;
Title = report.Title; Title = report.Title;
QueryName = report.QueryName; QueryName = report.QueryName;
QueryArguments = report.QueryArguments; QueryArguments = report.QueryArguments;
...@@ -24,8 +24,8 @@ public ReportData(rep_report report) ...@@ -24,8 +24,8 @@ public ReportData(rep_report report)
NTitle = report.NTitle; NTitle = report.NTitle;
NUnit = report.NUnit; NUnit = report.NUnit;
Formula = report.Formula; Formula = report.Formula;
DataType = report.DataType ?? 0; DataType = report.DataType;
FilterValue = report.FilterValue ?? 0; FilterValue = report.FilterValue;
ChartData = new List<ChartData>(); ChartData = new List<ChartData>();
} }
...@@ -34,12 +34,12 @@ public ReportData(rep_report report) ...@@ -34,12 +34,12 @@ public ReportData(rep_report report)
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public int ChartType { get; set; } public Nullable<int> ChartType { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public int Sort { get; set; } public Nullable<int> Sort { get; set; }
/// <summary> /// <summary>
/// 报表标题 /// 报表标题
...@@ -104,12 +104,12 @@ public ReportData(rep_report report) ...@@ -104,12 +104,12 @@ public ReportData(rep_report report)
/// <summary> /// <summary>
/// 1表示需要进行小于百分2的类型进行合并 /// 1表示需要进行小于百分2的类型进行合并
/// </summary> /// </summary>
public int DataType { get; set; } public Nullable<int> DataType { get; set; }
/// <summary> /// <summary>
/// 图标value过滤执值 /// 图标value过滤执值
/// </summary> /// </summary>
public decimal FilterValue { get; set; } public Nullable<decimal> FilterValue { get; set; }
/// <summary> /// <summary>
/// 图表数据 /// 图表数据
...@@ -146,7 +146,7 @@ public class ChartData ...@@ -146,7 +146,7 @@ public class ChartData
/// <summary> /// <summary>
/// 总量 /// 总量
/// </summary> /// </summary>
public decimal Total { get; set; } public Nullable<decimal> Total { get; set; }
/// <summary> /// <summary>
/// ChartData 类型标签 /// ChartData 类型标签
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment