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

View File

@@ -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
});
}
}
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}
}

View File

@@ -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
});
}
}

View 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
});
}
}
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -0,0 +1,6 @@
@HardwarePerformance.API_HostAddress = http://localhost:5277
GET {{HardwarePerformance.API_HostAddress}}/weatherforecast/
Accept: application/json
###

View 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; }
}
}

View 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();

View File

@@ -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"
}
}
}
}

View File

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

View 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": "*"
}

View File

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

View File

@@ -0,0 +1,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 类生成。

View File

@@ -0,0 +1 @@
c864e8af1f73ac3c0cfb752888ca009da1d159a83d0f6648240e670a9d6a467e

View File

@@ -0,0 +1,21 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb = true
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = 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 =

View File

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

View File

@@ -0,0 +1 @@
e5921e7a1919c86641a4559f89f9c7d56174547a0006dc67be9c5fd271f1bbad

View File

@@ -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

View File

@@ -0,0 +1 @@
{"GlobalPropertiesHash":"iWexcF6oOYdga2d9awG8b+J7CuzlMv2HGwFcrf0LVc0=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["BX3rnoxloELJyRpTcP/qR1aocjFsd8x57atK9sOV7lw=","P2fT07pEO/tA2nDzvyPju\u002BR2V67D1LAa\u002Bk2qYNEReD4="],"CachedAssets":{},"CachedCopyCandidates":{}}

View File

@@ -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"
}
}
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,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"
}
]
}

View 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": []
}
]
}