M2a: server workspace, kvitt-domain, skeleton routes, OpenAPI match, Dockerfile
Cargo workspace (kvitt-domain, kvitt-server, kvitt-import), Rust 1.99.1 pinned. kvitt-domain passes every Rust vector and adds next_occurrence_date (D-015). kvitt-server: config, SQLite pool (WAL, §8.9 pragmas), migration 0001 identical to the contract schema, error type for all 25 codes, auth extractor and protocol layer, all 33 routes (E-1/E-2 implemented, the rest 501), utoipa document equal to contracts/openapi.yaml, seams for M3/M4/M9, serve/migrate/healthcheck. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
//! Accounts: E-18 to E-22 (FR-6).
|
||||
//!
|
||||
//! Registered and annotated by M2a; M3 owns this file and implements the handlers (until then 501
|
||||
//! `not_implemented`).
|
||||
|
||||
use crate::api::{IdPath, not_implemented};
|
||||
use crate::auth::AuthDevice;
|
||||
use crate::error::AppError;
|
||||
use crate::openapi::responses::{BadRequest, Conflict, NotFound, Unprocessable};
|
||||
use crate::wire::{Account, CreateAccountRequest, PatchAccountRequest, UuidSchema};
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/accounts",
|
||||
operation_id = "createAccount",
|
||||
summary = "E-18 Create account",
|
||||
request_body(content = CreateAccountRequest, content_type = "application/json; charset=utf-8"),
|
||||
responses(
|
||||
(status = 201, description = "The new account.", body = Account, content_type = "application/json; charset=utf-8"),
|
||||
(status = 400, response = BadRequest),
|
||||
(status = 409, response = Conflict),
|
||||
(status = 422, response = Unprocessable),
|
||||
)
|
||||
)]
|
||||
pub async fn create_account(_device: AuthDevice) -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
patch,
|
||||
path = "/accounts/{account_id}",
|
||||
operation_id = "patchAccount",
|
||||
summary = "E-19 Rename, change default ratio",
|
||||
params(
|
||||
("account_id" = UuidSchema, Path, description = "Not a UUID is 404 `not_found`."),
|
||||
),
|
||||
request_body(content = PatchAccountRequest, content_type = "application/json; charset=utf-8"),
|
||||
responses(
|
||||
(status = 200, description = "The updated account.", body = Account, content_type = "application/json; charset=utf-8"),
|
||||
(status = 400, response = BadRequest),
|
||||
(status = 404, response = NotFound),
|
||||
(status = 409, response = Conflict),
|
||||
(status = 422, response = Unprocessable),
|
||||
)
|
||||
)]
|
||||
pub async fn patch_account(_device: AuthDevice, IdPath(_account_id): IdPath) -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/accounts/{account_id}/archive",
|
||||
operation_id = "archiveAccount",
|
||||
summary = "E-20 Archive account",
|
||||
description = "No body. Idempotent.",
|
||||
params(
|
||||
("account_id" = UuidSchema, Path, description = "Not a UUID is 404 `not_found`."),
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "The account.", body = Account, content_type = "application/json; charset=utf-8"),
|
||||
(status = 404, response = NotFound),
|
||||
)
|
||||
)]
|
||||
pub async fn archive_account(_device: AuthDevice, IdPath(_account_id): IdPath) -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/accounts/{account_id}/unarchive",
|
||||
operation_id = "unarchiveAccount",
|
||||
summary = "E-21 Unarchive account",
|
||||
description = "No body. Idempotent.",
|
||||
params(
|
||||
("account_id" = UuidSchema, Path, description = "Not a UUID is 404 `not_found`."),
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "The account.", body = Account, content_type = "application/json; charset=utf-8"),
|
||||
(status = 404, response = NotFound),
|
||||
)
|
||||
)]
|
||||
pub async fn unarchive_account(_device: AuthDevice, IdPath(_account_id): IdPath) -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/accounts/{account_id}",
|
||||
operation_id = "deleteAccount",
|
||||
summary = "E-22 Soft delete when empty",
|
||||
description = "Refused while a non-deleted expense, an allocation of a non-deleted settlement or a non-deleted recurring template references the account (AC-6.5).",
|
||||
params(
|
||||
("account_id" = UuidSchema, Path, description = "Not a UUID is 404 `not_found`."),
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "The tombstone.", body = Account, content_type = "application/json; charset=utf-8"),
|
||||
(status = 404, response = NotFound),
|
||||
(status = 409, response = Conflict),
|
||||
)
|
||||
)]
|
||||
pub async fn delete_account(_device: AuthDevice, IdPath(_account_id): IdPath) -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
Reference in New Issue
Block a user