docs: 标记自提档期完成

This commit is contained in:
2025-12-04 11:51:09 +08:00
parent 2022d1c377
commit 7d6b7d8760
29 changed files with 1165 additions and 2 deletions

View File

@@ -0,0 +1,114 @@
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TakeoutSaaS.Application.App.Stores.Commands;
using TakeoutSaaS.Application.App.Stores.Dto;
using TakeoutSaaS.Application.App.Stores.Queries;
using TakeoutSaaS.Module.Authorization.Attributes;
using TakeoutSaaS.Shared.Abstractions.Constants;
using TakeoutSaaS.Shared.Abstractions.Results;
using TakeoutSaaS.Shared.Web.Api;
namespace TakeoutSaaS.AdminApi.Controllers;
/// <summary>
/// 门店自提管理。
/// </summary>
[ApiVersion("1.0")]
[Authorize]
[Route("api/admin/v{version:apiVersion}/stores/{storeId:long}/pickup")]
public sealed class StorePickupController(IMediator mediator) : BaseApiController
{
/// <summary>
/// 获取自提配置。
/// </summary>
[HttpGet("settings")]
[PermissionAuthorize("pickup-setting:read")]
[ProducesResponseType(typeof(ApiResponse<StorePickupSettingDto>), StatusCodes.Status200OK)]
public async Task<ApiResponse<StorePickupSettingDto>> GetSetting(long storeId, CancellationToken cancellationToken)
{
var result = await mediator.Send(new GetStorePickupSettingQuery { StoreId = storeId }, cancellationToken);
return result is null
? ApiResponse<StorePickupSettingDto>.Error(ErrorCodes.NotFound, "未配置自提设置")
: ApiResponse<StorePickupSettingDto>.Ok(result);
}
/// <summary>
/// 更新自提配置。
/// </summary>
[HttpPut("settings")]
[PermissionAuthorize("pickup-setting:update")]
[ProducesResponseType(typeof(ApiResponse<StorePickupSettingDto>), StatusCodes.Status200OK)]
public async Task<ApiResponse<StorePickupSettingDto>> UpsertSetting(long storeId, [FromBody] UpsertStorePickupSettingCommand command, CancellationToken cancellationToken)
{
if (command.StoreId == 0)
{
command = command with { StoreId = storeId };
}
var result = await mediator.Send(command, cancellationToken);
return ApiResponse<StorePickupSettingDto>.Ok(result);
}
/// <summary>
/// 查询档期列表。
/// </summary>
[HttpGet("slots")]
[PermissionAuthorize("pickup-slot:read")]
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<StorePickupSlotDto>>), StatusCodes.Status200OK)]
public async Task<ApiResponse<IReadOnlyList<StorePickupSlotDto>>> ListSlots(long storeId, CancellationToken cancellationToken)
{
var result = await mediator.Send(new ListStorePickupSlotsQuery { StoreId = storeId }, cancellationToken);
return ApiResponse<IReadOnlyList<StorePickupSlotDto>>.Ok(result);
}
/// <summary>
/// 创建档期。
/// </summary>
[HttpPost("slots")]
[PermissionAuthorize("pickup-slot:create")]
[ProducesResponseType(typeof(ApiResponse<StorePickupSlotDto>), StatusCodes.Status200OK)]
public async Task<ApiResponse<StorePickupSlotDto>> CreateSlot(long storeId, [FromBody] CreateStorePickupSlotCommand command, CancellationToken cancellationToken)
{
if (command.StoreId == 0)
{
command = command with { StoreId = storeId };
}
var result = await mediator.Send(command, cancellationToken);
return ApiResponse<StorePickupSlotDto>.Ok(result);
}
/// <summary>
/// 更新档期。
/// </summary>
[HttpPut("slots/{slotId:long}")]
[PermissionAuthorize("pickup-slot:update")]
[ProducesResponseType(typeof(ApiResponse<StorePickupSlotDto>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
public async Task<ApiResponse<StorePickupSlotDto>> UpdateSlot(long storeId, long slotId, [FromBody] UpdateStorePickupSlotCommand command, CancellationToken cancellationToken)
{
if (command.StoreId == 0 || command.SlotId == 0)
{
command = command with { StoreId = storeId, SlotId = slotId };
}
var result = await mediator.Send(command, cancellationToken);
return result is null
? ApiResponse<StorePickupSlotDto>.Error(ErrorCodes.NotFound, "档期不存在")
: ApiResponse<StorePickupSlotDto>.Ok(result);
}
/// <summary>
/// 删除档期。
/// </summary>
[HttpDelete("slots/{slotId:long}")]
[PermissionAuthorize("pickup-slot:delete")]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
public async Task<ApiResponse<object>> DeleteSlot(long storeId, long slotId, CancellationToken cancellationToken)
{
var success = await mediator.Send(new DeleteStorePickupSlotCommand { StoreId = storeId, SlotId = slotId }, cancellationToken);
return success ? ApiResponse<object>.Ok(null) : ApiResponse<object>.Error(ErrorCodes.NotFound, "档期不存在");
}
}

View File

@@ -290,6 +290,12 @@
"inventory:batch:read",
"inventory:batch:update",
"inventory:lock:expire",
"pickup-setting:read",
"pickup-setting:update",
"pickup-slot:read",
"pickup-slot:create",
"pickup-slot:update",
"pickup-slot:delete",
"order:create",
"order:read",
"order:update",
@@ -398,6 +404,12 @@
"inventory:batch:read",
"inventory:batch:update",
"inventory:lock:expire",
"pickup-setting:read",
"pickup-setting:update",
"pickup-slot:read",
"pickup-slot:create",
"pickup-slot:update",
"pickup-slot:delete",
"order:create",
"order:read",
"order:update",

View File

@@ -0,0 +1,31 @@
using System;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TakeoutSaaS.Application.App.Stores.Dto;
using TakeoutSaaS.Application.App.Stores.Queries;
using TakeoutSaaS.Shared.Abstractions.Results;
using TakeoutSaaS.Shared.Web.Api;
namespace TakeoutSaaS.MiniApi.Controllers;
/// <summary>
/// 小程序端自提档期查询。
/// </summary>
[ApiVersion("1.0")]
[Authorize]
[Route("api/mini/v{version:apiVersion}/stores/{storeId:long}/pickup-slots")]
public sealed class PickupSlotsController(IMediator mediator) : BaseApiController
{
/// <summary>
/// 获取指定日期可用档期。
/// </summary>
[HttpGet]
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<StorePickupSlotDto>>), StatusCodes.Status200OK)]
public async Task<ApiResponse<IReadOnlyList<StorePickupSlotDto>>> GetSlots(long storeId, [FromQuery] DateTime date, CancellationToken cancellationToken)
{
var result = await mediator.Send(new GetAvailablePickupSlotsQuery { StoreId = storeId, Date = date }, cancellationToken);
return ApiResponse<IReadOnlyList<StorePickupSlotDto>>.Ok(result);
}
}