AgentSkillsCN

scaffold-delete-operation

在后端新增 DELETE 操作(软删除/标记删除)。当实现 DELETE 端点以移除资源时,可使用此技能。

SKILL.md
--- frontmatter
name: scaffold-delete-operation
description: Adds a new DELETE operation (soft delete / tombstone) to the Backend. Use this when implementing DELETE endpoints to remove resources.

Follow this guide to implement a Delete Operation (Soft Delete) in the ApiService.

  1. Define the Domain Event

    • Create a record in src/BookStore.ApiService/Events/
    • Naming: {Resource}Deleted
    • Template: templates/Event.cs
  2. Define the Command

    • Create a record in src/BookStore.ApiService/Commands/{Resource}/
    • Naming: Delete{Resource}
    • Template: templates/Command.cs
  3. Implement the Endpoint

    • Create/Update src/BookStore.ApiService/Endpoints/{Resource}Endpoints.cs
    • Pattern: Wolverine.HTTP
    • Features: Use [Aggregate] attribute to auto-load state.
    • Logic: Pure function receiving aggregate and returning (IResult, IEvent).
    • Template: templates/Endpoint.cs
  4. Update Read Models

    • Ensure your projections handle the {Resource}Deleted event (e.g., set Deleted = true or remove document).

Related Skills

  • /scaffold-create-operation: For creating new resources.
  • /scaffold-update-operation: For updating existing resources.