测试
This commit is contained in:
BIN
backend/.vs/HardwarePerformance/DesignTimeBuild/.dtbcache.v2
Normal file
BIN
backend/.vs/HardwarePerformance/DesignTimeBuild/.dtbcache.v2
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/.vs/HardwarePerformance/v17/.futdcache.v2
Normal file
BIN
backend/.vs/HardwarePerformance/v17/.futdcache.v2
Normal file
Binary file not shown.
BIN
backend/.vs/HardwarePerformance/v17/.suo
Normal file
BIN
backend/.vs/HardwarePerformance/v17/.suo
Normal file
Binary file not shown.
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|c:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\hardwareperformance.api\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|solutionrelative:hardwareperformance.api\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|c:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\hardwareperformance.api\\hardwareperformance.api.http||{5703B403-55E7-4C63-8C88-A8F52C7A45C5}",
|
||||
"RelativeMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|solutionrelative:hardwareperformance.api\\hardwareperformance.api.http||{5703B403-55E7-4C63-8C88-A8F52C7A45C5}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|c:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\hardwareperformance.api\\hardwareperformance.api.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
|
||||
"RelativeMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|solutionrelative:hardwareperformance.api\\hardwareperformance.api.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\Program.cs",
|
||||
"RelativeDocumentMoniker": "HardwarePerformance.API\\Program.cs",
|
||||
"ToolTip": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\Program.cs",
|
||||
"RelativeToolTip": "HardwarePerformance.API\\Program.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-31T00:43:17.145Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "HardwarePerformance.API.http",
|
||||
"DocumentMoniker": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.http",
|
||||
"RelativeDocumentMoniker": "HardwarePerformance.API\\HardwarePerformance.API.http",
|
||||
"ToolTip": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.http",
|
||||
"RelativeToolTip": "HardwarePerformance.API\\HardwarePerformance.API.http",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003502|",
|
||||
"WhenOpened": "2025-10-31T00:43:15.855Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "HardwarePerformance.API.csproj",
|
||||
"DocumentMoniker": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"RelativeDocumentMoniker": "HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"ToolTip": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"RelativeToolTip": "HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
|
||||
"WhenOpened": "2025-10-31T00:31:33.848Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{269a02dc-6af8-11d3-bdc4-00c04f688e50}"
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{cce594b6-0c39-4442-ba28-10c64ac7e89f}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
77
backend/.vs/HardwarePerformance/v17/DocumentLayout.json
Normal file
77
backend/.vs/HardwarePerformance/v17/DocumentLayout.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|c:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\hardwareperformance.api\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|solutionrelative:hardwareperformance.api\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|c:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\hardwareperformance.api\\hardwareperformance.api.http||{5703B403-55E7-4C63-8C88-A8F52C7A45C5}",
|
||||
"RelativeMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|solutionrelative:hardwareperformance.api\\hardwareperformance.api.http||{5703B403-55E7-4C63-8C88-A8F52C7A45C5}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|c:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\hardwareperformance.api\\hardwareperformance.api.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
|
||||
"RelativeMoniker": "D:0:0:{3A62F1B9-2352-4304-A7C5-BC395F7CC252}|HardwarePerformance.API\\HardwarePerformance.API.csproj|solutionrelative:hardwareperformance.api\\hardwareperformance.api.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\Program.cs",
|
||||
"RelativeDocumentMoniker": "HardwarePerformance.API\\Program.cs",
|
||||
"ToolTip": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\Program.cs",
|
||||
"RelativeToolTip": "HardwarePerformance.API\\Program.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-31T00:43:17.145Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "HardwarePerformance.API.http",
|
||||
"DocumentMoniker": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.http",
|
||||
"RelativeDocumentMoniker": "HardwarePerformance.API\\HardwarePerformance.API.http",
|
||||
"ToolTip": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.http",
|
||||
"RelativeToolTip": "HardwarePerformance.API\\HardwarePerformance.API.http",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003502|",
|
||||
"WhenOpened": "2025-10-31T00:43:15.855Z"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "HardwarePerformance.API.csproj",
|
||||
"DocumentMoniker": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"RelativeDocumentMoniker": "HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"ToolTip": "C:\\work\\\u7535\u8111\u786C\u4EF6-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"RelativeToolTip": "HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
|
||||
"WhenOpened": "2025-10-31T00:31:33.848Z"
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{269a02dc-6af8-11d3-bdc4-00c04f688e50}"
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{cce594b6-0c39-4442-ba28-10c64ac7e89f}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
BIN
backend/.vs/ProjectEvaluation/hardwareperformance.strings.v9.bin
Normal file
BIN
backend/.vs/ProjectEvaluation/hardwareperformance.strings.v9.bin
Normal file
Binary file not shown.
@@ -0,0 +1,46 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using HardwarePerformance.API.Models;
|
||||
|
||||
namespace HardwarePerformance.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class CategoriesController : ControllerBase
|
||||
{
|
||||
private static readonly List<Category> _categories = new()
|
||||
{
|
||||
new Category { Id = 1, Name = "手机CPU", Description = "移动设备处理器" },
|
||||
new Category { Id = 2, Name = "手机GPU", Description = "移动设备图形处理器" },
|
||||
new Category { Id = 3, Name = "电脑CPU", Description = "桌面和笔记本处理器" },
|
||||
new Category { Id = 4, Name = "电脑GPU", Description = "桌面和笔记本图形处理器" }
|
||||
};
|
||||
|
||||
[HttpGet]
|
||||
public ApiResponse<IEnumerable<Category>> GetCategories()
|
||||
{
|
||||
return new ApiResponse<IEnumerable<Category>>
|
||||
{
|
||||
Data = _categories
|
||||
};
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public ActionResult<ApiResponse<Category>> GetCategory(int id)
|
||||
{
|
||||
var category = _categories.FirstOrDefault(c => c.Id == id);
|
||||
if (category == null)
|
||||
{
|
||||
return NotFound(new ApiResponse<Category>
|
||||
{
|
||||
Success = false,
|
||||
Message = "未找到指定的类别"
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new ApiResponse<Category>
|
||||
{
|
||||
Data = category
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using HardwarePerformance.API.Models;
|
||||
|
||||
namespace HardwarePerformance.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ComparisonController : ControllerBase
|
||||
{
|
||||
private static readonly List<Product> _products = new()
|
||||
{
|
||||
new Product
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Apple A17 Pro",
|
||||
Model = "A17 Pro",
|
||||
Manufacturer = "Apple",
|
||||
CategoryId = 1,
|
||||
CurrentRank = 1,
|
||||
ReleaseDate = new DateTime(2023, 9, 12),
|
||||
Price = null
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 2,
|
||||
Name = "Snapdragon 8 Gen 3",
|
||||
Model = "SM8650-AB",
|
||||
Manufacturer = "Qualcomm",
|
||||
CategoryId = 1,
|
||||
CurrentRank = 2,
|
||||
ReleaseDate = new DateTime(2023, 10, 24),
|
||||
Price = null
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 3,
|
||||
Name = "Intel Core i9-13900K",
|
||||
Model = "Core i9-13900K",
|
||||
Manufacturer = "Intel",
|
||||
CategoryId = 3,
|
||||
CurrentRank = 1,
|
||||
ReleaseDate = new DateTime(2022, 10, 20),
|
||||
Price = 589.99m
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 4,
|
||||
Name = "AMD Ryzen 9 7950X",
|
||||
Model = "Ryzen 9 7950X",
|
||||
Manufacturer = "AMD",
|
||||
CategoryId = 3,
|
||||
CurrentRank = 2,
|
||||
ReleaseDate = new DateTime(2022, 9, 27),
|
||||
Price = 699.99m
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 5,
|
||||
Name = "NVIDIA GeForce RTX 4090",
|
||||
Model = "RTX 4090",
|
||||
Manufacturer = "NVIDIA",
|
||||
CategoryId = 4,
|
||||
CurrentRank = 1,
|
||||
ReleaseDate = new DateTime(2022, 10, 12),
|
||||
Price = 1599.99m
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 6,
|
||||
Name = "AMD Radeon RX 7900 XTX",
|
||||
Model = "RX 7900 XTX",
|
||||
Manufacturer = "AMD",
|
||||
CategoryId = 4,
|
||||
CurrentRank = 2,
|
||||
ReleaseDate = new DateTime(2022, 12, 3),
|
||||
Price = 999.99m
|
||||
}
|
||||
};
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult<ApiResponse<object>> CompareProducts([FromBody] ComparisonRequest request)
|
||||
{
|
||||
// 验证请求
|
||||
if (request.ProductIds == null || request.ProductIds.Count < 2 || request.ProductIds.Count > 4)
|
||||
{
|
||||
return BadRequest(new ApiResponse<object>
|
||||
{
|
||||
Success = false,
|
||||
Message = "产品ID数量必须在2到4之间"
|
||||
});
|
||||
}
|
||||
|
||||
// 获取产品
|
||||
var products = _products.Where(p => request.ProductIds.Contains(p.Id)).ToList();
|
||||
|
||||
if (products.Count != request.ProductIds.Count)
|
||||
{
|
||||
return NotFound(new ApiResponse<object>
|
||||
{
|
||||
Success = false,
|
||||
Message = "一个或多个产品ID无效"
|
||||
});
|
||||
}
|
||||
|
||||
// 检查是否所有产品属于同一类别
|
||||
var categories = products.Select(p => p.CategoryId).Distinct().ToList();
|
||||
if (categories.Count > 1)
|
||||
{
|
||||
return BadRequest(new ApiResponse<object>
|
||||
{
|
||||
Success = false,
|
||||
Message = "所有产品必须属于同一类别"
|
||||
});
|
||||
}
|
||||
|
||||
// 创建对比数据
|
||||
var comparisonData = new
|
||||
{
|
||||
Products = products.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.Name,
|
||||
p.Model,
|
||||
p.Manufacturer,
|
||||
p.CategoryId,
|
||||
p.CurrentRank,
|
||||
p.ReleaseDate,
|
||||
p.Price,
|
||||
PerformanceScore = 100 - p.CurrentRank // 使用排名计算模拟性能分数
|
||||
}).ToList(),
|
||||
Comparison = GenerateComparisonMatrix(products)
|
||||
};
|
||||
|
||||
return Ok(new ApiResponse<object>
|
||||
{
|
||||
Data = comparisonData
|
||||
});
|
||||
}
|
||||
|
||||
private object GenerateComparisonMatrix(List<Product> products)
|
||||
{
|
||||
var matrix = new List<Dictionary<string, object>>();
|
||||
|
||||
// 添加基本信息行
|
||||
matrix.Add(new Dictionary<string, object>
|
||||
{
|
||||
["指标"] = "产品名称",
|
||||
["类型"] = "基本信息"
|
||||
});
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
matrix[0][$"{product.Name}"] = product.Name;
|
||||
}
|
||||
|
||||
// 添加制造商行
|
||||
matrix.Add(new Dictionary<string, object>
|
||||
{
|
||||
["指标"] = "制造商",
|
||||
["类型"] = "基本信息"
|
||||
});
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
matrix[1][$"{product.Name}"] = product.Manufacturer;
|
||||
}
|
||||
|
||||
// 添加型号行
|
||||
matrix.Add(new Dictionary<string, object>
|
||||
{
|
||||
["指标"] = "型号",
|
||||
["类型"] = "基本信息"
|
||||
});
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
matrix[2][$"{product.Name}"] = product.Model;
|
||||
}
|
||||
|
||||
// 添加排名行
|
||||
matrix.Add(new Dictionary<string, object>
|
||||
{
|
||||
["指标"] = "当前排名",
|
||||
["类型"] = "性能指标"
|
||||
});
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
matrix[3][$"{product.Name}"] = product.CurrentRank;
|
||||
}
|
||||
|
||||
// 添加性能分数行(模拟)
|
||||
matrix.Add(new Dictionary<string, object>
|
||||
{
|
||||
["指标"] = "性能分数",
|
||||
["类型"] = "性能指标"
|
||||
});
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
matrix[4][$"{product.Name}"] = 100 - product.CurrentRank;
|
||||
}
|
||||
|
||||
// 添加发布日期行
|
||||
matrix.Add(new Dictionary<string, object>
|
||||
{
|
||||
["指标"] = "发布日期",
|
||||
["类型"] = "基本信息"
|
||||
});
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
matrix[5][$"{product.Name}"] = product.ReleaseDate.ToString("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
// 添加价格行
|
||||
matrix.Add(new Dictionary<string, object>
|
||||
{
|
||||
["指标"] = "价格",
|
||||
["类型"] = "基本信息"
|
||||
});
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
matrix[6][$"{product.Name}"] = product.Price?.ToString("C") ?? "N/A";
|
||||
}
|
||||
|
||||
// 标记最优和最差值
|
||||
MarkBestAndWorstValues(matrix, products);
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
private void MarkBestAndWorstValues(List<Dictionary<string, object>> matrix, List<Product> products)
|
||||
{
|
||||
// 对于排名,越小越好
|
||||
var rankRow = matrix.FirstOrDefault(m => m["指标"].ToString() == "当前排名");
|
||||
if (rankRow != null)
|
||||
{
|
||||
var ranks = products.Select(p => p.CurrentRank).ToList();
|
||||
var minRank = ranks.Min();
|
||||
var maxRank = ranks.Max();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
var rank = product.CurrentRank;
|
||||
if (rank == minRank)
|
||||
{
|
||||
rankRow[$"{product.Name}_isBest"] = true;
|
||||
}
|
||||
else if (rank == maxRank)
|
||||
{
|
||||
rankRow[$"{product.Name}_isWorst"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 对于性能分数,越大越好
|
||||
var scoreRow = matrix.FirstOrDefault(m => m["指标"].ToString() == "性能分数");
|
||||
if (scoreRow != null)
|
||||
{
|
||||
var scores = products.Select(p => 100 - p.CurrentRank).ToList();
|
||||
var maxScore = scores.Max();
|
||||
var minScore = scores.Min();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
var score = 100 - product.CurrentRank;
|
||||
if (score == maxScore)
|
||||
{
|
||||
scoreRow[$"{product.Name}_isBest"] = true;
|
||||
}
|
||||
else if (score == minScore)
|
||||
{
|
||||
scoreRow[$"{product.Name}_isWorst"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 对于价格,越小越好
|
||||
var priceRow = matrix.FirstOrDefault(m => m["指标"].ToString() == "价格");
|
||||
if (priceRow != null)
|
||||
{
|
||||
var prices = products.Where(p => p.Price.HasValue).Select(p => p.Price!.Value).ToList();
|
||||
if (prices.Any())
|
||||
{
|
||||
var minPrice = prices.Min();
|
||||
var maxPrice = prices.Max();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
if (product.Price.HasValue)
|
||||
{
|
||||
if (product.Price == minPrice)
|
||||
{
|
||||
priceRow[$"{product.Name}_isBest"] = true;
|
||||
}
|
||||
else if (product.Price == maxPrice)
|
||||
{
|
||||
priceRow[$"{product.Name}_isWorst"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ComparisonRequest
|
||||
{
|
||||
public List<int> ProductIds { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using HardwarePerformance.API.Models;
|
||||
using HardwarePerformance.Infrastructure.Services;
|
||||
|
||||
namespace HardwarePerformance.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ProductsController : ControllerBase
|
||||
{
|
||||
private static readonly List<Product> _products = new()
|
||||
{
|
||||
new Product
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Apple A17 Pro",
|
||||
Model = "A17 Pro",
|
||||
Manufacturer = "Apple",
|
||||
CategoryId = 1,
|
||||
CurrentRank = 1,
|
||||
ReleaseDate = new DateTime(2023, 9, 12),
|
||||
Price = null
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 2,
|
||||
Name = "Snapdragon 8 Gen 3",
|
||||
Model = "SM8650-AB",
|
||||
Manufacturer = "Qualcomm",
|
||||
CategoryId = 1,
|
||||
CurrentRank = 2,
|
||||
ReleaseDate = new DateTime(2023, 10, 24),
|
||||
Price = null
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 3,
|
||||
Name = "Intel Core i9-13900K",
|
||||
Model = "Core i9-13900K",
|
||||
Manufacturer = "Intel",
|
||||
CategoryId = 3,
|
||||
CurrentRank = 1,
|
||||
ReleaseDate = new DateTime(2022, 10, 20),
|
||||
Price = 589.99m
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 4,
|
||||
Name = "AMD Ryzen 9 7950X",
|
||||
Model = "Ryzen 9 7950X",
|
||||
Manufacturer = "AMD",
|
||||
CategoryId = 3,
|
||||
CurrentRank = 2,
|
||||
ReleaseDate = new DateTime(2022, 9, 27),
|
||||
Price = 699.99m
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 5,
|
||||
Name = "NVIDIA GeForce RTX 4090",
|
||||
Model = "RTX 4090",
|
||||
Manufacturer = "NVIDIA",
|
||||
CategoryId = 4,
|
||||
CurrentRank = 1,
|
||||
ReleaseDate = new DateTime(2022, 10, 12),
|
||||
Price = 1599.99m
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Id = 6,
|
||||
Name = "AMD Radeon RX 7900 XTX",
|
||||
Model = "RX 7900 XTX",
|
||||
Manufacturer = "AMD",
|
||||
CategoryId = 4,
|
||||
CurrentRank = 2,
|
||||
ReleaseDate = new DateTime(2022, 12, 3),
|
||||
Price = 999.99m
|
||||
}
|
||||
};
|
||||
|
||||
private readonly IRedisCacheService _cacheService;
|
||||
|
||||
public ProductsController(IRedisCacheService cacheService)
|
||||
{
|
||||
_cacheService = cacheService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<PagedResponse<Product>>> GetProducts(
|
||||
[FromQuery] int? categoryId,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 10,
|
||||
[FromQuery] string sortBy = "CurrentRank",
|
||||
[FromQuery] string order = "asc")
|
||||
{
|
||||
// 创建缓存键
|
||||
var cacheKey = $"products:list:{categoryId ?? 0}:{page}:{pageSize}:{sortBy}:{order}";
|
||||
|
||||
// 尝试从缓存获取数据
|
||||
var cachedResult = await _cacheService.GetAsync<PagedResponse<Product>>(cacheKey);
|
||||
if (cachedResult != null)
|
||||
{
|
||||
return Ok(cachedResult);
|
||||
}
|
||||
|
||||
var query = _products.AsEnumerable();
|
||||
|
||||
if (categoryId.HasValue)
|
||||
{
|
||||
query = query.Where(p => p.CategoryId == categoryId.Value);
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = sortBy.ToLower() switch
|
||||
{
|
||||
"name" => order.ToLower() == "desc" ? query.OrderByDescending(p => p.Name) : query.OrderBy(p => p.Name),
|
||||
"manufacturer" => order.ToLower() == "desc" ? query.OrderByDescending(p => p.Manufacturer) : query.OrderBy(p => p.Manufacturer),
|
||||
"releasedate" => order.ToLower() == "desc" ? query.OrderByDescending(p => p.ReleaseDate) : query.OrderBy(p => p.ReleaseDate),
|
||||
"price" => order.ToLower() == "desc" ? query.OrderByDescending(p => p.Price) : query.OrderBy(p => p.Price),
|
||||
_ => order.ToLower() == "desc" ? query.OrderByDescending(p => p.CurrentRank) : query.OrderBy(p => p.CurrentRank)
|
||||
};
|
||||
|
||||
var totalCount = query.Count();
|
||||
var totalPages = (int)Math.Ceiling((double)totalCount / pageSize);
|
||||
var items = query.Skip((page - 1) * pageSize).Take(pageSize).ToList();
|
||||
|
||||
var result = new PagedResponse<Product>
|
||||
{
|
||||
Items = items,
|
||||
TotalCount = totalCount,
|
||||
PageNumber = page,
|
||||
PageSize = pageSize,
|
||||
TotalPages = totalPages
|
||||
};
|
||||
|
||||
// 将结果存入缓存,设置5分钟过期时间
|
||||
await _cacheService.SetAsync(cacheKey, result, TimeSpan.FromMinutes(5));
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ApiResponse<Product>>> GetProduct(int id)
|
||||
{
|
||||
// 创建缓存键
|
||||
var cacheKey = $"product:detail:{id}";
|
||||
|
||||
// 尝试从缓存获取数据
|
||||
var cachedResult = await _cacheService.GetAsync<ApiResponse<Product>>(cacheKey);
|
||||
if (cachedResult != null)
|
||||
{
|
||||
return Ok(cachedResult);
|
||||
}
|
||||
|
||||
var product = _products.FirstOrDefault(p => p.Id == id);
|
||||
if (product == null)
|
||||
{
|
||||
var notFoundResponse = new ApiResponse<Product>
|
||||
{
|
||||
Success = false,
|
||||
Message = "未找到指定的产品"
|
||||
};
|
||||
|
||||
// 缓存未找到的结果,设置较短过期时间
|
||||
await _cacheService.SetAsync(cacheKey, notFoundResponse, TimeSpan.FromMinutes(1));
|
||||
|
||||
return NotFound(notFoundResponse);
|
||||
}
|
||||
|
||||
var result = new ApiResponse<Product>
|
||||
{
|
||||
Data = product
|
||||
};
|
||||
|
||||
// 将结果存入缓存,设置15分钟过期时间
|
||||
await _cacheService.SetAsync(cacheKey, result, TimeSpan.FromMinutes(15));
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("search")]
|
||||
public async Task<ActionResult<PagedResponse<Product>>> SearchProducts(
|
||||
[FromQuery] string q,
|
||||
[FromQuery] int? categoryId,
|
||||
[FromQuery] string? manufacturer,
|
||||
[FromQuery] int? minScore,
|
||||
[FromQuery] int? maxScore,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 10)
|
||||
{
|
||||
// 创建缓存键
|
||||
var cacheKey = $"products:search:{q ?? ""}:{categoryId ?? 0}:{manufacturer ?? ""}:{minScore ?? 0}:{maxScore ?? 0}:{page}:{pageSize}";
|
||||
|
||||
// 尝试从缓存获取数据
|
||||
var cachedResult = await _cacheService.GetAsync<PagedResponse<Product>>(cacheKey);
|
||||
if (cachedResult != null)
|
||||
{
|
||||
return Ok(cachedResult);
|
||||
}
|
||||
|
||||
var query = _products.AsEnumerable();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(q))
|
||||
{
|
||||
query = query.Where(p =>
|
||||
p.Name.Contains(q, StringComparison.OrdinalIgnoreCase) ||
|
||||
p.Model.Contains(q, StringComparison.OrdinalIgnoreCase) ||
|
||||
p.Manufacturer.Contains(q, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
if (categoryId.HasValue)
|
||||
{
|
||||
query = query.Where(p => p.CategoryId == categoryId.Value);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(manufacturer))
|
||||
{
|
||||
query = query.Where(p =>
|
||||
p.Manufacturer.Equals(manufacturer, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
// 注意:这里我们使用CurrentRank作为性能分数的替代,因为实际产品中没有性能分数字段
|
||||
if (minScore.HasValue)
|
||||
{
|
||||
query = query.Where(p => (100 - p.CurrentRank) >= minScore.Value);
|
||||
}
|
||||
|
||||
if (maxScore.HasValue)
|
||||
{
|
||||
query = query.Where(p => (100 - p.CurrentRank) <= maxScore.Value);
|
||||
}
|
||||
|
||||
var totalCount = query.Count();
|
||||
var totalPages = (int)Math.Ceiling((double)totalCount / pageSize);
|
||||
var items = query.Skip((page - 1) * pageSize).Take(pageSize).ToList();
|
||||
|
||||
var result = new PagedResponse<Product>
|
||||
{
|
||||
Items = items,
|
||||
TotalCount = totalCount,
|
||||
PageNumber = page,
|
||||
PageSize = pageSize,
|
||||
TotalPages = totalPages
|
||||
};
|
||||
|
||||
// 将结果存入缓存,设置3分钟过期时间(搜索结果变化较快)
|
||||
await _cacheService.SetAsync(cacheKey, result, TimeSpan.FromMinutes(3));
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace HardwarePerformance.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class SimpleTestController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<SimpleTestController> _logger;
|
||||
|
||||
public SimpleTestController(ILogger<SimpleTestController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet("status")]
|
||||
public IActionResult GetStatus()
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
Status = "Running",
|
||||
Message = "API服务正常运行",
|
||||
Timestamp = DateTime.Now,
|
||||
Version = "1.0.0"
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("test-data")]
|
||||
public IActionResult GetTestData()
|
||||
{
|
||||
var categories = new[]
|
||||
{
|
||||
new { Id = 1, Name = "手机CPU", Description = "移动设备处理器" },
|
||||
new { Id = 2, Name = "手机GPU", Description = "移动设备图形处理器" },
|
||||
new { Id = 3, Name = "电脑CPU", Description = "桌面和笔记本处理器" },
|
||||
new { Id = 4, Name = "电脑GPU", Description = "桌面和笔记本图形处理器" }
|
||||
};
|
||||
|
||||
var products = new[]
|
||||
{
|
||||
new { Id = 1, Name = "Apple A17 Pro", Model = "A17 Pro", Manufacturer = "Apple", CategoryId = 1, CurrentRank = 1 },
|
||||
new { Id = 2, Name = "Snapdragon 8 Gen 3", Model = "SM8650-AB", Manufacturer = "Qualcomm", CategoryId = 1, CurrentRank = 2 },
|
||||
new { Id = 3, Name = "Intel Core i9-13900K", Model = "Core i9-13900K", Manufacturer = "Intel", CategoryId = 3, CurrentRank = 1 },
|
||||
new { Id = 4, Name = "AMD Ryzen 9 7950X", Model = "Ryzen 9 7950X", Manufacturer = "AMD", CategoryId = 3, CurrentRank = 2 },
|
||||
new { Id = 5, Name = "NVIDIA GeForce RTX 4090", Model = "RTX 4090", Manufacturer = "NVIDIA", CategoryId = 4, CurrentRank = 1 },
|
||||
new { Id = 6, Name = "AMD Radeon RX 7900 XTX", Model = "RX 7900 XTX", Manufacturer = "AMD", CategoryId = 4, CurrentRank = 2 }
|
||||
};
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
Categories = categories,
|
||||
Products = products,
|
||||
TotalCategories = categories.Length,
|
||||
TotalProducts = products.Length
|
||||
});
|
||||
}
|
||||
}
|
||||
154
backend/HardwarePerformance.API/Controllers/TestController.cs
Normal file
154
backend/HardwarePerformance.API/Controllers/TestController.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using HardwarePerformance.Infrastructure.Data;
|
||||
|
||||
namespace HardwarePerformance.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class TestController : ControllerBase
|
||||
{
|
||||
private readonly SimpleAppDbContext _context;
|
||||
private readonly ILogger<TestController> _logger;
|
||||
|
||||
public TestController(SimpleAppDbContext context, ILogger<TestController> logger)
|
||||
{
|
||||
_context = context;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet("database-status")]
|
||||
public async Task<IActionResult> GetDatabaseStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
var isConnected = await _context.TestConnectionAsync();
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
IsConnected = isConnected,
|
||||
Message = isConnected ? "数据库连接成功" : "数据库连接失败",
|
||||
Timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "检查数据库连接时发生错误");
|
||||
return StatusCode(500, new
|
||||
{
|
||||
IsConnected = false,
|
||||
Message = $"检查数据库连接时发生错误: {ex.Message}",
|
||||
Timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("initialize-database")]
|
||||
public async Task<IActionResult> InitializeDatabase()
|
||||
{
|
||||
try
|
||||
{
|
||||
await _context.InitializeDatabaseAsync();
|
||||
await _context.SeedInitialDataAsync();
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
Message = "数据库初始化成功,种子数据已添加",
|
||||
Timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "初始化数据库时发生错误");
|
||||
return StatusCode(500, new
|
||||
{
|
||||
Message = $"初始化数据库时发生错误: {ex.Message}",
|
||||
Timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("categories")]
|
||||
public async Task<IActionResult> GetCategories()
|
||||
{
|
||||
try
|
||||
{
|
||||
var categories = new List<object>();
|
||||
|
||||
using var connection = new MySql.Data.MySqlClient.MySqlConnection(
|
||||
"Server=localhost;Database=HardwarePerformance;User=root;Password=123456;");
|
||||
await connection.OpenAsync();
|
||||
|
||||
using var cmd = new MySql.Data.MySqlClient.MySqlCommand("SELECT * FROM Categories", connection);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
categories.Add(new
|
||||
{
|
||||
Id = reader.GetInt32("Id"),
|
||||
Name = reader.GetString("Name"),
|
||||
Description = reader.IsDBNull("Description") ? null : reader.GetString("Description"),
|
||||
CreatedAt = reader.GetDateTime("CreatedAt")
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(categories);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取类别列表时发生错误");
|
||||
return StatusCode(500, new
|
||||
{
|
||||
Message = $"获取类别列表时发生错误: {ex.Message}",
|
||||
Timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("products")]
|
||||
public async Task<IActionResult> GetProducts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var products = new List<object>();
|
||||
|
||||
using var connection = new MySql.Data.MySqlClient.MySqlConnection(
|
||||
"Server=localhost;Database=HardwarePerformance;User=root;Password=123456;");
|
||||
await connection.OpenAsync();
|
||||
|
||||
using var cmd = new MySql.Data.MySqlClient.MySqlCommand(
|
||||
@"SELECT p.*, c.Name as CategoryName
|
||||
FROM Products p
|
||||
LEFT JOIN Categories c ON p.CategoryId = c.Id", connection);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
products.Add(new
|
||||
{
|
||||
Id = reader.GetInt32("Id"),
|
||||
Name = reader.GetString("Name"),
|
||||
Model = reader.IsDBNull("Model") ? null : reader.GetString("Model"),
|
||||
Manufacturer = reader.IsDBNull("Manufacturer") ? null : reader.GetString("Manufacturer"),
|
||||
ImageUrl = reader.IsDBNull("ImageUrl") ? null : reader.GetString("ImageUrl"),
|
||||
ReleaseDate = reader.IsDBNull("ReleaseDate") ? (DateTime?)null : reader.GetDateTime("ReleaseDate"),
|
||||
CategoryId = reader.IsDBNull("CategoryId") ? (int?)null : reader.GetInt32("CategoryId"),
|
||||
CategoryName = reader.IsDBNull("CategoryName") ? null : reader.GetString("CategoryName"),
|
||||
CurrentRank = reader.IsDBNull("CurrentRank") ? (int?)null : reader.GetInt32("CurrentRank"),
|
||||
CreatedAt = reader.GetDateTime("CreatedAt")
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(products);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取产品列表时发生错误");
|
||||
return StatusCode(500, new
|
||||
{
|
||||
Message = $"获取产品列表时发生错误: {ex.Message}",
|
||||
Timestamp = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HardwarePerformance.Application\HardwarePerformance.Application.csproj" />
|
||||
<ProjectReference Include="..\HardwarePerformance.Infrastructure\HardwarePerformance.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>https</ActiveDebugProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
@HardwarePerformance.API_HostAddress = http://localhost:5277
|
||||
|
||||
GET {{HardwarePerformance.API_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
53
backend/HardwarePerformance.API/Models/ApiModels.cs
Normal file
53
backend/HardwarePerformance.API/Models/ApiModels.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace HardwarePerformance.API.Models
|
||||
{
|
||||
public class Category
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class Product
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Model { get; set; } = string.Empty;
|
||||
public string Manufacturer { get; set; } = string.Empty;
|
||||
public int CategoryId { get; set; }
|
||||
public int CurrentRank { get; set; }
|
||||
public DateTime ReleaseDate { get; set; }
|
||||
public decimal? Price { get; set; }
|
||||
}
|
||||
|
||||
public class ApiResponse<T>
|
||||
{
|
||||
[JsonPropertyName("success")]
|
||||
public bool Success { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("data")]
|
||||
public T? Data { get; set; }
|
||||
|
||||
[JsonPropertyName("message")]
|
||||
public string? Message { get; set; }
|
||||
}
|
||||
|
||||
public class PagedResponse<T>
|
||||
{
|
||||
[JsonPropertyName("items")]
|
||||
public List<T> Items { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("totalCount")]
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
[JsonPropertyName("pageNumber")]
|
||||
public int PageNumber { get; set; }
|
||||
|
||||
[JsonPropertyName("pageSize")]
|
||||
public int PageSize { get; set; }
|
||||
|
||||
[JsonPropertyName("totalPages")]
|
||||
public int TotalPages { get; set; }
|
||||
}
|
||||
}
|
||||
87
backend/HardwarePerformance.API/Program.cs
Normal file
87
backend/HardwarePerformance.API/Program.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System.IO.Compression;
|
||||
using HardwarePerformance.Infrastructure.Services;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
// 添加响应压缩服务
|
||||
builder.Services.AddResponseCompression(options =>
|
||||
{
|
||||
options.EnableForHttps = true;
|
||||
options.Providers.Add<BrotliCompressionProvider>();
|
||||
options.Providers.Add<GzipCompressionProvider>();
|
||||
options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
|
||||
{
|
||||
"application/javascript",
|
||||
"application/json",
|
||||
"text/css",
|
||||
"text/html",
|
||||
"text/plain",
|
||||
"text/xml"
|
||||
});
|
||||
});
|
||||
|
||||
// 配置压缩级别
|
||||
builder.Services.Configure<BrotliCompressionProviderOptions>(options =>
|
||||
{
|
||||
options.Level = CompressionLevel.Fastest;
|
||||
});
|
||||
|
||||
builder.Services.Configure<GzipCompressionProviderOptions>(options =>
|
||||
{
|
||||
options.Level = CompressionLevel.Fastest;
|
||||
});
|
||||
|
||||
// 配置Redis缓存
|
||||
builder.Services.AddStackExchangeRedisCache(options =>
|
||||
{
|
||||
options.Configuration = builder.Configuration.GetConnectionString("Redis") ?? "localhost:6379";
|
||||
options.InstanceName = "HardwarePerformance:";
|
||||
});
|
||||
|
||||
// 注册Redis缓存服务
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(provider =>
|
||||
{
|
||||
var configuration = provider.GetRequiredService<IConfiguration>();
|
||||
var connectionString = configuration.GetConnectionString("Redis") ?? "localhost:6379";
|
||||
return ConnectionMultiplexer.Connect(connectionString);
|
||||
});
|
||||
|
||||
builder.Services.AddScoped<IRedisCacheService, RedisCacheService>();
|
||||
|
||||
// 配置CORS
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll", policy =>
|
||||
{
|
||||
policy.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
// 添加响应压缩中间件
|
||||
app.UseResponseCompression();
|
||||
|
||||
app.UseCors("AllowAll");
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5277",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7259;http://localhost:5277",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
backend/HardwarePerformance.API/appsettings.json
Normal file
13
backend/HardwarePerformance.API/appsettings.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=localhost;Database=HardwarePerformance;User=root;Password=123456;",
|
||||
"Redis": "localhost:6379"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
|
||||
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("HardwarePerformance.API")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("HardwarePerformance.API")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("HardwarePerformance.API")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// 由 MSBuild WriteCodeFragment 类生成。
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
c864e8af1f73ac3c0cfb752888ca009da1d159a83d0f6648240e670a9d6a467e
|
||||
@@ -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 = HardwarePerformance.API
|
||||
build_property.RootNamespace = HardwarePerformance.API
|
||||
build_property.ProjectDir = C:\work\电脑硬件-01\backend\HardwarePerformance.API\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.RazorLangVersion = 9.0
|
||||
build_property.SupportLocalizedComponentNames =
|
||||
build_property.GenerateRazorMetadataSourceChecksumAttributes =
|
||||
build_property.MSBuildProjectDirectory = C:\work\电脑硬件-01\backend\HardwarePerformance.API
|
||||
build_property._RazorSourceGeneratorDebug =
|
||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
@@ -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.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
e5921e7a1919c86641a4559f89f9c7d56174547a0006dc67be9c5fd271f1bbad
|
||||
@@ -0,0 +1,7 @@
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.API\obj\Debug\net9.0\HardwarePerformance.API.csproj.AssemblyReference.cache
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.API\obj\Debug\net9.0\rpswa.dswa.cache.json
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.API\obj\Debug\net9.0\HardwarePerformance.API.GeneratedMSBuildEditorConfig.editorconfig
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.API\obj\Debug\net9.0\HardwarePerformance.API.AssemblyInfoInputs.cache
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.API\obj\Debug\net9.0\HardwarePerformance.API.AssemblyInfo.cs
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.API\obj\Debug\net9.0\HardwarePerformance.API.csproj.CoreCompileInputs.cache
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.API\obj\Debug\net9.0\HardwarePerformance.API.MvcApplicationPartsAssemblyInfo.cache
|
||||
@@ -0,0 +1 @@
|
||||
{"GlobalPropertiesHash":"iWexcF6oOYdga2d9awG8b+J7CuzlMv2HGwFcrf0LVc0=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["BX3rnoxloELJyRpTcP/qR1aocjFsd8x57atK9sOV7lw=","P2fT07pEO/tA2nDzvyPju\u002BR2V67D1LAa\u002Bk2qYNEReD4="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
@@ -0,0 +1,342 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"projectName": "HardwarePerformance.API",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"projectReferences": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj": {
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj"
|
||||
},
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Infrastructure\\HardwarePerformance.Infrastructure.csproj": {
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Infrastructure\\HardwarePerformance.Infrastructure.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
},
|
||||
"restoreAuditProperties": {
|
||||
"enableAudit": "true",
|
||||
"auditLevel": "low",
|
||||
"auditMode": "direct"
|
||||
},
|
||||
"SdkAnalysisLevel": "9.0.300"
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNetCore.OpenApi": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"Microsoft.AspNetCore.ResponseCompression": {
|
||||
"target": "Package",
|
||||
"version": "[2.2.0, )"
|
||||
},
|
||||
"Microsoft.EntityFrameworkCore.Design": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"StackExchange.Redis": {
|
||||
"target": "Package",
|
||||
"version": "[2.7.10, )"
|
||||
},
|
||||
"Swashbuckle.AspNetCore": {
|
||||
"target": "Package",
|
||||
"version": "[6.6.2, )"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj",
|
||||
"projectName": "HardwarePerformance.Application",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"projectReferences": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj": {
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"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.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"projectName": "HardwarePerformance.Core",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"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.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Infrastructure\\HardwarePerformance.Infrastructure.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Infrastructure\\HardwarePerformance.Infrastructure.csproj",
|
||||
"projectName": "HardwarePerformance.Infrastructure",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Infrastructure\\HardwarePerformance.Infrastructure.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Infrastructure\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"projectReferences": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj": {
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
},
|
||||
"restoreAuditProperties": {
|
||||
"enableAudit": "true",
|
||||
"auditLevel": "low",
|
||||
"auditMode": "direct"
|
||||
},
|
||||
"SdkAnalysisLevel": "9.0.300"
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"dependencies": {
|
||||
"Microsoft.EntityFrameworkCore": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"Microsoft.EntityFrameworkCore.Design": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"Microsoft.EntityFrameworkCore.Tools": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"MySql.Data": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"Pomelo.EntityFrameworkCore.MySql": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
}
|
||||
},
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48",
|
||||
"net481"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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" />
|
||||
132
backend/HardwarePerformance.API/obj/project.assets.json
Normal file
132
backend/HardwarePerformance.API/obj/project.assets.json
Normal file
@@ -0,0 +1,132 @@
|
||||
{
|
||||
"version": 3,
|
||||
"targets": {
|
||||
"net9.0": {}
|
||||
},
|
||||
"libraries": {},
|
||||
"projectFileDependencyGroups": {
|
||||
"net9.0": [
|
||||
"Microsoft.AspNetCore.OpenApi >= 9.0.0",
|
||||
"Microsoft.AspNetCore.ResponseCompression >= 2.2.0",
|
||||
"Microsoft.EntityFrameworkCore.Design >= 9.0.0",
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis >= 9.0.0",
|
||||
"StackExchange.Redis >= 2.7.10",
|
||||
"Swashbuckle.AspNetCore >= 6.6.2"
|
||||
]
|
||||
},
|
||||
"packageFolders": {
|
||||
"C:\\Users\\代\\.nuget\\packages\\": {},
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"projectName": "HardwarePerformance.API",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"projectReferences": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj": {
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj"
|
||||
},
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Infrastructure\\HardwarePerformance.Infrastructure.csproj": {
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Infrastructure\\HardwarePerformance.Infrastructure.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
},
|
||||
"restoreAuditProperties": {
|
||||
"enableAudit": "true",
|
||||
"auditLevel": "low",
|
||||
"auditMode": "direct"
|
||||
},
|
||||
"SdkAnalysisLevel": "9.0.300"
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNetCore.OpenApi": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"Microsoft.AspNetCore.ResponseCompression": {
|
||||
"target": "Package",
|
||||
"version": "[2.2.0, )"
|
||||
},
|
||||
"Microsoft.EntityFrameworkCore.Design": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis": {
|
||||
"target": "Package",
|
||||
"version": "[9.0.0, )"
|
||||
},
|
||||
"StackExchange.Redis": {
|
||||
"target": "Package",
|
||||
"version": "[2.7.10, )"
|
||||
},
|
||||
"Swashbuckle.AspNetCore": {
|
||||
"target": "Package",
|
||||
"version": "[6.6.2, )"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
"logs": [
|
||||
{
|
||||
"code": "NU1301",
|
||||
"level": "Error",
|
||||
"message": "无法加载源 https://nuget.cdn.azure.cn/v3/index.json 的服务索引。\r\n 不知道这样的主机。 (null:80)\r\n 不知道这样的主机。",
|
||||
"libraryId": "Microsoft.EntityFrameworkCore.Design"
|
||||
}
|
||||
]
|
||||
}
|
||||
18
backend/HardwarePerformance.API/obj/project.nuget.cache
Normal file
18
backend/HardwarePerformance.API/obj/project.nuget.cache
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "rxPvbZQQnrI=",
|
||||
"success": false,
|
||||
"projectFilePath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"logs": [
|
||||
{
|
||||
"code": "NU1301",
|
||||
"level": "Error",
|
||||
"message": "无法加载源 https://nuget.cdn.azure.cn/v3/index.json 的服务索引。\r\n 不知道这样的主机。 (null:80)\r\n 不知道这样的主机。",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"filePath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.API\\HardwarePerformance.API.csproj",
|
||||
"libraryId": "Microsoft.EntityFrameworkCore.Design",
|
||||
"targetGraphs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
6
backend/HardwarePerformance.Application/Class1.cs
Normal file
6
backend/HardwarePerformance.Application/Class1.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace HardwarePerformance.Application;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HardwarePerformance.Core\HardwarePerformance.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v9.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v9.0": {
|
||||
"HardwarePerformance.Application/1.0.0": {
|
||||
"dependencies": {
|
||||
"HardwarePerformance.Core": "1.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"HardwarePerformance.Application.dll": {}
|
||||
}
|
||||
},
|
||||
"HardwarePerformance.Core/1.0.0": {
|
||||
"runtime": {
|
||||
"HardwarePerformance.Core.dll": {
|
||||
"assemblyVersion": "1.0.0.0",
|
||||
"fileVersion": "1.0.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"HardwarePerformance.Application/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"HardwarePerformance.Core/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
|
||||
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("HardwarePerformance.Application")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("HardwarePerformance.Application")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("HardwarePerformance.Application")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// 由 MSBuild WriteCodeFragment 类生成。
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
47ace040dd573a6e7d73bc27be6f43fbae68038e279bb072bfa7078bb1c58834
|
||||
@@ -0,0 +1,15 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net9.0
|
||||
build_property.TargetPlatformMinVersion =
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = HardwarePerformance.Application
|
||||
build_property.ProjectDir = c:\work\电脑硬件-01\backend\HardwarePerformance.Application\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
@@ -0,0 +1,8 @@
|
||||
// <auto-generated/>
|
||||
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.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
aeab2ef3e033460ff4326980bc90f1b0dc64d280b740f7a22c976cbecf4593d4
|
||||
@@ -0,0 +1,15 @@
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\bin\Debug\net9.0\HardwarePerformance.Application.deps.json
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\bin\Debug\net9.0\HardwarePerformance.Application.dll
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\bin\Debug\net9.0\HardwarePerformance.Application.pdb
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\bin\Debug\net9.0\HardwarePerformance.Core.dll
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\bin\Debug\net9.0\HardwarePerformance.Core.pdb
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\HardwarePerformance.Application.csproj.AssemblyReference.cache
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\HardwarePerformance.Application.GeneratedMSBuildEditorConfig.editorconfig
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\HardwarePerformance.Application.AssemblyInfoInputs.cache
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\HardwarePerformance.Application.AssemblyInfo.cs
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\HardwarePerformance.Application.csproj.CoreCompileInputs.cache
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\Hardware.84873EFD.Up2Date
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\HardwarePerformance.Application.dll
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\refint\HardwarePerformance.Application.dll
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\HardwarePerformance.Application.pdb
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Application\obj\Debug\net9.0\ref\HardwarePerformance.Application.dll
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,146 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj",
|
||||
"projectName": "HardwarePerformance.Application",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"projectReferences": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj": {
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"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.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"projectName": "HardwarePerformance.Core",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"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.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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" />
|
||||
104
backend/HardwarePerformance.Application/obj/project.assets.json
Normal file
104
backend/HardwarePerformance.Application/obj/project.assets.json
Normal file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"version": 3,
|
||||
"targets": {
|
||||
"net9.0": {
|
||||
"HardwarePerformance.Core/1.0.0": {
|
||||
"type": "project",
|
||||
"framework": ".NETCoreApp,Version=v9.0",
|
||||
"compile": {
|
||||
"bin/placeholder/HardwarePerformance.Core.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/placeholder/HardwarePerformance.Core.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"HardwarePerformance.Core/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../HardwarePerformance.Core/HardwarePerformance.Core.csproj",
|
||||
"msbuildProject": "../HardwarePerformance.Core/HardwarePerformance.Core.csproj"
|
||||
}
|
||||
},
|
||||
"projectFileDependencyGroups": {
|
||||
"net9.0": [
|
||||
"HardwarePerformance.Core >= 1.0.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\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj",
|
||||
"projectName": "HardwarePerformance.Application",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"projectReferences": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj": {
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"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.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "vK7SRP5Q/lo=",
|
||||
"success": true,
|
||||
"projectFilePath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Application\\HardwarePerformance.Application.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"logs": []
|
||||
}
|
||||
6
backend/HardwarePerformance.Core/Class1.cs
Normal file
6
backend/HardwarePerformance.Core/Class1.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace HardwarePerformance.Core;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
52
backend/HardwarePerformance.Core/Entities/Category.cs
Normal file
52
backend/HardwarePerformance.Core/Entities/Category.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace HardwarePerformance.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品类别实体
|
||||
/// </summary>
|
||||
public class Category : Infrastructure.Data.BaseEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[MaxLength(500)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类别图标URL
|
||||
/// </summary>
|
||||
[MaxLength(500)]
|
||||
public string? IconUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序顺序
|
||||
/// </summary>
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// 导航属性
|
||||
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
|
||||
|
||||
[NotMapped]
|
||||
public int ProductCount => Products?.Count ?? 0;
|
||||
}
|
||||
}
|
||||
56
backend/HardwarePerformance.Core/Entities/DataSource.cs
Normal file
56
backend/HardwarePerformance.Core/Entities/DataSource.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace HardwarePerformance.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据源实体
|
||||
/// </summary>
|
||||
public class DataSource : Infrastructure.Data.BaseEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[MaxLength(500)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据源URL
|
||||
/// </summary>
|
||||
[MaxLength(500)]
|
||||
public string? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据源类型(如:GeekBench、3DMark、AnTuTu等)
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public string Type { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 最后同步时间
|
||||
/// </summary>
|
||||
public DateTime? LastSyncAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// 导航属性
|
||||
public virtual ICollection<PerformanceScore> PerformanceScores { get; set; } = new List<PerformanceScore>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace HardwarePerformance.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 性能分数实体
|
||||
/// </summary>
|
||||
public class PerformanceScore : Infrastructure.Data.BaseEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 测试项目名称(如:CPU单核、CPU多核、GPU等)
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string TestName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 测试分数
|
||||
/// </summary>
|
||||
public int Score { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 测试单位
|
||||
/// </summary>
|
||||
[MaxLength(20)]
|
||||
public string? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 测试版本
|
||||
/// </summary>
|
||||
[MaxLength(50)]
|
||||
public string? TestVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 测试日期
|
||||
/// </summary>
|
||||
public DateTime TestDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// 外键
|
||||
public int ProductId { get; set; }
|
||||
public int DataSourceId { get; set; }
|
||||
|
||||
// 导航属性
|
||||
[ForeignKey("ProductId")]
|
||||
public virtual Product Product { get; set; } = null!;
|
||||
|
||||
[ForeignKey("DataSourceId")]
|
||||
public virtual DataSource DataSource { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
85
backend/HardwarePerformance.Core/Entities/Product.cs
Normal file
85
backend/HardwarePerformance.Core/Entities/Product.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace HardwarePerformance.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品实体
|
||||
/// </summary>
|
||||
public class Product : Infrastructure.Data.BaseEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(200)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(200)]
|
||||
public string Model { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string Manufacturer { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 产品图片URL
|
||||
/// </summary>
|
||||
[MaxLength(500)]
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品描述
|
||||
/// </summary>
|
||||
[MaxLength(2000)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发布年份
|
||||
/// </summary>
|
||||
public int ReleaseYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发布日期
|
||||
/// </summary>
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 综合性能分数
|
||||
/// </summary>
|
||||
public int PerformanceScore { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前排名
|
||||
/// </summary>
|
||||
public int? CurrentRank { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// 外键
|
||||
public int CategoryId { get; set; }
|
||||
|
||||
// 导航属性
|
||||
[ForeignKey("CategoryId")]
|
||||
public virtual Category Category { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<PerformanceScore> PerformanceScores { get; set; } = new List<PerformanceScore>();
|
||||
|
||||
public virtual ICollection<Specification> Specifications { get; set; } = new List<Specification>();
|
||||
|
||||
public virtual ICollection<RankingHistory> RankingHistories { get; set; } = new List<RankingHistory>();
|
||||
}
|
||||
}
|
||||
40
backend/HardwarePerformance.Core/Entities/RankingHistory.cs
Normal file
40
backend/HardwarePerformance.Core/Entities/RankingHistory.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace HardwarePerformance.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 排名历史实体
|
||||
/// </summary>
|
||||
public class RankingHistory : Infrastructure.Data.BaseEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排名
|
||||
/// </summary>
|
||||
public int Rank { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 性能分数
|
||||
/// </summary>
|
||||
public int Score { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 记录日期
|
||||
/// </summary>
|
||||
public DateTime RecordDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// 外键
|
||||
public int ProductId { get; set; }
|
||||
|
||||
// 导航属性
|
||||
[ForeignKey("ProductId")]
|
||||
public virtual Product Product { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
67
backend/HardwarePerformance.Core/Entities/Specification.cs
Normal file
67
backend/HardwarePerformance.Core/Entities/Specification.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace HardwarePerformance.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品规格参数实体
|
||||
/// </summary>
|
||||
public class Specification : Infrastructure.Data.BaseEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格组名称(如:处理器规格、图形规格等)
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string GroupName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 规格名称
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 规格值
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(500)]
|
||||
public string Value { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 规格单位
|
||||
/// </summary>
|
||||
[MaxLength(20)]
|
||||
public string? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为关键规格(用于对比时高亮显示)
|
||||
/// </summary>
|
||||
public bool IsKeySpecification { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 排序顺序
|
||||
/// </summary>
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// 外键
|
||||
public int ProductId { get; set; }
|
||||
|
||||
// 导航属性
|
||||
[ForeignKey("ProductId")]
|
||||
public virtual Product Product { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v9.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v9.0": {
|
||||
"HardwarePerformance.Core/1.0.0": {
|
||||
"runtime": {
|
||||
"HardwarePerformance.Core.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"HardwarePerformance.Core/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
|
||||
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("HardwarePerformance.Core")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("HardwarePerformance.Core")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("HardwarePerformance.Core")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// 由 MSBuild WriteCodeFragment 类生成。
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
47fb7408a33db12e565d87964c656fd47a21dcfbee73d3b0be85e656da215d8e
|
||||
@@ -0,0 +1,15 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net9.0
|
||||
build_property.TargetPlatformMinVersion =
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = HardwarePerformance.Core
|
||||
build_property.ProjectDir = c:\work\电脑硬件-01\backend\HardwarePerformance.Core\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
@@ -0,0 +1,8 @@
|
||||
// <auto-generated/>
|
||||
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.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
aea687805272a99f2d3351b970987a76ce0be622ef66272aa203a6cebba2e9bb
|
||||
@@ -0,0 +1,11 @@
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\bin\Debug\net9.0\HardwarePerformance.Core.deps.json
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\bin\Debug\net9.0\HardwarePerformance.Core.dll
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\bin\Debug\net9.0\HardwarePerformance.Core.pdb
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\obj\Debug\net9.0\HardwarePerformance.Core.GeneratedMSBuildEditorConfig.editorconfig
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\obj\Debug\net9.0\HardwarePerformance.Core.AssemblyInfoInputs.cache
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\obj\Debug\net9.0\HardwarePerformance.Core.AssemblyInfo.cs
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\obj\Debug\net9.0\HardwarePerformance.Core.csproj.CoreCompileInputs.cache
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\obj\Debug\net9.0\HardwarePerformance.Core.dll
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\obj\Debug\net9.0\refint\HardwarePerformance.Core.dll
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\obj\Debug\net9.0\HardwarePerformance.Core.pdb
|
||||
C:\work\电脑硬件-01\backend\HardwarePerformance.Core\obj\Debug\net9.0\ref\HardwarePerformance.Core.dll
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"projectName": "HardwarePerformance.Core",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"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.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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" />
|
||||
81
backend/HardwarePerformance.Core/obj/project.assets.json
Normal file
81
backend/HardwarePerformance.Core/obj/project.assets.json
Normal file
@@ -0,0 +1,81 @@
|
||||
{
|
||||
"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\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"projectName": "HardwarePerformance.Core",
|
||||
"projectPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"packagesPath": "C:\\Users\\代\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\work\\电脑硬件-01\\backend\\NuGet.Config",
|
||||
"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": {
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://nuget.cdn.azure.cn/v3/index.json": {},
|
||||
"https://packages.microsoft.com/index.json": {}
|
||||
},
|
||||
"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.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
backend/HardwarePerformance.Core/obj/project.nuget.cache
Normal file
8
backend/HardwarePerformance.Core/obj/project.nuget.cache
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "IaGf00VQysw=",
|
||||
"success": true,
|
||||
"projectFilePath": "C:\\work\\电脑硬件-01\\backend\\HardwarePerformance.Core\\HardwarePerformance.Core.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"logs": []
|
||||
}
|
||||
6
backend/HardwarePerformance.Infrastructure/Class1.cs
Normal file
6
backend/HardwarePerformance.Infrastructure/Class1.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace HardwarePerformance.Infrastructure;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
259
backend/HardwarePerformance.Infrastructure/Data/AppDbContext.cs
Normal file
259
backend/HardwarePerformance.Infrastructure/Data/AppDbContext.cs
Normal file
@@ -0,0 +1,259 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using HardwarePerformance.Core.Entities;
|
||||
|
||||
namespace HardwarePerformance.Infrastructure.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础实体类
|
||||
/// </summary>
|
||||
public abstract class BaseEntity
|
||||
{
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用程序数据库上下文
|
||||
/// </summary>
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
// DbSets
|
||||
public DbSet<Category> Categories { get; set; }
|
||||
public DbSet<Product> Products { get; set; }
|
||||
public DbSet<PerformanceScore> PerformanceScores { get; set; }
|
||||
public DbSet<Specification> Specifications { get; set; }
|
||||
public DbSet<DataSource> DataSources { get; set; }
|
||||
public DbSet<RankingHistory> RankingHistories { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
// 配置Category实体
|
||||
modelBuilder.Entity<Category>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
|
||||
entity.Property(e => e.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.Description)
|
||||
.HasMaxLength(500);
|
||||
|
||||
entity.Property(e => e.IconUrl)
|
||||
.HasMaxLength(500);
|
||||
|
||||
entity.Property(e => e.CreatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
entity.Property(e => e.UpdatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
entity.HasIndex(e => e.Name).IsUnique();
|
||||
entity.HasIndex(e => e.SortOrder);
|
||||
});
|
||||
|
||||
// 配置Product实体
|
||||
modelBuilder.Entity<Product>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
|
||||
entity.Property(e => e.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
entity.Property(e => e.Model)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
entity.Property(e => e.Manufacturer)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.ImageUrl)
|
||||
.HasMaxLength(500);
|
||||
|
||||
entity.Property(e => e.Description)
|
||||
.HasMaxLength(2000);
|
||||
|
||||
entity.Property(e => e.CreatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
entity.Property(e => e.UpdatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
// 配置外键关系
|
||||
entity.HasOne(e => e.Category)
|
||||
.WithMany(c => c.Products)
|
||||
.HasForeignKey(e => e.CategoryId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// 配置索引
|
||||
entity.HasIndex(e => e.Name);
|
||||
entity.HasIndex(e => e.Model);
|
||||
entity.HasIndex(e => e.CategoryId);
|
||||
entity.HasIndex(e => e.PerformanceScore);
|
||||
entity.HasIndex(e => e.CurrentRank);
|
||||
entity.HasIndex(e => e.Manufacturer);
|
||||
entity.HasIndex(e => e.ReleaseYear);
|
||||
entity.HasIndex(e => new { e.CategoryId, e.CurrentRank });
|
||||
});
|
||||
|
||||
// 配置PerformanceScore实体
|
||||
modelBuilder.Entity<PerformanceScore>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
|
||||
entity.Property(e => e.TestName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.Unit)
|
||||
.HasMaxLength(20);
|
||||
|
||||
entity.Property(e => e.TestVersion)
|
||||
.HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.CreatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
// 配置外键关系
|
||||
entity.HasOne(e => e.Product)
|
||||
.WithMany(p => p.PerformanceScores)
|
||||
.HasForeignKey(e => e.ProductId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasOne(e => e.DataSource)
|
||||
.WithMany(d => d.PerformanceScores)
|
||||
.HasForeignKey(e => e.DataSourceId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
// 配置索引
|
||||
entity.HasIndex(e => new { e.ProductId, e.TestName });
|
||||
entity.HasIndex(e => e.Score);
|
||||
entity.HasIndex(e => e.TestDate);
|
||||
});
|
||||
|
||||
// 配置Specification实体
|
||||
modelBuilder.Entity<Specification>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
|
||||
entity.Property(e => e.GroupName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.Value)
|
||||
.IsRequired()
|
||||
.HasMaxLength(500);
|
||||
|
||||
entity.Property(e => e.Unit)
|
||||
.HasMaxLength(20);
|
||||
|
||||
entity.Property(e => e.CreatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
entity.Property(e => e.UpdatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
// 配置外键关系
|
||||
entity.HasOne(e => e.Product)
|
||||
.WithMany(p => p.Specifications)
|
||||
.HasForeignKey(e => e.ProductId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// 配置索引
|
||||
entity.HasIndex(e => new { e.ProductId, e.GroupName });
|
||||
entity.HasIndex(e => new { e.ProductId, e.Name });
|
||||
entity.HasIndex(e => e.IsKeySpecification);
|
||||
});
|
||||
|
||||
// 配置DataSource实体
|
||||
modelBuilder.Entity<DataSource>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
|
||||
entity.Property(e => e.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
entity.Property(e => e.Description)
|
||||
.HasMaxLength(500);
|
||||
|
||||
entity.Property(e => e.Url)
|
||||
.HasMaxLength(500);
|
||||
|
||||
entity.Property(e => e.Type)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.CreatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
entity.Property(e => e.UpdatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
// 配置索引
|
||||
entity.HasIndex(e => e.Name).IsUnique();
|
||||
entity.HasIndex(e => e.Type);
|
||||
});
|
||||
|
||||
// 配置RankingHistory实体
|
||||
modelBuilder.Entity<RankingHistory>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
|
||||
entity.Property(e => e.CreatedAt)
|
||||
.HasDefaultValueSql("UTC_TIMESTAMP()");
|
||||
|
||||
// 配置外键关系
|
||||
entity.HasOne(e => e.Product)
|
||||
.WithMany(p => p.RankingHistories)
|
||||
.HasForeignKey(e => e.ProductId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// 配置索引
|
||||
entity.HasIndex(e => new { e.ProductId, e.RecordDate });
|
||||
entity.HasIndex(e => e.Rank);
|
||||
entity.HasIndex(e => e.RecordDate);
|
||||
});
|
||||
}
|
||||
|
||||
public override int SaveChanges()
|
||||
{
|
||||
UpdateTimestamps();
|
||||
return base.SaveChanges();
|
||||
}
|
||||
|
||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
UpdateTimestamps();
|
||||
return base.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
private void UpdateTimestamps()
|
||||
{
|
||||
var entries = ChangeTracker.Entries()
|
||||
.Where(e => e.Entity is BaseEntity && (e.State == EntityState.Added || e.State == EntityState.Modified));
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (entry.State == EntityState.Added)
|
||||
{
|
||||
((BaseEntity)entry.Entity).CreatedAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
((BaseEntity)entry.Entity).UpdatedAt = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
266
backend/HardwarePerformance.Infrastructure/Data/DataSeeder.cs
Normal file
266
backend/HardwarePerformance.Infrastructure/Data/DataSeeder.cs
Normal file
@@ -0,0 +1,266 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using HardwarePerformance.Core.Entities;
|
||||
|
||||
namespace HardwarePerformance.Infrastructure.Data
|
||||
{
|
||||
public class DataSeeder
|
||||
{
|
||||
public static void SeedData(AppDbContext context)
|
||||
{
|
||||
// 确保数据库已创建
|
||||
context.Database.EnsureCreated();
|
||||
|
||||
// 检查是否已有数据
|
||||
if (context.Categories.Any())
|
||||
{
|
||||
return; // 数据库已有数据,不需要种子数据
|
||||
}
|
||||
|
||||
// 添加初始产品类别
|
||||
var categories = new List<Category>
|
||||
{
|
||||
new Category
|
||||
{
|
||||
Name = "手机CPU",
|
||||
Description = "移动设备处理器性能排名"
|
||||
},
|
||||
new Category
|
||||
{
|
||||
Name = "手机GPU",
|
||||
Description = "移动设备图形处理器性能排名"
|
||||
},
|
||||
new Category
|
||||
{
|
||||
Name = "电脑CPU",
|
||||
Description = "桌面和笔记本处理器性能排名"
|
||||
},
|
||||
new Category
|
||||
{
|
||||
Name = "电脑GPU",
|
||||
Description = "桌面和笔记本图形处理器性能排名"
|
||||
}
|
||||
};
|
||||
|
||||
context.Categories.AddRange(categories);
|
||||
context.SaveChanges();
|
||||
|
||||
// 添加初始数据源
|
||||
var dataSources = new List<DataSource>
|
||||
{
|
||||
new DataSource
|
||||
{
|
||||
Name = "Geekbench",
|
||||
Description = "跨平台处理器和内存性能测试工具",
|
||||
ApiUrl = "https://browser.geekbench.com/"
|
||||
},
|
||||
new DataSource
|
||||
{
|
||||
Name = "3DMark",
|
||||
Description = "游戏和图形性能基准测试工具",
|
||||
ApiUrl = "https://www.3dmark.com/"
|
||||
},
|
||||
new DataSource
|
||||
{
|
||||
Name = "AnTuTu",
|
||||
Description = "移动设备综合性能测试平台",
|
||||
ApiUrl = "https://www.antutu.com/"
|
||||
}
|
||||
};
|
||||
|
||||
context.DataSources.AddRange(dataSources);
|
||||
context.SaveChanges();
|
||||
|
||||
// 添加一些示例产品数据
|
||||
var mobileCpuCategory = context.Categories.FirstOrDefault(c => c.Name == "手机CPU");
|
||||
var mobileGpuCategory = context.Categories.FirstOrDefault(c => c.Name == "手机GPU");
|
||||
var desktopCpuCategory = context.Categories.FirstOrDefault(c => c.Name == "电脑CPU");
|
||||
var desktopGpuCategory = context.Categories.FirstOrDefault(c => c.Name == "电脑GPU");
|
||||
|
||||
var geekbenchSource = context.DataSources.FirstOrDefault(s => s.Name == "Geekbench");
|
||||
var threeDMarkSource = context.DataSources.FirstOrDefault(s => s.Name == "3DMark");
|
||||
var antutuSource = context.DataSources.FirstOrDefault(s => s.Name == "AnTuTu");
|
||||
|
||||
if (mobileCpuCategory != null && geekbenchSource != null)
|
||||
{
|
||||
var mobileCpus = new List<Product>
|
||||
{
|
||||
new Product
|
||||
{
|
||||
Name = "Apple A17 Pro",
|
||||
Model = "A17 Pro",
|
||||
Manufacturer = "Apple",
|
||||
ReleaseDate = new DateTime(2023, 9, 1),
|
||||
ImageUrl = "/images/apple-a17-pro.jpg",
|
||||
CategoryId = mobileCpuCategory.Id,
|
||||
CurrentRank = 1
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Name = "Snapdragon 8 Gen 3",
|
||||
Model = "SM8650-AB",
|
||||
Manufacturer = "Qualcomm",
|
||||
ReleaseDate = new DateTime(2023, 10, 1),
|
||||
ImageUrl = "/images/snapdragon-8-gen-3.jpg",
|
||||
CategoryId = mobileCpuCategory.Id,
|
||||
CurrentRank = 2
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Name = "MediaTek Dimensity 9300",
|
||||
Model = "MT6989",
|
||||
Manufacturer = "MediaTek",
|
||||
ReleaseDate = new DateTime(2023, 11, 1),
|
||||
ImageUrl = "/images/dimensity-9300.jpg",
|
||||
CategoryId = mobileCpuCategory.Id,
|
||||
CurrentRank = 3
|
||||
}
|
||||
};
|
||||
|
||||
context.Products.AddRange(mobileCpus);
|
||||
context.SaveChanges();
|
||||
|
||||
// 添加性能分数
|
||||
var performanceScores = new List<PerformanceScore>();
|
||||
foreach (var cpu in mobileCpus)
|
||||
{
|
||||
performanceScores.Add(new PerformanceScore
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
BenchmarkType = "Single-Core",
|
||||
Score = cpu.Name.Contains("A17") ? 2950 : cpu.Name.Contains("Snapdragon") ? 2300 : 2200,
|
||||
TestDate = DateTime.Now,
|
||||
DataSourceId = geekbenchSource.Id
|
||||
});
|
||||
|
||||
performanceScores.Add(new PerformanceScore
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
BenchmarkType = "Multi-Core",
|
||||
Score = cpu.Name.Contains("A17") ? 7200 : cpu.Name.Contains("Snapdragon") ? 7400 : 7500,
|
||||
TestDate = DateTime.Now,
|
||||
DataSourceId = geekbenchSource.Id
|
||||
});
|
||||
}
|
||||
|
||||
context.PerformanceScores.AddRange(performanceScores);
|
||||
context.SaveChanges();
|
||||
|
||||
// 添加规格参数
|
||||
var specifications = new List<Specification>();
|
||||
foreach (var cpu in mobileCpus)
|
||||
{
|
||||
if (cpu.Name.Contains("A17"))
|
||||
{
|
||||
specifications.Add(new Specification
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
Key = "制程工艺",
|
||||
Value = "3nm",
|
||||
Unit = "nm"
|
||||
});
|
||||
specifications.Add(new Specification
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
Key = "核心数",
|
||||
Value = "6",
|
||||
Unit = "核"
|
||||
});
|
||||
}
|
||||
else if (cpu.Name.Contains("Snapdragon"))
|
||||
{
|
||||
specifications.Add(new Specification
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
Key = "制程工艺",
|
||||
Value = "4nm",
|
||||
Unit = "nm"
|
||||
});
|
||||
specifications.Add(new Specification
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
Key = "核心数",
|
||||
Value = "8",
|
||||
Unit = "核"
|
||||
});
|
||||
}
|
||||
else if (cpu.Name.Contains("Dimensity"))
|
||||
{
|
||||
specifications.Add(new Specification
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
Key = "制程工艺",
|
||||
Value = "4nm",
|
||||
Unit = "nm"
|
||||
});
|
||||
specifications.Add(new Specification
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
Key = "核心数",
|
||||
Value = "8",
|
||||
Unit = "核"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
context.Specifications.AddRange(specifications);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
if (desktopCpuCategory != null && geekbenchSource != null)
|
||||
{
|
||||
var desktopCpus = new List<Product>
|
||||
{
|
||||
new Product
|
||||
{
|
||||
Name = "Intel Core i9-14900K",
|
||||
Model = "i9-14900K",
|
||||
Manufacturer = "Intel",
|
||||
ReleaseDate = new DateTime(2023, 10, 1),
|
||||
ImageUrl = "/images/intel-i9-14900k.jpg",
|
||||
CategoryId = desktopCpuCategory.Id,
|
||||
CurrentRank = 1
|
||||
},
|
||||
new Product
|
||||
{
|
||||
Name = "AMD Ryzen 9 7950X",
|
||||
Model = "Ryzen 9 7950X",
|
||||
Manufacturer = "AMD",
|
||||
ReleaseDate = new DateTime(2023, 9, 1),
|
||||
ImageUrl = "/images/amd-ryzen9-7950x.jpg",
|
||||
CategoryId = desktopCpuCategory.Id,
|
||||
CurrentRank = 2
|
||||
}
|
||||
};
|
||||
|
||||
context.Products.AddRange(desktopCpus);
|
||||
context.SaveChanges();
|
||||
|
||||
// 添加性能分数
|
||||
var performanceScores = new List<PerformanceScore>();
|
||||
foreach (var cpu in desktopCpus)
|
||||
{
|
||||
performanceScores.Add(new PerformanceScore
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
BenchmarkType = "Single-Core",
|
||||
Score = cpu.Name.Contains("Intel") ? 3200 : 2300,
|
||||
TestDate = DateTime.Now,
|
||||
DataSourceId = geekbenchSource.Id
|
||||
});
|
||||
|
||||
performanceScores.Add(new PerformanceScore
|
||||
{
|
||||
ProductId = cpu.Id,
|
||||
BenchmarkType = "Multi-Core",
|
||||
Score = cpu.Name.Contains("Intel") ? 22000 : 30000,
|
||||
TestDate = DateTime.Now,
|
||||
DataSourceId = geekbenchSource.Id
|
||||
});
|
||||
}
|
||||
|
||||
context.PerformanceScores.AddRange(performanceScores);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HardwarePerformance.Infrastructure.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Categories",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "DataSources",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
ApiUrl = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DataSources", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Products",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false),
|
||||
Model = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
Manufacturer = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
ReleaseDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
ImageUrl = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true),
|
||||
CategoryId = table.Column<int>(type: "int", nullable: false),
|
||||
CurrentRank = table.Column<int>(type: "int", nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Products", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Products_Categories_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "Categories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PerformanceScores",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
ProductId = table.Column<int>(type: "int", nullable: false),
|
||||
BenchmarkType = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false),
|
||||
Score = table.Column<decimal>(type: "decimal(10,2)", nullable: false),
|
||||
TestDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
DataSourceId = table.Column<int>(type: "int", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PerformanceScores", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PerformanceScores_DataSources_DataSourceId",
|
||||
column: x => x.DataSourceId,
|
||||
principalTable: "DataSources",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PerformanceScores_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RankingHistories",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
ProductId = table.Column<int>(type: "int", nullable: false),
|
||||
Rank = table.Column<int>(type: "int", nullable: false),
|
||||
CategoryId = table.Column<int>(type: "int", nullable: false),
|
||||
RecordDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RankingHistories", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RankingHistories_Categories_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "Categories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RankingHistories_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Specifications",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
ProductId = table.Column<int>(type: "int", nullable: false),
|
||||
Key = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||||
Value = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: false),
|
||||
Unit = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Specifications", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Specifications_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PerformanceScores_BenchmarkType",
|
||||
table: "PerformanceScores",
|
||||
column: "BenchmarkType");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PerformanceScores_ProductId",
|
||||
table: "PerformanceScores",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_CategoryId",
|
||||
table: "Products",
|
||||
column: "CategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_Manufacturer",
|
||||
table: "Products",
|
||||
column: "Manufacturer");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_Model",
|
||||
table: "Products",
|
||||
column: "Model");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_Name",
|
||||
table: "Products",
|
||||
column: "Name");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RankingHistories_CategoryId",
|
||||
table: "RankingHistories",
|
||||
column: "CategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RankingHistories_ProductId",
|
||||
table: "RankingHistories",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Specifications_ProductId",
|
||||
table: "Specifications",
|
||||
column: "ProductId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PerformanceScores");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RankingHistories");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Specifications");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "DataSources");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Products");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Categories");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using HardwarePerformance.Infrastructure.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HardwarePerformance.Infrastructure.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
partial class AppDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
MySqlModelBuilderExtensions.UseCollation(modelBuilder, "utf8mb4_0900_ai_ci");
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.DataSource", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ApiUrl")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("varchar(500)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("DataSources");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.PerformanceScore", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BenchmarkType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("DataSourceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Score")
|
||||
.HasColumnType("decimal(10,2)");
|
||||
|
||||
b.Property<DateTime>("TestDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BenchmarkType");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("PerformanceScores");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.Product", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("ImageUrl")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("varchar(500)");
|
||||
|
||||
b.Property<string>("Manufacturer")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<string>("Model")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)");
|
||||
|
||||
b.Property<int?>("CurrentRank")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("ReleaseDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.HasIndex("Manufacturer");
|
||||
|
||||
b.HasIndex("Model");
|
||||
|
||||
b.HasIndex("Name");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.RankingHistory", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Rank")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("RecordDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("RankingHistories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.Specification", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Unit")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("varchar(500)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("Specifications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.PerformanceScore", b =>
|
||||
{
|
||||
b.HasOne("HardwarePerformance.Core.Entities.DataSource", "DataSource")
|
||||
.WithMany()
|
||||
.HasForeignKey("DataSourceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwarePerformance.Core.Entities.Product", "Product")
|
||||
.WithMany("PerformanceScores")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("DataSource");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.Product", b =>
|
||||
{
|
||||
b.HasOne("HardwarePerformance.Core.Entities.Category", "Category")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.RankingHistory", b =>
|
||||
{
|
||||
b.HasOne("HardwarePerformance.Core.Entities.Category", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwarePerformance.Core.Entities.Product", "Product")
|
||||
.WithMany("RankingHistories")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.Specification", b =>
|
||||
{
|
||||
b.HasOne("HardwarePerformance.Core.Entities.Product", "Product")
|
||||
.WithMany("Specifications")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.Category", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwarePerformance.Core.Entities.Product", b =>
|
||||
{
|
||||
b.Navigation("PerformanceScores");
|
||||
|
||||
b.Navigation("RankingHistories");
|
||||
|
||||
b.Navigation("Specifications");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
using System.Data;
|
||||
using MySql.Data.MySqlClient;
|
||||
using HardwarePerformance.Core.Entities;
|
||||
|
||||
namespace HardwarePerformance.Infrastructure.Data;
|
||||
|
||||
public class SimpleAppDbContext
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
|
||||
public SimpleAppDbContext(IConfiguration configuration)
|
||||
{
|
||||
_connectionString = configuration.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
|
||||
public async Task<bool> TestConnectionAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var connection = new MySqlConnection(_connectionString);
|
||||
await connection.OpenAsync();
|
||||
return connection.State == ConnectionState.Open;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task InitializeDatabaseAsync()
|
||||
{
|
||||
using var connection = new MySqlConnection(_connectionString);
|
||||
await connection.OpenAsync();
|
||||
|
||||
// 创建Categories表
|
||||
var createCategoriesTable = @"
|
||||
CREATE TABLE IF NOT EXISTS Categories (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Name VARCHAR(100) NOT NULL,
|
||||
Description TEXT,
|
||||
CreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
)";
|
||||
|
||||
using var cmd = new MySqlCommand(createCategoriesTable, connection);
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 创建Products表
|
||||
var createProductsTable = @"
|
||||
CREATE TABLE IF NOT EXISTS Products (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Name VARCHAR(200) NOT NULL,
|
||||
Model VARCHAR(100),
|
||||
Manufacturer VARCHAR(100),
|
||||
ImageUrl VARCHAR(500),
|
||||
ReleaseDate DATE,
|
||||
CategoryId INT,
|
||||
CurrentRank INT,
|
||||
CreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (CategoryId) REFERENCES Categories(Id)
|
||||
)";
|
||||
|
||||
cmd.CommandText = createProductsTable;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 创建PerformanceScores表
|
||||
var createPerformanceScoresTable = @"
|
||||
CREATE TABLE IF NOT EXISTS PerformanceScores (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
ProductId INT NOT NULL,
|
||||
BenchmarkType VARCHAR(50) NOT NULL,
|
||||
Score INT NOT NULL,
|
||||
TestDate DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
DataSourceId INT,
|
||||
FOREIGN KEY (ProductId) REFERENCES Products(Id)
|
||||
)";
|
||||
|
||||
cmd.CommandText = createPerformanceScoresTable;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 创建DataSources表
|
||||
var createDataSourcesTable = @"
|
||||
CREATE TABLE IF NOT EXISTS DataSources (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
Name VARCHAR(100) NOT NULL,
|
||||
Description TEXT,
|
||||
WebsiteUrl VARCHAR(500),
|
||||
CreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
)";
|
||||
|
||||
cmd.CommandText = createDataSourcesTable;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 创建Specifications表
|
||||
var createSpecificationsTable = @"
|
||||
CREATE TABLE IF NOT EXISTS Specifications (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
ProductId INT NOT NULL,
|
||||
Name VARCHAR(100) NOT NULL,
|
||||
Value TEXT NOT NULL,
|
||||
Unit VARCHAR(50),
|
||||
FOREIGN KEY (ProductId) REFERENCES Products(Id)
|
||||
)";
|
||||
|
||||
cmd.CommandText = createSpecificationsTable;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 创建RankingHistories表
|
||||
var createRankingHistoriesTable = @"
|
||||
CREATE TABLE IF NOT EXISTS RankingHistories (
|
||||
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
ProductId INT NOT NULL,
|
||||
Rank INT NOT NULL,
|
||||
CategoryId INT NOT NULL,
|
||||
RecordedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (ProductId) REFERENCES Products(Id),
|
||||
FOREIGN KEY (CategoryId) REFERENCES Categories(Id)
|
||||
)";
|
||||
|
||||
cmd.CommandText = createRankingHistoriesTable;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
public async Task SeedInitialDataAsync()
|
||||
{
|
||||
using var connection = new MySqlConnection(_connectionString);
|
||||
await connection.OpenAsync();
|
||||
|
||||
// 检查是否已有数据
|
||||
var checkCategoriesCmd = new MySqlCommand("SELECT COUNT(*) FROM Categories", connection);
|
||||
var categoryCount = Convert.ToInt32(await checkCategoriesCmd.ExecuteScalarAsync());
|
||||
|
||||
if (categoryCount > 0)
|
||||
{
|
||||
return; // 已有数据,不需要种子数据
|
||||
}
|
||||
|
||||
// 插入Categories
|
||||
var insertCategories = @"
|
||||
INSERT INTO Categories (Name, Description) VALUES
|
||||
('手机CPU', '移动设备处理器'),
|
||||
('手机GPU', '移动设备图形处理器'),
|
||||
('电脑CPU', '桌面和笔记本处理器'),
|
||||
('电脑GPU', '桌面和笔记本图形处理器')";
|
||||
|
||||
using var cmd = new MySqlCommand(insertCategories, connection);
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 插入DataSources
|
||||
var insertDataSources = @"
|
||||
INSERT INTO DataSources (Name, Description, WebsiteUrl) VALUES
|
||||
('Geekbench', '处理器和内存性能测试', 'https://www.geekbench.com'),
|
||||
('3DMark', '图形和游戏性能测试', 'https://www.3dmark.com'),
|
||||
('AnTuTu', '移动设备综合性能测试', 'https://www.antutu.com')";
|
||||
|
||||
cmd.CommandText = insertDataSources;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 插入示例产品
|
||||
var insertProducts = @"
|
||||
INSERT INTO Products (Name, Model, Manufacturer, ReleaseDate, CategoryId, CurrentRank) VALUES
|
||||
('Apple A17 Pro', 'A17 Pro', 'Apple', '2023-09-12', 1, 1),
|
||||
('Snapdragon 8 Gen 3', 'SM8650-AB', 'Qualcomm', '2023-10-24', 1, 2),
|
||||
('Intel Core i9-13900K', 'Core i9-13900K', 'Intel', '2022-10-20', 3, 1),
|
||||
('AMD Ryzen 9 7950X', 'Ryzen 9 7950X', 'AMD', '2022-09-27', 3, 2),
|
||||
('NVIDIA GeForce RTX 4090', 'RTX 4090', 'NVIDIA', '2022-10-12', 4, 1),
|
||||
('AMD Radeon RX 7900 XTX', 'RX 7900 XTX', 'AMD', '2022-12-13', 4, 2)";
|
||||
|
||||
cmd.CommandText = insertProducts;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 插入性能分数
|
||||
var insertPerformanceScores = @"
|
||||
INSERT INTO PerformanceScores (ProductId, BenchmarkType, Score, DataSourceId) VALUES
|
||||
(1, 'Geekbench Single-Core', 2900, 1),
|
||||
(1, 'Geekbench Multi-Core', 7200, 1),
|
||||
(2, 'Geekbench Single-Core', 2300, 1),
|
||||
(2, 'Geekbench Multi-Core', 7400, 1),
|
||||
(3, 'Geekbench Single-Core', 3200, 1),
|
||||
(3, 'Geekbench Multi-Core', 24000, 1),
|
||||
(4, 'Geekbench Single-Core', 2600, 1),
|
||||
(4, 'Geekbench Multi-Core', 26000, 1)";
|
||||
|
||||
cmd.CommandText = insertPerformanceScores;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
// 插入规格参数
|
||||
var insertSpecifications = @"
|
||||
INSERT INTO Specifications (ProductId, Name, Value, Unit) VALUES
|
||||
(1, '工艺', '3nm', null),
|
||||
(1, '核心数', '6', '个'),
|
||||
(1, '线程数', '6', '个'),
|
||||
(2, '工艺', '4nm', null),
|
||||
(2, '核心数', '8', '个'),
|
||||
(2, '线程数', '8', '个'),
|
||||
(3, '工艺', 'Intel 7', null),
|
||||
(3, '核心数', '24', '个'),
|
||||
(3, '线程数', '32', '个'),
|
||||
(4, '工艺', '5nm', null),
|
||||
(4, '核心数', '16', '个'),
|
||||
(4, '线程数', '32', '个')";
|
||||
|
||||
cmd.CommandText = insertSpecifications;
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user