U:调整所有代码格式
This commit is contained in:
1 parent
d133bacf55
commit
155b67e831
342 files changed
+9431
-9868
No files matched your search
@@ -16,7 +16,7 @@ public class ProductController : BaseController
|
||||
new Product { Id = 1, Name = "笔记本电脑", Price = 5999.00m, Stock = 50, Category = "电子产品" },
|
||||
new Product { Id = 2, Name = "无线鼠标", Price = 99.00m, Stock = 200, Category = "电子产品" },
|
||||
new Product { Id = 3, Name = "机械键盘", Price = 399.00m, Stock = 100, Category = "电子产品" },
|
||||
new Product { Id = 4, Name = "显示器", Price = 1299.00m, Stock = 30, Category = "电子产品" },
|
||||
new Product { Id = 4, Name = "显示器", Price = 1299.00m, Stock = 30, Category = "电子产品" }
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -109,14 +109,12 @@ public class ProductController : BaseController
|
||||
|
||||
var stockUpdate = await ReadJsonBodyAsync<Dictionary<string, object>>(context);
|
||||
if (stockUpdate != null && stockUpdate.TryGetValue("quantity", out var quantityObj))
|
||||
{
|
||||
if (int.TryParse(quantityObj.ToString(), out var quantity))
|
||||
{
|
||||
product.Stock = quantity;
|
||||
await WriteSuccessResponseAsync(context, product, "库存更新成功");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await BadRequestAsync(context, "无效的库存数量");
|
||||
}
|
||||
@@ -190,4 +188,4 @@ public class Product
|
||||
public decimal Price { get; set; }
|
||||
public int Stock { get; set; }
|
||||
public string Category { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user