Перейти к основному содержимому

Template Для Новой Feature

Назначение

Документ описывает, какие файлы создать при добавлении нового use case. Цель — чтобы API doc, CQRS implementation, tests, event docs и observability не расходились.

Структура Application

Pin.<Service>.Application/
<FeatureGroup>/
<Feature>/
<Feature>Command.cs
<Feature>CommandHandler.cs
<Feature>CommandResult.cs
<Feature>CommandValidator.cs

или для query:

Pin.<Service>.Application/
<FeatureGroup>/
<Feature>/
<Feature>Query.cs
<Feature>QueryHandler.cs
<Feature>QueryResult.cs
<Feature>QueryValidator.cs

Создаются только нужные файлы. Не добавлять пустые command/query пары.

Checklist Для API Feature

  1. Создать или обновить API method doc в docs/06-services/<service>/api/.../<method>.md.
  2. Указать actor, permission, route, request/response model, CQRS mapping.
  3. Создать command/query, handler, result, validator.
  4. Создать feature-specific policy/specification/mapping рядом с feature, если нужно.
  5. Добавить или обновить entity/event/model docs.
  6. Добавить tests:
    • validator tests;
    • handler tests;
    • API tests для auth/validation/error mapping;
    • integration tests, если есть persistence/messaging/cache/provider.
  7. Обновить service README index.
  8. Добавить observability: logs, metrics, trace names.

Checklist Для Mutation

  • transaction boundary;
  • idempotency key;
  • optimistic concurrency;
  • audit record;
  • MassTransit outbox publish/send;
  • cache invalidation;
  • state transition table;
  • reconciliation behavior для external side effects.

Checklist Для Query

  • source of truth или projection;
  • freshness SLA;
  • tenant/brand/user/partner filters;
  • paging/sorting;
  • masking;
  • cache key и TTL, если query cacheable;
  • privacy suppression, если данные агрегированные.

Naming

ТипПример
FeatureGroupUsers, Roles, Bookings, Payouts, Rankings
FeatureGetUserRoles, CreateBooking, ApprovePayoutOrder, SearchProjects
CommandCreateUserCommand
QueryGetUserRolesQuery
ResultCreateUserCommandResult, GetUserRolesQueryResult
ValidatorCreateUserCommandValidator
HandlerCreateUserCommandHandler

Definition Of Done

Feature готова, если документация, implementation, tests, observability, audit и events совпадают. Если code меняет behavior, docs обновляются в той же задаче.

Обратные ссылки

Автоссылки: где используется этот документ.