feat: 菜品菜单查询与子资源替换完善
This commit is contained in:
@@ -171,4 +171,89 @@ public sealed class ProductsController(IMediator mediator) : BaseApiController
|
||||
? ApiResponse<ProductDto>.Error(ErrorCodes.NotFound, "商品不存在")
|
||||
: ApiResponse<ProductDto>.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换商品 SKU。
|
||||
/// </summary>
|
||||
[HttpPut("{productId:long}/skus")]
|
||||
[PermissionAuthorize("product-sku:update")]
|
||||
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<ProductSkuDto>>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<IReadOnlyList<ProductSkuDto>>> ReplaceSkus(long productId, [FromBody] ReplaceProductSkusCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
if (command.ProductId == 0)
|
||||
{
|
||||
command = command with { ProductId = productId };
|
||||
}
|
||||
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<IReadOnlyList<ProductSkuDto>>.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换商品规格。
|
||||
/// </summary>
|
||||
[HttpPut("{productId:long}/attributes")]
|
||||
[PermissionAuthorize("product-attr:update")]
|
||||
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<ProductAttributeGroupDto>>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<IReadOnlyList<ProductAttributeGroupDto>>> ReplaceAttributes(long productId, [FromBody] ReplaceProductAttributesCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
if (command.ProductId == 0)
|
||||
{
|
||||
command = command with { ProductId = productId };
|
||||
}
|
||||
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<IReadOnlyList<ProductAttributeGroupDto>>.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换商品加料。
|
||||
/// </summary>
|
||||
[HttpPut("{productId:long}/addons")]
|
||||
[PermissionAuthorize("product-addon:update")]
|
||||
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<ProductAddonGroupDto>>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<IReadOnlyList<ProductAddonGroupDto>>> ReplaceAddons(long productId, [FromBody] ReplaceProductAddonsCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
if (command.ProductId == 0)
|
||||
{
|
||||
command = command with { ProductId = productId };
|
||||
}
|
||||
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<IReadOnlyList<ProductAddonGroupDto>>.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换商品媒资。
|
||||
/// </summary>
|
||||
[HttpPut("{productId:long}/media")]
|
||||
[PermissionAuthorize("product-media:update")]
|
||||
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<ProductMediaAssetDto>>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<IReadOnlyList<ProductMediaAssetDto>>> ReplaceMedia(long productId, [FromBody] ReplaceProductMediaCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
if (command.ProductId == 0)
|
||||
{
|
||||
command = command with { ProductId = productId };
|
||||
}
|
||||
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<IReadOnlyList<ProductMediaAssetDto>>.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换商品价格策略。
|
||||
/// </summary>
|
||||
[HttpPut("{productId:long}/pricing-rules")]
|
||||
[PermissionAuthorize("product-pricing:update")]
|
||||
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<ProductPricingRuleDto>>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<IReadOnlyList<ProductPricingRuleDto>>> ReplacePricingRules(long productId, [FromBody] ReplaceProductPricingRulesCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
if (command.ProductId == 0)
|
||||
{
|
||||
command = command with { ProductId = productId };
|
||||
}
|
||||
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<IReadOnlyList<ProductPricingRuleDto>>.Ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user