refactor(diary): Phase 3 质量提升 — 201 状态码 + OpenAPI 文档 + DiaryEvent 类型安全
前端: - fix(app): Isar native 文件直接导入 isar_database_native.dart,消除 5 个条件导出类型错误 - chore(app): build_runner 重新生成 .g.dart 文件 (102 outputs) - fix(app): 移除 secure_token_store_factory 未使用的 kIsWeb import 后端: - refactor(diary): 所有创建端点 POST 返回 201 Created (9 handler, 11 端点) - feat(diary): DiaryApiDoc OpenApi derive — 42 路径 + 32 Schema 汇总到 Swagger - feat(diary): DiaryEvent 枚举添加 event_type/payload/to_domain_event 方法 + 4 测试 测试: 84/84 erp-diary 通过, 509/509 全仓库通过, Flutter analyze 0 error
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// 家长中心 API 处理器 — PIPL 合规: 绑定/查阅/导出/删除
|
||||
|
||||
use axum::extract::{Extension, FromRef, Path, Query, State};
|
||||
use axum::http::StatusCode;
|
||||
use axum::response::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use utoipa::{IntoParams, ToSchema};
|
||||
@@ -71,7 +72,7 @@ pub struct DeleteResultResp {
|
||||
path = "/api/v1/diary/parent/bind",
|
||||
request_body = BindChildReq,
|
||||
responses(
|
||||
(status = 200, description = "绑定成功", body = ApiResponse<BindingResp>),
|
||||
(status = 201, description = "绑定成功", body = ApiResponse<BindingResp>),
|
||||
(status = 400, description = "已绑定该孩子"),
|
||||
(status = 401, description = "未授权"),
|
||||
(status = 403, description = "权限不足"),
|
||||
@@ -86,7 +87,7 @@ pub async fn bind_child<S>(
|
||||
State(state): State<DiaryState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
Json(req): Json<BindChildReq>,
|
||||
) -> Result<Json<ApiResponse<BindingResp>>, AppError>
|
||||
) -> Result<(StatusCode, Json<ApiResponse<BindingResp>>), AppError>
|
||||
where
|
||||
DiaryState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
@@ -102,11 +103,11 @@ where
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Json(ApiResponse::ok(BindingResp {
|
||||
Ok((StatusCode::CREATED, Json(ApiResponse::ok(BindingResp {
|
||||
binding_id: binding.id,
|
||||
child_id: binding.child_id,
|
||||
verified_at: binding.verified_at,
|
||||
})))
|
||||
}))))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
@@ -357,7 +358,7 @@ where
|
||||
path = "/api/v1/diary/parent/bindings/{binding_id}/confirm",
|
||||
params(("binding_id" = Uuid, Path, description = "绑定请求ID")),
|
||||
responses(
|
||||
(status = 200, description = "确认成功", body = ApiResponse<BindingResp>),
|
||||
(status = 201, description = "确认成功", body = ApiResponse<BindingResp>),
|
||||
(status = 401, description = "未授权"),
|
||||
(status = 403, description = "无权确认此绑定"),
|
||||
(status = 404, description = "绑定请求不存在"),
|
||||
@@ -372,7 +373,7 @@ pub async fn confirm_binding<S>(
|
||||
State(state): State<DiaryState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
Path(binding_id): Path<Uuid>,
|
||||
) -> Result<Json<ApiResponse<BindingResp>>, AppError>
|
||||
) -> Result<(StatusCode, Json<ApiResponse<BindingResp>>), AppError>
|
||||
where
|
||||
DiaryState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
@@ -386,11 +387,11 @@ where
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Json(ApiResponse::ok(BindingResp {
|
||||
Ok((StatusCode::CREATED, Json(ApiResponse::ok(BindingResp {
|
||||
binding_id: binding.id,
|
||||
child_id: binding.parent_id,
|
||||
verified_at: binding.verified_at,
|
||||
})))
|
||||
}))))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
|
||||
Reference in New Issue
Block a user