style: 命令不可变化与规范补充
This commit is contained in:
@@ -16,20 +16,15 @@ namespace TakeoutSaaS.AdminApi.Controllers;
|
||||
/// <summary>
|
||||
/// 配送单管理。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 初始化控制器。
|
||||
/// </remarks>
|
||||
[ApiVersion("1.0")]
|
||||
[Authorize]
|
||||
[Route("api/admin/v{version:apiVersion}/deliveries")]
|
||||
public sealed class DeliveriesController : BaseApiController
|
||||
public sealed class DeliveriesController(IMediator mediator) : BaseApiController
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化控制器。
|
||||
/// </summary>
|
||||
public DeliveriesController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建配送单。
|
||||
@@ -39,7 +34,7 @@ public sealed class DeliveriesController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<DeliveryOrderDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<DeliveryOrderDto>> Create([FromBody] CreateDeliveryOrderCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<DeliveryOrderDto>.Ok(result);
|
||||
}
|
||||
|
||||
@@ -58,7 +53,7 @@ public sealed class DeliveriesController : BaseApiController
|
||||
[FromQuery] bool sortDesc = true,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await _mediator.Send(new SearchDeliveryOrdersQuery
|
||||
var result = await mediator.Send(new SearchDeliveryOrdersQuery
|
||||
{
|
||||
OrderId = orderId,
|
||||
Status = status,
|
||||
@@ -80,7 +75,7 @@ public sealed class DeliveriesController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<DeliveryOrderDto>> Detail(long deliveryOrderId, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(new GetDeliveryOrderByIdQuery { DeliveryOrderId = deliveryOrderId }, cancellationToken);
|
||||
var result = await mediator.Send(new GetDeliveryOrderByIdQuery { DeliveryOrderId = deliveryOrderId }, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<DeliveryOrderDto>.Error(ErrorCodes.NotFound, "配送单不存在")
|
||||
: ApiResponse<DeliveryOrderDto>.Ok(result);
|
||||
@@ -95,8 +90,11 @@ public sealed class DeliveriesController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<DeliveryOrderDto>> Update(long deliveryOrderId, [FromBody] UpdateDeliveryOrderCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
command.DeliveryOrderId = command.DeliveryOrderId == 0 ? deliveryOrderId : command.DeliveryOrderId;
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
if (command.DeliveryOrderId == 0)
|
||||
{
|
||||
command = command with { DeliveryOrderId = deliveryOrderId };
|
||||
}
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<DeliveryOrderDto>.Error(ErrorCodes.NotFound, "配送单不存在")
|
||||
: ApiResponse<DeliveryOrderDto>.Ok(result);
|
||||
@@ -111,7 +109,7 @@ public sealed class DeliveriesController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<object>> Delete(long deliveryOrderId, CancellationToken cancellationToken)
|
||||
{
|
||||
var success = await _mediator.Send(new DeleteDeliveryOrderCommand { DeliveryOrderId = deliveryOrderId }, cancellationToken);
|
||||
var success = await mediator.Send(new DeleteDeliveryOrderCommand { DeliveryOrderId = deliveryOrderId }, cancellationToken);
|
||||
return success
|
||||
? ApiResponse<object>.Ok(null)
|
||||
: ApiResponse<object>.Error(ErrorCodes.NotFound, "配送单不存在");
|
||||
|
||||
@@ -16,20 +16,15 @@ namespace TakeoutSaaS.AdminApi.Controllers;
|
||||
/// <summary>
|
||||
/// 商户管理。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 初始化控制器。
|
||||
/// </remarks>
|
||||
[ApiVersion("1.0")]
|
||||
[Authorize]
|
||||
[Route("api/admin/v{version:apiVersion}/merchants")]
|
||||
public sealed class MerchantsController : BaseApiController
|
||||
public sealed class MerchantsController(IMediator mediator) : BaseApiController
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化控制器。
|
||||
/// </summary>
|
||||
public MerchantsController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建商户。
|
||||
@@ -39,7 +34,7 @@ public sealed class MerchantsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<MerchantDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<MerchantDto>> Create([FromBody] CreateMerchantCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<MerchantDto>.Ok(result);
|
||||
}
|
||||
|
||||
@@ -57,7 +52,7 @@ public sealed class MerchantsController : BaseApiController
|
||||
[FromQuery] bool sortDesc = true,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await _mediator.Send(new SearchMerchantsQuery
|
||||
var result = await mediator.Send(new SearchMerchantsQuery
|
||||
{
|
||||
Status = status,
|
||||
Page = page,
|
||||
@@ -77,9 +72,12 @@ public sealed class MerchantsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<MerchantDto>> Update(long merchantId, [FromBody] UpdateMerchantCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
command.MerchantId = command.MerchantId == 0 ? merchantId : command.MerchantId;
|
||||
if (command.MerchantId == 0)
|
||||
{
|
||||
command = command with { MerchantId = merchantId };
|
||||
}
|
||||
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<MerchantDto>.Error(ErrorCodes.NotFound, "商户不存在")
|
||||
: ApiResponse<MerchantDto>.Ok(result);
|
||||
@@ -94,7 +92,7 @@ public sealed class MerchantsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<object>> Delete(long merchantId, CancellationToken cancellationToken)
|
||||
{
|
||||
var success = await _mediator.Send(new DeleteMerchantCommand { MerchantId = merchantId }, cancellationToken);
|
||||
var success = await mediator.Send(new DeleteMerchantCommand { MerchantId = merchantId }, cancellationToken);
|
||||
return success
|
||||
? ApiResponse<object>.Ok(null)
|
||||
: ApiResponse<object>.Error(ErrorCodes.NotFound, "商户不存在");
|
||||
@@ -109,7 +107,7 @@ public sealed class MerchantsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<MerchantDto>> Detail(long merchantId, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(new GetMerchantByIdQuery { MerchantId = merchantId }, cancellationToken);
|
||||
var result = await mediator.Send(new GetMerchantByIdQuery { MerchantId = merchantId }, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<MerchantDto>.Error(ErrorCodes.NotFound, "商户不存在")
|
||||
: ApiResponse<MerchantDto>.Ok(result);
|
||||
|
||||
@@ -17,20 +17,15 @@ namespace TakeoutSaaS.AdminApi.Controllers;
|
||||
/// <summary>
|
||||
/// 订单管理。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 初始化控制器。
|
||||
/// </remarks>
|
||||
[ApiVersion("1.0")]
|
||||
[Authorize]
|
||||
[Route("api/admin/v{version:apiVersion}/orders")]
|
||||
public sealed class OrdersController : BaseApiController
|
||||
public sealed class OrdersController(IMediator mediator) : BaseApiController
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化控制器。
|
||||
/// </summary>
|
||||
public OrdersController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建订单。
|
||||
@@ -40,7 +35,7 @@ public sealed class OrdersController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<OrderDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<OrderDto>> Create([FromBody] CreateOrderCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<OrderDto>.Ok(result);
|
||||
}
|
||||
|
||||
@@ -61,7 +56,7 @@ public sealed class OrdersController : BaseApiController
|
||||
[FromQuery] bool sortDesc = true,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await _mediator.Send(new SearchOrdersQuery
|
||||
var result = await mediator.Send(new SearchOrdersQuery
|
||||
{
|
||||
StoreId = storeId,
|
||||
Status = status,
|
||||
@@ -85,7 +80,7 @@ public sealed class OrdersController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<OrderDto>> Detail(long orderId, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(new GetOrderByIdQuery { OrderId = orderId }, cancellationToken);
|
||||
var result = await mediator.Send(new GetOrderByIdQuery { OrderId = orderId }, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<OrderDto>.Error(ErrorCodes.NotFound, "订单不存在")
|
||||
: ApiResponse<OrderDto>.Ok(result);
|
||||
@@ -100,8 +95,11 @@ public sealed class OrdersController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<OrderDto>> Update(long orderId, [FromBody] UpdateOrderCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
command.OrderId = command.OrderId == 0 ? orderId : command.OrderId;
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
if (command.OrderId == 0)
|
||||
{
|
||||
command = command with { OrderId = orderId };
|
||||
}
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<OrderDto>.Error(ErrorCodes.NotFound, "订单不存在")
|
||||
: ApiResponse<OrderDto>.Ok(result);
|
||||
@@ -116,7 +114,7 @@ public sealed class OrdersController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<object>> Delete(long orderId, CancellationToken cancellationToken)
|
||||
{
|
||||
var success = await _mediator.Send(new DeleteOrderCommand { OrderId = orderId }, cancellationToken);
|
||||
var success = await mediator.Send(new DeleteOrderCommand { OrderId = orderId }, cancellationToken);
|
||||
return success
|
||||
? ApiResponse<object>.Ok(null)
|
||||
: ApiResponse<object>.Error(ErrorCodes.NotFound, "订单不存在");
|
||||
|
||||
@@ -16,20 +16,15 @@ namespace TakeoutSaaS.AdminApi.Controllers;
|
||||
/// <summary>
|
||||
/// 支付记录管理。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 初始化控制器。
|
||||
/// </remarks>
|
||||
[ApiVersion("1.0")]
|
||||
[Authorize]
|
||||
[Route("api/admin/v{version:apiVersion}/payments")]
|
||||
public sealed class PaymentsController : BaseApiController
|
||||
public sealed class PaymentsController(IMediator mediator) : BaseApiController
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化控制器。
|
||||
/// </summary>
|
||||
public PaymentsController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建支付记录。
|
||||
@@ -39,7 +34,7 @@ public sealed class PaymentsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<PaymentDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<PaymentDto>> Create([FromBody] CreatePaymentCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<PaymentDto>.Ok(result);
|
||||
}
|
||||
|
||||
@@ -58,7 +53,7 @@ public sealed class PaymentsController : BaseApiController
|
||||
[FromQuery] bool sortDesc = true,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await _mediator.Send(new SearchPaymentsQuery
|
||||
var result = await mediator.Send(new SearchPaymentsQuery
|
||||
{
|
||||
OrderId = orderId,
|
||||
Status = status,
|
||||
@@ -80,7 +75,7 @@ public sealed class PaymentsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<PaymentDto>> Detail(long paymentId, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(new GetPaymentByIdQuery { PaymentId = paymentId }, cancellationToken);
|
||||
var result = await mediator.Send(new GetPaymentByIdQuery { PaymentId = paymentId }, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<PaymentDto>.Error(ErrorCodes.NotFound, "支付记录不存在")
|
||||
: ApiResponse<PaymentDto>.Ok(result);
|
||||
@@ -95,8 +90,11 @@ public sealed class PaymentsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<PaymentDto>> Update(long paymentId, [FromBody] UpdatePaymentCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
command.PaymentId = command.PaymentId == 0 ? paymentId : command.PaymentId;
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
if (command.PaymentId == 0)
|
||||
{
|
||||
command = command with { PaymentId = paymentId };
|
||||
}
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<PaymentDto>.Error(ErrorCodes.NotFound, "支付记录不存在")
|
||||
: ApiResponse<PaymentDto>.Ok(result);
|
||||
@@ -111,7 +109,7 @@ public sealed class PaymentsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<object>> Delete(long paymentId, CancellationToken cancellationToken)
|
||||
{
|
||||
var success = await _mediator.Send(new DeletePaymentCommand { PaymentId = paymentId }, cancellationToken);
|
||||
var success = await mediator.Send(new DeletePaymentCommand { PaymentId = paymentId }, cancellationToken);
|
||||
return success
|
||||
? ApiResponse<object>.Ok(null)
|
||||
: ApiResponse<object>.Error(ErrorCodes.NotFound, "支付记录不存在");
|
||||
|
||||
@@ -16,20 +16,15 @@ namespace TakeoutSaaS.AdminApi.Controllers;
|
||||
/// <summary>
|
||||
/// 商品管理。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 初始化控制器。
|
||||
/// </remarks>
|
||||
[ApiVersion("1.0")]
|
||||
[Authorize]
|
||||
[Route("api/admin/v{version:apiVersion}/products")]
|
||||
public sealed class ProductsController : BaseApiController
|
||||
public sealed class ProductsController(IMediator mediator) : BaseApiController
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化控制器。
|
||||
/// </summary>
|
||||
public ProductsController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建商品。
|
||||
@@ -39,7 +34,7 @@ public sealed class ProductsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<ProductDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<ProductDto>> Create([FromBody] CreateProductCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<ProductDto>.Ok(result);
|
||||
}
|
||||
|
||||
@@ -59,7 +54,7 @@ public sealed class ProductsController : BaseApiController
|
||||
[FromQuery] bool sortDesc = true,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await _mediator.Send(new SearchProductsQuery
|
||||
var result = await mediator.Send(new SearchProductsQuery
|
||||
{
|
||||
StoreId = storeId,
|
||||
CategoryId = categoryId,
|
||||
@@ -82,7 +77,7 @@ public sealed class ProductsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<ProductDto>> Detail(long productId, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(new GetProductByIdQuery { ProductId = productId }, cancellationToken);
|
||||
var result = await mediator.Send(new GetProductByIdQuery { ProductId = productId }, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<ProductDto>.Error(ErrorCodes.NotFound, "商品不存在")
|
||||
: ApiResponse<ProductDto>.Ok(result);
|
||||
@@ -97,8 +92,11 @@ public sealed class ProductsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<ProductDto>> Update(long productId, [FromBody] UpdateProductCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
command.ProductId = command.ProductId == 0 ? productId : command.ProductId;
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
if (command.ProductId == 0)
|
||||
{
|
||||
command = command with { ProductId = productId };
|
||||
}
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<ProductDto>.Error(ErrorCodes.NotFound, "商品不存在")
|
||||
: ApiResponse<ProductDto>.Ok(result);
|
||||
@@ -113,7 +111,7 @@ public sealed class ProductsController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<object>> Delete(long productId, CancellationToken cancellationToken)
|
||||
{
|
||||
var success = await _mediator.Send(new DeleteProductCommand { ProductId = productId }, cancellationToken);
|
||||
var success = await mediator.Send(new DeleteProductCommand { ProductId = productId }, cancellationToken);
|
||||
return success
|
||||
? ApiResponse<object>.Ok(null)
|
||||
: ApiResponse<object>.Error(ErrorCodes.NotFound, "商品不存在");
|
||||
|
||||
@@ -16,20 +16,15 @@ namespace TakeoutSaaS.AdminApi.Controllers;
|
||||
/// <summary>
|
||||
/// 门店管理。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 初始化控制器。
|
||||
/// </remarks>
|
||||
[ApiVersion("1.0")]
|
||||
[Authorize]
|
||||
[Route("api/admin/v{version:apiVersion}/stores")]
|
||||
public sealed class StoresController : BaseApiController
|
||||
public sealed class StoresController(IMediator mediator) : BaseApiController
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化控制器。
|
||||
/// </summary>
|
||||
public StoresController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建门店。
|
||||
@@ -39,7 +34,7 @@ public sealed class StoresController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<StoreDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<StoreDto>> Create([FromBody] CreateStoreCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return ApiResponse<StoreDto>.Ok(result);
|
||||
}
|
||||
|
||||
@@ -58,7 +53,7 @@ public sealed class StoresController : BaseApiController
|
||||
[FromQuery] bool sortDesc = true,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await _mediator.Send(new SearchStoresQuery
|
||||
var result = await mediator.Send(new SearchStoresQuery
|
||||
{
|
||||
MerchantId = merchantId,
|
||||
Status = status,
|
||||
@@ -80,7 +75,7 @@ public sealed class StoresController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<StoreDto>> Detail(long storeId, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(new GetStoreByIdQuery { StoreId = storeId }, cancellationToken);
|
||||
var result = await mediator.Send(new GetStoreByIdQuery { StoreId = storeId }, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<StoreDto>.Error(ErrorCodes.NotFound, "门店不存在")
|
||||
: ApiResponse<StoreDto>.Ok(result);
|
||||
@@ -95,8 +90,11 @@ public sealed class StoresController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<StoreDto>> Update(long storeId, [FromBody] UpdateStoreCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
command.StoreId = command.StoreId == 0 ? storeId : command.StoreId;
|
||||
var result = await _mediator.Send(command, cancellationToken);
|
||||
if (command.StoreId == 0)
|
||||
{
|
||||
command = command with { StoreId = storeId };
|
||||
}
|
||||
var result = await mediator.Send(command, cancellationToken);
|
||||
return result == null
|
||||
? ApiResponse<StoreDto>.Error(ErrorCodes.NotFound, "门店不存在")
|
||||
: ApiResponse<StoreDto>.Ok(result);
|
||||
@@ -111,7 +109,7 @@ public sealed class StoresController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
|
||||
public async Task<ApiResponse<object>> Delete(long storeId, CancellationToken cancellationToken)
|
||||
{
|
||||
var success = await _mediator.Send(new DeleteStoreCommand { StoreId = storeId }, cancellationToken);
|
||||
var success = await mediator.Send(new DeleteStoreCommand { StoreId = storeId }, cancellationToken);
|
||||
return success
|
||||
? ApiResponse<object>.Ok(null)
|
||||
: ApiResponse<object>.Error(ErrorCodes.NotFound, "门店不存在");
|
||||
|
||||
@@ -7,65 +7,65 @@ namespace TakeoutSaaS.Application.App.Deliveries.Commands;
|
||||
/// <summary>
|
||||
/// 更新配送单命令。
|
||||
/// </summary>
|
||||
public sealed class UpdateDeliveryOrderCommand : IRequest<DeliveryOrderDto?>
|
||||
public sealed record UpdateDeliveryOrderCommand : IRequest<DeliveryOrderDto?>
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送单 ID。
|
||||
/// </summary>
|
||||
public long DeliveryOrderId { get; set; }
|
||||
public long DeliveryOrderId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单 ID。
|
||||
/// </summary>
|
||||
public long OrderId { get; set; }
|
||||
public long OrderId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商。
|
||||
/// </summary>
|
||||
public DeliveryProvider Provider { get; set; } = DeliveryProvider.InHouse;
|
||||
public DeliveryProvider Provider { get; init; } = DeliveryProvider.InHouse;
|
||||
|
||||
/// <summary>
|
||||
/// 第三方单号。
|
||||
/// </summary>
|
||||
public string? ProviderOrderId { get; set; }
|
||||
public string? ProviderOrderId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态。
|
||||
/// </summary>
|
||||
public DeliveryStatus Status { get; set; } = DeliveryStatus.Pending;
|
||||
public DeliveryStatus Status { get; init; } = DeliveryStatus.Pending;
|
||||
|
||||
/// <summary>
|
||||
/// 配送费。
|
||||
/// </summary>
|
||||
public decimal? DeliveryFee { get; set; }
|
||||
public decimal? DeliveryFee { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 骑手姓名。
|
||||
/// </summary>
|
||||
public string? CourierName { get; set; }
|
||||
public string? CourierName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 骑手电话。
|
||||
/// </summary>
|
||||
public string? CourierPhone { get; set; }
|
||||
public string? CourierPhone { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 下发时间。
|
||||
/// </summary>
|
||||
public DateTime? DispatchedAt { get; set; }
|
||||
public DateTime? DispatchedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 取餐时间。
|
||||
/// </summary>
|
||||
public DateTime? PickedUpAt { get; set; }
|
||||
public DateTime? PickedUpAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成时间。
|
||||
/// </summary>
|
||||
public DateTime? DeliveredAt { get; set; }
|
||||
public DateTime? DeliveredAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 异常原因。
|
||||
/// </summary>
|
||||
public string? FailureReason { get; set; }
|
||||
public string? FailureReason { get; init; }
|
||||
}
|
||||
|
||||
@@ -7,45 +7,45 @@ namespace TakeoutSaaS.Application.App.Merchants.Commands;
|
||||
/// <summary>
|
||||
/// 更新商户命令。
|
||||
/// </summary>
|
||||
public sealed class UpdateMerchantCommand : IRequest<MerchantDto?>
|
||||
public sealed record UpdateMerchantCommand : IRequest<MerchantDto?>
|
||||
{
|
||||
/// <summary>
|
||||
/// 商户 ID。
|
||||
/// </summary>
|
||||
public long MerchantId { get; set; }
|
||||
public long MerchantId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 品牌名称。
|
||||
/// </summary>
|
||||
public string BrandName { get; set; } = string.Empty;
|
||||
public string BrandName { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 品牌简称。
|
||||
/// </summary>
|
||||
public string? BrandAlias { get; set; }
|
||||
public string? BrandAlias { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Logo 地址。
|
||||
/// </summary>
|
||||
public string? LogoUrl { get; set; }
|
||||
public string? LogoUrl { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 品类。
|
||||
/// </summary>
|
||||
public string? Category { get; set; }
|
||||
public string? Category { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 联系电话。
|
||||
/// </summary>
|
||||
public string ContactPhone { get; set; } = string.Empty;
|
||||
public string ContactPhone { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 联系邮箱。
|
||||
/// </summary>
|
||||
public string? ContactEmail { get; set; }
|
||||
public string? ContactEmail { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 入驻状态。
|
||||
/// </summary>
|
||||
public MerchantStatus Status { get; set; }
|
||||
public MerchantStatus Status { get; init; }
|
||||
}
|
||||
|
||||
@@ -8,110 +8,110 @@ namespace TakeoutSaaS.Application.App.Orders.Commands;
|
||||
/// <summary>
|
||||
/// 更新订单命令。
|
||||
/// </summary>
|
||||
public sealed class UpdateOrderCommand : IRequest<OrderDto?>
|
||||
public sealed record UpdateOrderCommand : IRequest<OrderDto?>
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单 ID。
|
||||
/// </summary>
|
||||
public long OrderId { get; set; }
|
||||
public long OrderId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号。
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; } = string.Empty;
|
||||
public string OrderNo { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 门店 ID。
|
||||
/// </summary>
|
||||
public long StoreId { get; set; }
|
||||
public long StoreId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 渠道。
|
||||
/// </summary>
|
||||
public OrderChannel Channel { get; set; } = OrderChannel.MiniProgram;
|
||||
public OrderChannel Channel { get; init; } = OrderChannel.MiniProgram;
|
||||
|
||||
/// <summary>
|
||||
/// 履约方式。
|
||||
/// </summary>
|
||||
public DeliveryType DeliveryType { get; set; } = DeliveryType.DineIn;
|
||||
public DeliveryType DeliveryType { get; init; } = DeliveryType.DineIn;
|
||||
|
||||
/// <summary>
|
||||
/// 状态。
|
||||
/// </summary>
|
||||
public OrderStatus Status { get; set; } = OrderStatus.PendingPayment;
|
||||
public OrderStatus Status { get; init; } = OrderStatus.PendingPayment;
|
||||
|
||||
/// <summary>
|
||||
/// 支付状态。
|
||||
/// </summary>
|
||||
public PaymentStatus PaymentStatus { get; set; } = PaymentStatus.Unpaid;
|
||||
public PaymentStatus PaymentStatus { get; init; } = PaymentStatus.Unpaid;
|
||||
|
||||
/// <summary>
|
||||
/// 顾客姓名。
|
||||
/// </summary>
|
||||
public string? CustomerName { get; set; }
|
||||
public string? CustomerName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 顾客手机号。
|
||||
/// </summary>
|
||||
public string? CustomerPhone { get; set; }
|
||||
public string? CustomerPhone { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 桌号。
|
||||
/// </summary>
|
||||
public string? TableNo { get; set; }
|
||||
public string? TableNo { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 排队号。
|
||||
/// </summary>
|
||||
public string? QueueNumber { get; set; }
|
||||
public string? QueueNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 预约 ID。
|
||||
/// </summary>
|
||||
public long? ReservationId { get; set; }
|
||||
public long? ReservationId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品金额。
|
||||
/// </summary>
|
||||
public decimal ItemsAmount { get; set; }
|
||||
public decimal ItemsAmount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 优惠金额。
|
||||
/// </summary>
|
||||
public decimal DiscountAmount { get; set; }
|
||||
public decimal DiscountAmount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 应付金额。
|
||||
/// </summary>
|
||||
public decimal PayableAmount { get; set; }
|
||||
public decimal PayableAmount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 实付金额。
|
||||
/// </summary>
|
||||
public decimal PaidAmount { get; set; }
|
||||
public decimal PaidAmount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 支付时间。
|
||||
/// </summary>
|
||||
public DateTime? PaidAt { get; set; }
|
||||
public DateTime? PaidAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成时间。
|
||||
/// </summary>
|
||||
public DateTime? FinishedAt { get; set; }
|
||||
public DateTime? FinishedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 取消时间。
|
||||
/// </summary>
|
||||
public DateTime? CancelledAt { get; set; }
|
||||
public DateTime? CancelledAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 取消原因。
|
||||
/// </summary>
|
||||
public string? CancelReason { get; set; }
|
||||
public string? CancelReason { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注。
|
||||
/// </summary>
|
||||
public string? Remark { get; set; }
|
||||
public string? Remark { get; init; }
|
||||
}
|
||||
|
||||
@@ -7,55 +7,55 @@ namespace TakeoutSaaS.Application.App.Payments.Commands;
|
||||
/// <summary>
|
||||
/// 更新支付记录命令。
|
||||
/// </summary>
|
||||
public sealed class UpdatePaymentCommand : IRequest<PaymentDto?>
|
||||
public sealed record UpdatePaymentCommand : IRequest<PaymentDto?>
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付记录 ID。
|
||||
/// </summary>
|
||||
public long PaymentId { get; set; }
|
||||
public long PaymentId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单 ID。
|
||||
/// </summary>
|
||||
public long OrderId { get; set; }
|
||||
public long OrderId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 支付方式。
|
||||
/// </summary>
|
||||
public PaymentMethod Method { get; set; } = PaymentMethod.Unknown;
|
||||
public PaymentMethod Method { get; init; } = PaymentMethod.Unknown;
|
||||
|
||||
/// <summary>
|
||||
/// 支付状态。
|
||||
/// </summary>
|
||||
public PaymentStatus Status { get; set; } = PaymentStatus.Unpaid;
|
||||
public PaymentStatus Status { get; init; } = PaymentStatus.Unpaid;
|
||||
|
||||
/// <summary>
|
||||
/// 金额。
|
||||
/// </summary>
|
||||
public decimal Amount { get; set; }
|
||||
public decimal Amount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台交易号。
|
||||
/// </summary>
|
||||
public string? TradeNo { get; set; }
|
||||
public string? TradeNo { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 渠道单号。
|
||||
/// </summary>
|
||||
public string? ChannelTransactionId { get; set; }
|
||||
public string? ChannelTransactionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 支付时间。
|
||||
/// </summary>
|
||||
public DateTime? PaidAt { get; set; }
|
||||
public DateTime? PaidAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注。
|
||||
/// </summary>
|
||||
public string? Remark { get; set; }
|
||||
public string? Remark { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 原始回调。
|
||||
/// </summary>
|
||||
public string? Payload { get; set; }
|
||||
public string? Payload { get; init; }
|
||||
}
|
||||
|
||||
@@ -7,100 +7,100 @@ namespace TakeoutSaaS.Application.App.Products.Commands;
|
||||
/// <summary>
|
||||
/// 更新商品命令。
|
||||
/// </summary>
|
||||
public sealed class UpdateProductCommand : IRequest<ProductDto?>
|
||||
public sealed record UpdateProductCommand : IRequest<ProductDto?>
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品 ID。
|
||||
/// </summary>
|
||||
public long ProductId { get; set; }
|
||||
public long ProductId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 门店 ID。
|
||||
/// </summary>
|
||||
public long StoreId { get; set; }
|
||||
public long StoreId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类 ID。
|
||||
/// </summary>
|
||||
public long CategoryId { get; set; }
|
||||
public long CategoryId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品编码。
|
||||
/// </summary>
|
||||
public string SpuCode { get; set; } = string.Empty;
|
||||
public string SpuCode { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 名称。
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Name { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 副标题。
|
||||
/// </summary>
|
||||
public string? Subtitle { get; set; }
|
||||
public string? Subtitle { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位。
|
||||
/// </summary>
|
||||
public string? Unit { get; set; }
|
||||
public string? Unit { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 现价。
|
||||
/// </summary>
|
||||
public decimal Price { get; set; }
|
||||
public decimal Price { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 原价。
|
||||
/// </summary>
|
||||
public decimal? OriginalPrice { get; set; }
|
||||
public decimal? OriginalPrice { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 库存数量。
|
||||
/// </summary>
|
||||
public int? StockQuantity { get; set; }
|
||||
public int? StockQuantity { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 每单限购。
|
||||
/// </summary>
|
||||
public int? MaxQuantityPerOrder { get; set; }
|
||||
public int? MaxQuantityPerOrder { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态。
|
||||
/// </summary>
|
||||
public ProductStatus Status { get; set; } = ProductStatus.Draft;
|
||||
public ProductStatus Status { get; init; } = ProductStatus.Draft;
|
||||
|
||||
/// <summary>
|
||||
/// 主图。
|
||||
/// </summary>
|
||||
public string? CoverImage { get; set; }
|
||||
public string? CoverImage { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 图集。
|
||||
/// </summary>
|
||||
public string? GalleryImages { get; set; }
|
||||
public string? GalleryImages { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述。
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
public string? Description { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 支持堂食。
|
||||
/// </summary>
|
||||
public bool EnableDineIn { get; set; } = true;
|
||||
public bool EnableDineIn { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 支持自提。
|
||||
/// </summary>
|
||||
public bool EnablePickup { get; set; } = true;
|
||||
public bool EnablePickup { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 支持配送。
|
||||
/// </summary>
|
||||
public bool EnableDelivery { get; set; } = true;
|
||||
public bool EnableDelivery { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 是否推荐。
|
||||
/// </summary>
|
||||
public bool IsFeatured { get; set; }
|
||||
public bool IsFeatured { get; init; }
|
||||
}
|
||||
|
||||
@@ -7,100 +7,100 @@ namespace TakeoutSaaS.Application.App.Stores.Commands;
|
||||
/// <summary>
|
||||
/// 更新门店命令。
|
||||
/// </summary>
|
||||
public sealed class UpdateStoreCommand : IRequest<StoreDto?>
|
||||
public sealed record UpdateStoreCommand : IRequest<StoreDto?>
|
||||
{
|
||||
/// <summary>
|
||||
/// 门店 ID。
|
||||
/// </summary>
|
||||
public long StoreId { get; set; }
|
||||
public long StoreId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 商户 ID。
|
||||
/// </summary>
|
||||
public long MerchantId { get; set; }
|
||||
public long MerchantId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 门店编码。
|
||||
/// </summary>
|
||||
public string Code { get; set; } = string.Empty;
|
||||
public string Code { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 门店名称。
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Name { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 电话。
|
||||
/// </summary>
|
||||
public string? Phone { get; set; }
|
||||
public string? Phone { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 负责人。
|
||||
/// </summary>
|
||||
public string? ManagerName { get; set; }
|
||||
public string? ManagerName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态。
|
||||
/// </summary>
|
||||
public StoreStatus Status { get; set; } = StoreStatus.Closed;
|
||||
public StoreStatus Status { get; init; } = StoreStatus.Closed;
|
||||
|
||||
/// <summary>
|
||||
/// 省份。
|
||||
/// </summary>
|
||||
public string? Province { get; set; }
|
||||
public string? Province { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 城市。
|
||||
/// </summary>
|
||||
public string? City { get; set; }
|
||||
public string? City { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 区县。
|
||||
/// </summary>
|
||||
public string? District { get; set; }
|
||||
public string? District { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 详细地址。
|
||||
/// </summary>
|
||||
public string? Address { get; set; }
|
||||
public string? Address { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 经度。
|
||||
/// </summary>
|
||||
public double? Longitude { get; set; }
|
||||
public double? Longitude { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 纬度。
|
||||
/// </summary>
|
||||
public double? Latitude { get; set; }
|
||||
public double? Latitude { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 公告。
|
||||
/// </summary>
|
||||
public string? Announcement { get; set; }
|
||||
public string? Announcement { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签。
|
||||
/// </summary>
|
||||
public string? Tags { get; set; }
|
||||
public string? Tags { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 配送半径。
|
||||
/// </summary>
|
||||
public decimal DeliveryRadiusKm { get; set; }
|
||||
public decimal DeliveryRadiusKm { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 支持堂食。
|
||||
/// </summary>
|
||||
public bool SupportsDineIn { get; set; } = true;
|
||||
public bool SupportsDineIn { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 支持自提。
|
||||
/// </summary>
|
||||
public bool SupportsPickup { get; set; } = true;
|
||||
public bool SupportsPickup { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 支持配送。
|
||||
/// </summary>
|
||||
public bool SupportsDelivery { get; set; } = true;
|
||||
public bool SupportsDelivery { get; init; } = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user