This commit is contained in:
2025-11-03 17:03:57 +08:00
commit 7a04b85667
16804 changed files with 2492292 additions and 0 deletions

471
TestAPI/Program.cs Normal file
View File

@@ -0,0 +1,471 @@
using Microsoft.AspNetCore.ResponseCompression;
using System.IO.Compression;
using System.Text.Json;
using System.Linq;
var builder = WebApplication.CreateBuilder(args);
// 添加响应压缩服务
builder.Services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
options.Providers.Add<GzipCompressionProvider>();
options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { "application/json" });
});
// 配置压缩级别
builder.Services.Configure<BrotliCompressionProviderOptions>(options =>
{
options.Level = CompressionLevel.Fastest;
});
builder.Services.Configure<GzipCompressionProviderOptions>(options =>
{
options.Level = CompressionLevel.Fastest;
});
var app = builder.Build();
// 使用响应压缩中间件
app.UseResponseCompression();
// 添加一个返回大量数据的API端点以便测试压缩效果
app.MapGet("/api/data", () => new
{
Message = "这是一个用于测试响应压缩的API端点",
Data = Enumerable.Range(1, 1000).Select(i => new { Id = i, Name = $"Item {i}", Description = $"这是第{i}个项目的描述,包含更多文本内容以便测试压缩效果。" }).ToArray(),
Timestamp = DateTime.UtcNow
});
// 添加类别API端点供前端测试使用
app.MapGet("/api/categories", () => new[]
{
new { Id = 1, Name = "手机CPU", Description = "移动设备处理器性能排名", ProductCount = 25 },
new { Id = 2, Name = "手机GPU", Description = "移动设备图形处理器性能排名", ProductCount = 18 },
new { Id = 3, Name = "电脑CPU", Description = "桌面处理器性能排名", ProductCount = 32 },
new { Id = 4, Name = "电脑GPU", Description = "桌面显卡性能排名", ProductCount = 28 }
});
// 添加产品API端点供前端测试使用
app.MapGet("/api/products", (int? categoryId, int page = 1, int pageSize = 20, string sortBy = "PerformanceScore", string order = "desc") =>
{
// 模拟产品数据
var allProducts = new[]
{
new { Id = 1, Name = "Snapdragon 8 Gen 2", Model = "SM8550-AB", Manufacturer = "Qualcomm", ReleaseYear = 2022, PerformanceScore = 3879, CurrentRank = 1, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 2, Name = "A16 Bionic", Model = "A16 Bionic", Manufacturer = "Apple", ReleaseYear = 2022, PerformanceScore = 3756, CurrentRank = 2, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 3, Name = "Dimensity 9200", Model = "MT6985", Manufacturer = "MediaTek", ReleaseYear = 2022, PerformanceScore = 3512, CurrentRank = 3, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 4, Name = "Snapdragon 8+ Gen 1", Model = "SM8475", Manufacturer = "Qualcomm", ReleaseYear = 2022, PerformanceScore = 3341, CurrentRank = 4, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 5, Name = "A15 Bionic", Model = "A15 Bionic", Manufacturer = "Apple", ReleaseYear = 2021, PerformanceScore = 3215, CurrentRank = 5, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 6, Name = "Adreno 740", Model = "Adreno 740", Manufacturer = "Qualcomm", ReleaseYear = 2022, PerformanceScore = 14350, CurrentRank = 1, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 7, Name = "Apple A16 GPU", Model = "A16 GPU", Manufacturer = "Apple", ReleaseYear = 2022, PerformanceScore = 13980, CurrentRank = 2, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 8, Name = "Mali-G715 MC10", Model = "Mali-G715", Manufacturer = "ARM", ReleaseYear = 2022, PerformanceScore = 12150, CurrentRank = 3, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 9, Name = "Adreno 730", Model = "Adreno 730", Manufacturer = "Qualcomm", ReleaseYear = 2022, PerformanceScore = 11020, CurrentRank = 4, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 10, Name = "Apple A15 GPU", Model = "A15 GPU", Manufacturer = "Apple", ReleaseYear = 2021, PerformanceScore = 10560, CurrentRank = 5, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 11, Name = "Intel Core i9-13900K", Model = "i9-13900K", Manufacturer = "Intel", ReleaseYear = 2022, PerformanceScore = 3176, CurrentRank = 1, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 12, Name = "AMD Ryzen 9 7950X", Model = "Ryzen 9 7950X", Manufacturer = "AMD", ReleaseYear = 2022, PerformanceScore = 3095, CurrentRank = 2, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 13, Name = "Intel Core i7-13700K", Model = "i7-13700K", Manufacturer = "Intel", ReleaseYear = 2022, PerformanceScore = 2956, CurrentRank = 3, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 14, Name = "AMD Ryzen 9 5900X", Model = "Ryzen 9 5900X", Manufacturer = "AMD", ReleaseYear = 2020, PerformanceScore = 2835, CurrentRank = 4, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 15, Name = "Intel Core i5-13600K", Model = "i5-13600K", Manufacturer = "Intel", ReleaseYear = 2022, PerformanceScore = 2742, CurrentRank = 5, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 16, Name = "NVIDIA GeForce RTX 4090", Model = "RTX 4090", Manufacturer = "NVIDIA", ReleaseYear = 2022, PerformanceScore = 38928, CurrentRank = 1, ImageUrl = "/images/placeholder.svg", CategoryId = 4 },
new { Id = 17, Name = "NVIDIA GeForce RTX 4080", Model = "RTX 4080", Manufacturer = "NVIDIA", ReleaseYear = 2022, PerformanceScore = 32168, CurrentRank = 2, ImageUrl = "/images/placeholder.svg", CategoryId = 4 },
new { Id = 18, Name = "NVIDIA GeForce RTX 3090 Ti", Model = "RTX 3090 Ti", Manufacturer = "NVIDIA", ReleaseYear = 2022, PerformanceScore = 28595, CurrentRank = 3, ImageUrl = "/images/placeholder.svg", CategoryId = 4 },
new { Id = 19, Name = "AMD Radeon RX 7900 XTX", Model = "RX 7900 XTX", Manufacturer = "AMD", ReleaseYear = 2022, PerformanceScore = 27850, CurrentRank = 4, ImageUrl = "/images/placeholder.svg", CategoryId = 4 },
new { Id = 20, Name = "NVIDIA GeForce RTX 3090", Model = "RTX 3090", Manufacturer = "NVIDIA", ReleaseYear = 2020, PerformanceScore = 26420, CurrentRank = 5, ImageUrl = "/images/placeholder.svg", CategoryId = 4 }
};
// 根据类别ID筛选
var filteredProducts = categoryId.HasValue
? allProducts.Where(p => p.CategoryId == categoryId.Value).ToArray()
: allProducts;
// 排序
filteredProducts = sortBy.ToLower() switch
{
"name" => order.ToLower() == "desc"
? filteredProducts.OrderByDescending(p => p.Name).ToArray()
: filteredProducts.OrderBy(p => p.Name).ToArray(),
"manufacturer" => order.ToLower() == "desc"
? filteredProducts.OrderByDescending(p => p.Manufacturer).ToArray()
: filteredProducts.OrderBy(p => p.Manufacturer).ToArray(),
"releaseyear" => order.ToLower() == "desc"
? filteredProducts.OrderByDescending(p => p.ReleaseYear).ToArray()
: filteredProducts.OrderBy(p => p.ReleaseYear).ToArray(),
_ => order.ToLower() == "desc"
? filteredProducts.OrderByDescending(p => p.PerformanceScore).ToArray()
: filteredProducts.OrderBy(p => p.PerformanceScore).ToArray()
};
var totalItems = filteredProducts.Length;
var totalPages = (int)Math.Ceiling((double)totalItems / pageSize);
// 分页
var pagedProducts = filteredProducts
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToArray();
return new {
Items = pagedProducts,
Total = totalItems,
CurrentPage = page,
PageSize = pageSize,
TotalPages = totalPages
};
});
// 添加产品详情API端点
app.MapGet("/api/products/{id}", (int id) =>
{
// 模拟产品详情数据
var allProducts = new[]
{
new {
Id = 1,
Name = "Snapdragon 8 Gen 2",
Model = "SM8550-AB",
Manufacturer = "Qualcomm",
ReleaseYear = 2022,
PerformanceScore = 3879,
CurrentRank = 1,
ImageUrl = "/images/placeholder.svg",
CategoryId = 1,
Description = "高通骁龙8 Gen 2是2022年推出的旗舰移动处理器采用4nm工艺制程。",
Specifications = new[] {
new { Name = "工艺", Value = "4nm" },
new { Name = "核心数", Value = "8" },
new { Name = "主频", Value = "3.2GHz" },
new { Name = "GPU", Value = "Adreno 740" }
},
PerformanceScores = new[] {
new { Benchmark = "Geekbench 5 Single-Core", Score = 1524 },
new { Benchmark = "Geekbench 5 Multi-Core", Score = 5352 },
new { Benchmark = "AnTuTu 9", Score = 1314582 }
}
},
new {
Id = 2,
Name = "A16 Bionic",
Model = "A16 Bionic",
Manufacturer = "Apple",
ReleaseYear = 2022,
PerformanceScore = 3756,
CurrentRank = 2,
ImageUrl = "/images/placeholder.svg",
CategoryId = 1,
Description = "苹果A16 Bionic是2022年推出的移动处理器采用4nm工艺制程。",
Specifications = new[] {
new { Name = "工艺", Value = "4nm" },
new { Name = "核心数", Value = "6" },
new { Name = "主频", Value = "3.46GHz" },
new { Name = "GPU", Value = "Apple A16 GPU" }
},
PerformanceScores = new[] {
new { Benchmark = "Geekbench 5 Single-Core", Score = 1874 },
new { Benchmark = "Geekbench 5 Multi-Core", Score = 5372 },
new { Benchmark = "AnTuTu 9", Score = 1425876 }
}
},
new {
Id = 3,
Name = "Dimensity 9200",
Model = "MT6985",
Manufacturer = "MediaTek",
ReleaseYear = 2022,
PerformanceScore = 3512,
CurrentRank = 3,
ImageUrl = "/images/placeholder.svg",
CategoryId = 1,
Description = "联发科天玑9200是2022年推出的旗舰移动处理器采用4nm工艺制程。",
Specifications = new[] {
new { Name = "工艺", Value = "4nm" },
new { Name = "核心数", Value = "8" },
new { Name = "主频", Value = "3.05GHz" },
new { Name = "GPU", Value = "Mali-G715 MC10" }
},
PerformanceScores = new[] {
new { Benchmark = "Geekbench 5 Single-Core", Score = 1424 },
new { Benchmark = "Geekbench 5 Multi-Core", Score = 4485 },
new { Benchmark = "AnTuTu 9", Score = 1245876 }
}
},
new {
Id = 4,
Name = "Snapdragon 8+ Gen 1",
Model = "SM8475",
Manufacturer = "Qualcomm",
ReleaseYear = 2022,
PerformanceScore = 3341,
CurrentRank = 4,
ImageUrl = "/images/placeholder.svg",
CategoryId = 1,
Description = "高通骁龙8+ Gen 1是2022年推出的旗舰移动处理器采用4nm工艺制程。",
Specifications = new[] {
new { Name = "工艺", Value = "4nm" },
new { Name = "核心数", Value = "8" },
new { Name = "主频", Value = "3.2GHz" },
new { Name = "GPU", Value = "Adreno 730" }
},
PerformanceScores = new[] {
new { Benchmark = "Geekbench 5 Single-Core", Score = 1314 },
new { Benchmark = "Geekbench 5 Multi-Core", Score = 4185 },
new { Benchmark = "AnTuTu 9", Score = 1145876 }
}
}
};
var product = allProducts.FirstOrDefault(p => p.Id == id);
if (product == null)
{
return Results.NotFound(new { Message = "产品不存在" });
}
return Results.Ok(product);
});
// 添加产品搜索API端点
app.MapGet("/api/products/search", (string q, int? categoryId) =>
{
// 模拟产品数据
var allProducts = new[]
{
new { Id = 1, Name = "Snapdragon 8 Gen 2", Model = "SM8550-AB", Manufacturer = "Qualcomm", ReleaseYear = 2022, PerformanceScore = 3879, CurrentRank = 1, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 2, Name = "A16 Bionic", Model = "A16 Bionic", Manufacturer = "Apple", ReleaseYear = 2022, PerformanceScore = 3756, CurrentRank = 2, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 3, Name = "Dimensity 9200", Model = "MT6985", Manufacturer = "MediaTek", ReleaseYear = 2022, PerformanceScore = 3512, CurrentRank = 3, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 4, Name = "Snapdragon 8+ Gen 1", Model = "SM8475", Manufacturer = "Qualcomm", ReleaseYear = 2022, PerformanceScore = 3341, CurrentRank = 4, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 5, Name = "A15 Bionic", Model = "A15 Bionic", Manufacturer = "Apple", ReleaseYear = 2021, PerformanceScore = 3215, CurrentRank = 5, ImageUrl = "/images/placeholder.svg", CategoryId = 1 },
new { Id = 6, Name = "Adreno 740", Model = "Adreno 740", Manufacturer = "Qualcomm", ReleaseYear = 2022, PerformanceScore = 14350, CurrentRank = 1, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 7, Name = "Apple A16 GPU", Model = "A16 GPU", Manufacturer = "Apple", ReleaseYear = 2022, PerformanceScore = 13980, CurrentRank = 2, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 8, Name = "Mali-G715 MC10", Model = "Mali-G715", Manufacturer = "ARM", ReleaseYear = 2022, PerformanceScore = 12150, CurrentRank = 3, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 9, Name = "Adreno 730", Model = "Adreno 730", Manufacturer = "Qualcomm", ReleaseYear = 2022, PerformanceScore = 11020, CurrentRank = 4, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 10, Name = "Apple A15 GPU", Model = "A15 GPU", Manufacturer = "Apple", ReleaseYear = 2021, PerformanceScore = 10560, CurrentRank = 5, ImageUrl = "/images/placeholder.svg", CategoryId = 2 },
new { Id = 11, Name = "Intel Core i9-13900K", Model = "i9-13900K", Manufacturer = "Intel", ReleaseYear = 2022, PerformanceScore = 3176, CurrentRank = 1, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 12, Name = "AMD Ryzen 9 7950X", Model = "Ryzen 9 7950X", Manufacturer = "AMD", ReleaseYear = 2022, PerformanceScore = 3095, CurrentRank = 2, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 13, Name = "Intel Core i7-13700K", Model = "i7-13700K", Manufacturer = "Intel", ReleaseYear = 2022, PerformanceScore = 2956, CurrentRank = 3, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 14, Name = "AMD Ryzen 9 5900X", Model = "Ryzen 9 5900X", Manufacturer = "AMD", ReleaseYear = 2020, PerformanceScore = 2835, CurrentRank = 4, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 15, Name = "Intel Core i5-13600K", Model = "i5-13600K", Manufacturer = "Intel", ReleaseYear = 2022, PerformanceScore = 2742, CurrentRank = 5, ImageUrl = "/images/placeholder.svg", CategoryId = 3 },
new { Id = 16, Name = "NVIDIA GeForce RTX 4090", Model = "RTX 4090", Manufacturer = "NVIDIA", ReleaseYear = 2022, PerformanceScore = 38928, CurrentRank = 1, ImageUrl = "/images/placeholder.svg", CategoryId = 4 },
new { Id = 17, Name = "NVIDIA GeForce RTX 4080", Model = "RTX 4080", Manufacturer = "NVIDIA", ReleaseYear = 2022, PerformanceScore = 32168, CurrentRank = 2, ImageUrl = "/images/placeholder.svg", CategoryId = 4 },
new { Id = 18, Name = "NVIDIA GeForce RTX 3090 Ti", Model = "RTX 3090 Ti", Manufacturer = "NVIDIA", ReleaseYear = 2022, PerformanceScore = 28595, CurrentRank = 3, ImageUrl = "/images/placeholder.svg", CategoryId = 4 },
new { Id = 19, Name = "AMD Radeon RX 7900 XTX", Model = "RX 7900 XTX", Manufacturer = "AMD", ReleaseYear = 2022, PerformanceScore = 27850, CurrentRank = 4, ImageUrl = "/images/placeholder.svg", CategoryId = 4 },
new { Id = 20, Name = "NVIDIA GeForce RTX 3090", Model = "RTX 3090", Manufacturer = "NVIDIA", ReleaseYear = 2020, PerformanceScore = 26420, CurrentRank = 5, ImageUrl = "/images/placeholder.svg", CategoryId = 4 }
};
// 根据类别ID筛选
var filteredProducts = categoryId.HasValue
? allProducts.Where(p => p.CategoryId == categoryId.Value).ToArray()
: allProducts;
// 根据搜索关键词筛选
if (!string.IsNullOrWhiteSpace(q))
{
filteredProducts = filteredProducts.Where(p =>
p.Name.Contains(q, StringComparison.OrdinalIgnoreCase) ||
p.Model.Contains(q, StringComparison.OrdinalIgnoreCase) ||
p.Manufacturer.Contains(q, StringComparison.OrdinalIgnoreCase)
).ToArray();
}
return filteredProducts;
});
// 添加产品对比API端点
app.MapPost("/api/comparison", async (HttpRequest request) =>
{
try
{
// 读取请求体
var requestBody = await new StreamReader(request.Body).ReadToEndAsync();
// 尝试解析为JSON对象
dynamic jsonBody = JsonSerializer.Deserialize<Dictionary<string, object>>(requestBody);
// 提取productIds数组
if (jsonBody == null || !jsonBody.ContainsKey("productIds"))
{
return Results.BadRequest(new { Message = "请求体必须包含productIds字段" });
}
// 获取productIds数组
var productIdsJson = jsonBody["productIds"].ToString();
var productIds = JsonSerializer.Deserialize<int[]>(productIdsJson);
// 验证产品ID数量
if (productIds == null || productIds.Length < 2 || productIds.Length > 4)
{
return Results.BadRequest(new { Message = "产品对比需要2-4个产品ID" });
}
// 模拟产品详情数据
var allProducts = new[]
{
new {
Id = 1,
Name = "Snapdragon 8 Gen 2",
Model = "SM8550-AB",
Manufacturer = "Qualcomm",
ReleaseYear = 2022,
PerformanceScore = 3879,
CurrentRank = 1,
ImageUrl = "/images/placeholder.svg",
CategoryId = 1,
Description = "高通骁龙8 Gen 2是2022年推出的旗舰移动处理器采用4nm工艺制程。",
Specifications = new[] {
new { Name = "工艺", Value = "4nm" },
new { Name = "核心数", Value = "8" },
new { Name = "主频", Value = "3.2GHz" },
new { Name = "GPU", Value = "Adreno 740" }
},
PerformanceScores = new[] {
new { Benchmark = "Geekbench 5 Single-Core", Score = 1524 },
new { Benchmark = "Geekbench 5 Multi-Core", Score = 5352 },
new { Benchmark = "AnTuTu 9", Score = 1314582 }
}
},
new {
Id = 2,
Name = "A16 Bionic",
Model = "A16 Bionic",
Manufacturer = "Apple",
ReleaseYear = 2022,
PerformanceScore = 3756,
CurrentRank = 2,
ImageUrl = "/images/placeholder.svg",
CategoryId = 1,
Description = "苹果A16 Bionic是2022年推出的移动处理器采用4nm工艺制程。",
Specifications = new[] {
new { Name = "工艺", Value = "4nm" },
new { Name = "核心数", Value = "6" },
new { Name = "主频", Value = "3.46GHz" },
new { Name = "GPU", Value = "Apple A16 GPU" }
},
PerformanceScores = new[] {
new { Benchmark = "Geekbench 5 Single-Core", Score = 1874 },
new { Benchmark = "Geekbench 5 Multi-Core", Score = 5372 },
new { Benchmark = "AnTuTu 9", Score = 1425876 }
}
},
new {
Id = 3,
Name = "Dimensity 9200",
Model = "MT6985",
Manufacturer = "MediaTek",
ReleaseYear = 2022,
PerformanceScore = 3512,
CurrentRank = 3,
ImageUrl = "/images/placeholder.svg",
CategoryId = 1,
Description = "联发科天玑9200是2022年推出的旗舰移动处理器采用4nm工艺制程。",
Specifications = new[] {
new { Name = "工艺", Value = "4nm" },
new { Name = "核心数", Value = "8" },
new { Name = "主频", Value = "3.05GHz" },
new { Name = "GPU", Value = "Mali-G715 MC10" }
},
PerformanceScores = new[] {
new { Benchmark = "Geekbench 5 Single-Core", Score = 1424 },
new { Benchmark = "Geekbench 5 Multi-Core", Score = 4485 },
new { Benchmark = "AnTuTu 9", Score = 1245876 }
}
},
new {
Id = 4,
Name = "Snapdragon 8+ Gen 1",
Model = "SM8475",
Manufacturer = "Qualcomm",
ReleaseYear = 2022,
PerformanceScore = 3341,
CurrentRank = 4,
ImageUrl = "/images/placeholder.svg",
CategoryId = 1,
Description = "高通骁龙8+ Gen 1是2022年推出的旗舰移动处理器采用4nm工艺制程。",
Specifications = new[] {
new { Name = "工艺", Value = "4nm" },
new { Name = "核心数", Value = "8" },
new { Name = "主频", Value = "3.2GHz" },
new { Name = "GPU", Value = "Adreno 730" }
},
PerformanceScores = new[] {
new { Benchmark = "Geekbench 5 Single-Core", Score = 1314 },
new { Benchmark = "Geekbench 5 Multi-Core", Score = 4185 },
new { Benchmark = "AnTuTu 9", Score = 1145876 }
}
}
};
// 获取请求的产品
var selectedProducts = allProducts.Where(p => productIds.Contains(p.Id)).ToArray();
// 检查是否找到了所有请求的产品
if (selectedProducts.Length != productIds.Length)
{
return Results.NotFound(new { Message = "一个或多个产品不存在" });
}
// 创建对比数据
var comparisonData = new {
Products = selectedProducts,
ComparisonMatrix = new {
PerformanceScore = selectedProducts.Select(p => new {
ProductId = p.Id,
ProductName = p.Name,
Value = p.PerformanceScore,
IsBest = p.PerformanceScore == selectedProducts.Max(x => x.PerformanceScore),
IsWorst = p.PerformanceScore == selectedProducts.Min(x => x.PerformanceScore)
}).ToArray(),
ReleaseYear = selectedProducts.Select(p => new {
ProductId = p.Id,
ProductName = p.Name,
Value = p.ReleaseYear,
IsBest = p.ReleaseYear == selectedProducts.Max(x => x.ReleaseYear),
IsWorst = p.ReleaseYear == selectedProducts.Min(x => x.ReleaseYear)
}).ToArray()
},
PerformanceComparison = new {
Benchmarks = new[] {
new {
Name = "Geekbench 5 Single-Core",
Values = selectedProducts.Select(p => new {
ProductId = p.Id,
ProductName = p.Name,
Value = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Single-Core")?.Score ?? 0,
IsBest = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Single-Core")?.Score == selectedProducts.Max(x => x.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Single-Core")?.Score ?? 0),
IsWorst = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Single-Core")?.Score == selectedProducts.Min(x => x.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Single-Core")?.Score ?? int.MaxValue)
}).ToArray()
},
new {
Name = "Geekbench 5 Multi-Core",
Values = selectedProducts.Select(p => new {
ProductId = p.Id,
ProductName = p.Name,
Value = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Multi-Core")?.Score ?? 0,
IsBest = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Multi-Core")?.Score == selectedProducts.Max(x => x.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Multi-Core")?.Score ?? 0),
IsWorst = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Multi-Core")?.Score == selectedProducts.Min(x => x.PerformanceScores.FirstOrDefault(s => s.Benchmark == "Geekbench 5 Multi-Core")?.Score ?? int.MaxValue)
}).ToArray()
},
new {
Name = "AnTuTu 9",
Values = selectedProducts.Select(p => new {
ProductId = p.Id,
ProductName = p.Name,
Value = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "AnTuTu 9")?.Score ?? 0,
IsBest = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "AnTuTu 9")?.Score == selectedProducts.Max(x => x.PerformanceScores.FirstOrDefault(s => s.Benchmark == "AnTuTu 9")?.Score ?? 0),
IsWorst = p.PerformanceScores.FirstOrDefault(s => s.Benchmark == "AnTuTu 9")?.Score == selectedProducts.Min(x => x.PerformanceScores.FirstOrDefault(s => s.Benchmark == "AnTuTu 9")?.Score ?? int.MaxValue)
}).ToArray()
}
}
}
};
return Results.Ok(comparisonData);
}
catch (Exception ex)
{
return Results.BadRequest(new { Message = $"处理请求时出错: {ex.Message}" });
}
});
app.MapGet("/", () => "Hello World!");
app.Run();

View File

@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5034",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7100;http://localhost:5034",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

9
TestAPI/TestAPI.csproj Normal file
View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

9
TestAPI/appsettings.json Normal file
View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"TestAPI/1.0.0": {
"runtime": {
"TestAPI.dll": {}
}
}
}
},
"libraries": {
"TestAPI/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,19 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "9.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1 @@
{"Version":1,"ManifestType":"Build","Endpoints":[]}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("TestAPI")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("TestAPI")]
[assembly: System.Reflection.AssemblyTitleAttribute("TestAPI")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。

View File

@@ -0,0 +1 @@
ccdd8558c5bd69980236f6ef7435019aea79860a1fdbecb265564d3b99885b5a

View File

@@ -0,0 +1,21 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb = true
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = TestAPI
build_property.RootNamespace = TestAPI
build_property.ProjectDir = C:\work\电脑硬件-01\TestAPI\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.RazorLangVersion = 9.0
build_property.SupportLocalizedComponentNames =
build_property.GenerateRazorMetadataSourceChecksumAttributes =
build_property.MSBuildProjectDirectory = C:\work\电脑硬件-01\TestAPI
build_property._RazorSourceGeneratorDebug =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,17 @@
// <auto-generated/>
global using global::Microsoft.AspNetCore.Builder;
global using global::Microsoft.AspNetCore.Hosting;
global using global::Microsoft.AspNetCore.Http;
global using global::Microsoft.AspNetCore.Routing;
global using global::Microsoft.Extensions.Configuration;
global using global::Microsoft.Extensions.DependencyInjection;
global using global::Microsoft.Extensions.Hosting;
global using global::Microsoft.Extensions.Logging;
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Net.Http.Json;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

View File

@@ -0,0 +1 @@
629dc1ba4c6ea1c70ecea85384c28652dcd9f627da004e854aea08234c082e60

View File

@@ -0,0 +1,27 @@
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\rpswa.dswa.cache.json
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\TestAPI.GeneratedMSBuildEditorConfig.editorconfig
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\TestAPI.AssemblyInfoInputs.cache
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\TestAPI.AssemblyInfo.cs
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\TestAPI.csproj.CoreCompileInputs.cache
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\TestAPI.MvcApplicationPartsAssemblyInfo.cache
C:\work\电脑硬件-01\TestAPI\bin\Debug\net9.0\appsettings.Development.json
C:\work\电脑硬件-01\TestAPI\bin\Debug\net9.0\appsettings.json
C:\work\电脑硬件-01\TestAPI\bin\Debug\net9.0\TestAPI.staticwebassets.endpoints.json
C:\work\电脑硬件-01\TestAPI\bin\Debug\net9.0\TestAPI.exe
C:\work\电脑硬件-01\TestAPI\bin\Debug\net9.0\TestAPI.deps.json
C:\work\电脑硬件-01\TestAPI\bin\Debug\net9.0\TestAPI.runtimeconfig.json
C:\work\电脑硬件-01\TestAPI\bin\Debug\net9.0\TestAPI.dll
C:\work\电脑硬件-01\TestAPI\bin\Debug\net9.0\TestAPI.pdb
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\rjimswa.dswa.cache.json
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\rjsmrazor.dswa.cache.json
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\rjsmcshtml.dswa.cache.json
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\scopedcss\bundle\TestAPI.styles.css
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\staticwebassets.build.json
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\staticwebassets.build.json.cache
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\staticwebassets.development.json
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\staticwebassets.build.endpoints.json
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\TestAPI.dll
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\refint\TestAPI.dll
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\TestAPI.pdb
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\TestAPI.genruntimeconfig.cache
C:\work\电脑硬件-01\TestAPI\obj\Debug\net9.0\ref\TestAPI.dll

Binary file not shown.

View File

@@ -0,0 +1 @@
38a42475f40bb80e703a6be2ed50ba07b47c048703c6393754361ef17fa8a577

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
{"GlobalPropertiesHash":"dVVFBPF+yx1XeT2fudEGH1R3XO+aUijSkKblyMEVniE=","FingerprintPatternsHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["Lpeh1RwLXIyvQKXlP5V/sva7Z/agva4HylWWs9x367k=","NpVS4EAMz7A1S25A2Hx2pp3S0yLCtTxxWK1YTu5DYG4=","ZG\u002BuM97rTAPjb9pyJf6/REwgb991A7gdC1eXa0J08qk=","IqGtI2TxPcfTta2GT9LoWzn8eGroGmjezPv2CukNgaQ="],"CachedAssets":{},"CachedCopyCandidates":{}}

View File

@@ -0,0 +1 @@
{"GlobalPropertiesHash":"WBkI6Z6c2yRX/TuiMz89dqrp0Y8PeOUEoBMF1UPIwhY=","FingerprintPatternsHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["Lpeh1RwLXIyvQKXlP5V/sva7Z/agva4HylWWs9x367k=","NpVS4EAMz7A1S25A2Hx2pp3S0yLCtTxxWK1YTu5DYG4=","ZG\u002BuM97rTAPjb9pyJf6/REwgb991A7gdC1eXa0J08qk=","IqGtI2TxPcfTta2GT9LoWzn8eGroGmjezPv2CukNgaQ="],"CachedAssets":{},"CachedCopyCandidates":{}}

View File

@@ -0,0 +1 @@
{"GlobalPropertiesHash":"hVHQLSOValT1B/pCNBhgcbHPS5nopeoAhzjLbDuN7Zg=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["Lpeh1RwLXIyvQKXlP5V/sva7Z/agva4HylWWs9x367k=","NpVS4EAMz7A1S25A2Hx2pp3S0yLCtTxxWK1YTu5DYG4="],"CachedAssets":{},"CachedCopyCandidates":{}}

View File

@@ -0,0 +1 @@
{"Version":1,"ManifestType":"Build","Endpoints":[]}

View File

@@ -0,0 +1 @@
{"Version":1,"Hash":"64bSZbxOJKaY+8UM7wPlJ/AHdb+9Pt5O8g8LvheWrpE=","Source":"TestAPI","BasePath":"_content/TestAPI","Mode":"Default","ManifestType":"Build","ReferencedProjectsConfiguration":[],"DiscoveryPatterns":[],"Assets":[],"Endpoints":[]}

View File

@@ -0,0 +1 @@
64bSZbxOJKaY+8UM7wPlJ/AHdb+9Pt5O8g8LvheWrpE=

View File

@@ -0,0 +1,80 @@
{
"format": 1,
"restore": {
"C:\\work\\电脑硬件-01\\TestAPI\\TestAPI.csproj": {}
},
"projects": {
"C:\\work\\电脑硬件-01\\TestAPI\\TestAPI.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\work\\电脑硬件-01\\TestAPI\\TestAPI.csproj",
"projectName": "TestAPI",
"projectPath": "C:\\work\\电脑硬件-01\\TestAPI\\TestAPI.csproj",
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
"outputPath": "C:\\work\\电脑硬件-01\\TestAPI\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\代\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {},
"https://nuget.cdn.azure.cn/v3/index.json": {},
"https://packages.chinacloudapi.cn/v3/index.json": {},
"https://packages.microsoft.com/dotnet": {},
"https://www.nuget.org/api/v2/": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.AspNetCore.App": {
"privateAssets": "none"
},
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\代\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\代\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,86 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"C:\\Users\\代\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\work\\电脑硬件-01\\TestAPI\\TestAPI.csproj",
"projectName": "TestAPI",
"projectPath": "C:\\work\\电脑硬件-01\\TestAPI\\TestAPI.csproj",
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
"outputPath": "C:\\work\\电脑硬件-01\\TestAPI\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\代\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {},
"https://nuget.cdn.azure.cn/v3/index.json": {},
"https://packages.chinacloudapi.cn/v3/index.json": {},
"https://packages.microsoft.com/dotnet": {},
"https://www.nuget.org/api/v2/": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.AspNetCore.App": {
"privateAssets": "none"
},
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "+9ap18uw05w=",
"success": true,
"projectFilePath": "C:\\work\\电脑硬件-01\\TestAPI\\TestAPI.csproj",
"expectedPackageFiles": [],
"logs": []
}