feat(uploads): P0-1 batch 4 — server-side duplicate photo detection (409 + force + index)

契约 UploadInitRequest 加 force(bool,仅 owner/admin 跳过查重)。
服务端 init 事务前置查重:同 albumId + uploaderId + bytes 的非 deleted
照片已存在 → 409 PHOTO_DUPLICATE。photos 表加 idx_photos_dedup 索引
(迁移 20260928120000)。
App UploadInitRequest 加 force 字段 + toJson 序列化。
本地查重(层 1)+ 服务端查重(层 2)双层防线到位。

API typecheck ✅ · app analyze ✅ · 397/397 ✅ · contract lint ✅

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-28 11:29:29 +08:00
parent 33f347cdea
commit 90dcc58c33
7 changed files with 74 additions and 18 deletions
@@ -93,6 +93,7 @@ class UploadInitRequest {
required this.contentType,
this.categoryId,
this.sourceDeviceId,
this.force = false,
});
/// 目标相册 ID。
@@ -116,6 +117,9 @@ class UploadInitRequest {
/// 发起设备标识(可选,minLength 8 / maxLength 64;A19)。
final String? sourceDeviceId;
/// P0-1 层 2:跳过服务端查重(仅 owner/admin 生效)。缺省 false。
final bool force;
Map<String, dynamic> toJson() => {
'albumId': albumId,
if (categoryId != null) 'categoryId': categoryId,
@@ -124,6 +128,7 @@ class UploadInitRequest {
'bytes': bytes,
'contentType': contentType,
if (sourceDeviceId != null) 'sourceDeviceId': sourceDeviceId,
if (force) 'force': true,
};
}